GameMaker: Studio

GameMaker: Studio

View Stats:
Eluros Feb 12, 2017 @ 6:09pm
Loading ds_map From String?
Hey, all!

Let's say I have an object, "ctrl". That object contains a ds_map , "item_ds_map".

So, something like this would return a value:

with (ctrl)
{
ds_map_size(item_ds_map);
}

However, let's say that I have a string that matches the name of a ds_map. We can imagine a local variable whose value is a string, "item_ds_map".

var NameOfDataStructure;
NameOfDataStructure = "item_ds_map";

I want to be able to call functions/commands on a ds_map whose name matches a value stored in a variable. Something like this:

var NameOfDataStructure;
NameOfDataStructure = "item_ds_map";
with (ctrl)
{
ds_map_size(NameOfDataStructure);
}

However, I can't figure out a way to do it! Any ideas?

Thanks, everyone!
< >
Showing 1-1 of 1 comments
Daynar Feb 12, 2017 @ 7:41pm 
You can't really do stuff like that. When compiled the game will not know what text name each variable was given. If you really want to do it you'll need to create your own system for doing so. Since your using data structures this should be easy. Ds maps can take strings as keys so if you save the data structure in a ds map u can use a string to access the data structure.
< >
Showing 1-1 of 1 comments
Per page: 1530 50

Date Posted: Feb 12, 2017 @ 6:09pm
Posts: 1