Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ds_*_many functions #13

Merged
merged 3 commits into from
Mar 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 56 additions & 2 deletions gm82core.gej
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"folder": "gm82",
"version": "1.6",
"author": "renex, Floogle, Lovey01, cam900, Adamcake, YellowAfterlife, Verve",
"date": "28/02/2024",
"date": "17/02/2024",
"license": "Free to use, also for commercial games.",
"description": "Part of the standard Game Maker 8.2 distribution. This extension package contains a number of helper functions that are commonly used, and also geometry functions introduced in GM:Studio. This extension is also required for using the other GM 8.2 extensions, Sound and Joystick.",
"helpfile": "",
Expand Down Expand Up @@ -1283,6 +1283,15 @@
],
"returntype": 2
},
{
"name": "ds_list_add_many",
"extname": "",
"calltype": 2,
"helpline": "ds_list_add_many(list,val...])",
"hidden": false,
"argtypes": null,
"returntype": 2
},
{
"name": "ds_map_add_copy",
"extname": "",
Expand Down Expand Up @@ -1344,6 +1353,51 @@
],
"returntype": 2
},
{
"name": "ds_map_set_many",
"extname": "",
"calltype": 2,
"helpline": "ds_map_set_many(map,key1,value1,key2,value2...)",
"hidden": false,
"argtypes": null,
"returntype": 2
},
{
"name": "ds_stack_push_many",
"extname": "",
"calltype": 2,
"helpline": "ds_stack_push_many(stack,val...)",
"hidden": false,
"argtypes": null,
"returntype": 2
},
{
"name": "ds_queue_enqueue_many",
"extname": "",
"calltype": 2,
"helpline": "ds_queue_enqueue_many(queue,val...)",
"hidden": false,
"argtypes": null,
"returntype": 2
},
{
"name": "ds_priority_add_many",
"extname": "",
"calltype": 2,
"helpline": "ds_priority_add_many(queue,val1,prio1,val2,prio2...)",
"hidden": false,
"argtypes": null,
"returntype": 2
},
{
"name": "ds_grid_set_many",
"extname": "",
"calltype": 2,
"helpline": "ds_grid_set_many(grid,x1,y1,value1,x2,y2,value2...)",
"hidden": false,
"argtypes": null,
"returntype": 2
},
{
"name": "is_undefined",
"extname": "",
Expand Down Expand Up @@ -2378,4 +2432,4 @@
"constants": []
}
]
}
}
113 changes: 112 additions & 1 deletion source/data_structures.gml
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@
return true


#define ds_list_add_many
///ds_list_add_many(list,val...])
//list: ds list index
//val: value(s) to add
//returns: ds list index
//Adds any number of values to the provided list.
var __i;

__i=1;
repeat (argument_count-1) {
ds_list_add(argument[0],argument[__i]);
__i+=1;
}

return argument[0];


#define ds_map_add_copy
///ds_map_add_copy(src,dest)
//src, dest: ds map indexes
Expand Down Expand Up @@ -204,11 +221,105 @@
return argument2


#define ds_map_set_many
///ds_map_set_many(map,key1,value1,key2,value2...)
//map: ds map index
//key1,value1: first key-value pair
//key2,value2: second key-value pair
//etc
//returns: ds map index
//Sets any number of map keys at once.
var __i;

__i=1;
repeat (floor((argument_count-1)/2)) {
if (ds_map_exists(argument[0],argument[__i]))
ds_map_replace(argument[0],argument[__i],argument[__i+1]);
else
ds_map_add(argument[0],argument[__i],argument[__i+1]);
__i+=2;
}

return argument[0];


#define ds_stack_push_many
///ds_stack_push_many(stack,val...)
//stack: ds stack index
//val: value(s) to push
//returns: ds stack index
//Pushes any number of values onto the stack.
var __i;

__i=1;
repeat (argument_count-1) {
ds_stack_push(argument[0], argument[__i]);
__i+=1;
}

return argument[0];


#define ds_queue_enqueue_many
///ds_queue_enqueue_many(queue,val...)
//queue: ds queue index
//val: value(s) to enqueue
//returns: ds queue index
//Enqueues any number of values to the queue.
var __i;

__i=1;
repeat (argument_count-1) {
ds_queue_enqueue(argument[0],argument[__i]);
__i+=1;
}

return argument[0];


#define ds_priority_add_many
///ds_priority_add_many(queue,val1,prio1,val2,prio2...)
//queue: ds priority queue index
//val1,prio1: first value and its priority
//val2,prio2: second value and its priority
//etc
//returns: ds priority queue index
//Adds any number of values to the priority queue.
var __i;

__i=1;
repeat (floor((argument_count-1)/2)) {
ds_priority_add(argument[0],argument[__i],argument[__i+1]);
__i+=2;
}

return argument[0];


#define ds_grid_set_many
///ds_grid_set_many(grid,x1,y1,value1,x2,y2,value2...)
//grid: ds grid index
//x1,y1,value1: first position and value to set
//x2,y2,value2: second position and value to set
//etc
//returns: ds grid index
//Sets any number of values in the grid.
var __i;

__i=1;
repeat (floor((argument_count-1)/3)) {
ds_grid_set(argument[0],argument[__i],argument[__i+1],argument[__i+2]);
__i+=3;
}

return argument[0];


#define is_undefined
///is_undefined(val)
//val - value to check
//returns: bool
//Studio shim. checks the value against the 'undefined' constant.
return string(argument0)==undefined
//
//
//
Loading