Skip to content

Commit

Permalink
ds_map_search
Browse files Browse the repository at this point in the history
  • Loading branch information
omicronrex committed Apr 1, 2024
1 parent e960290 commit 08a359b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
14 changes: 13 additions & 1 deletion 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": "23/03/2024",
"date": "01/04/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 @@ -1408,6 +1408,18 @@
2
],
"returntype": 2
},
{
"name": "ds_map_search",
"extname": "",
"calltype": 2,
"helpline": "ds_map_search(map,value)",
"hidden": false,
"argtypes": [
2,
2
],
"returntype": 2
}
],
"constants": []
Expand Down
23 changes: 23 additions & 0 deletions source/data_structures.gml
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,29 @@
return argument[0];


#define ds_map_search
///ds_map_search(map,value)
//map: map to search through
//value: key value to find
//returns: first occurrence of key containing the value, or "undefined"
var __map,__find,__key,__str;

__map=argument0
__find=argument1
__str=is_string(__find)

__key=ds_map_find_first(__map)

repeat (ds_map_size(__map)) {
__cur=ds_map_find_value(__map,__key)
if (__str) {if (is_string(__cur)) if (__cur==__find) return __key}
else {if (is_real(__cur)) if (__cur==__find) return __key}
__key=ds_map_find_next(__map,__key)
}

return undefined


#define is_undefined
///is_undefined(val)
//val - value to check
Expand Down

0 comments on commit 08a359b

Please sign in to comment.