N
Niall Edwards
Guest
Is it a ds_list or an array when accessing such a variable in a script, function or action in gml?
It is an array if you select Multi-select, otherwise it contains whatever data type (string, number, etc.) the selected item is out of all the possible values you provide. When you say you want the variable to be a list, in the interface, you're not saying you want the variable to contain a list at runtime, you're telling the GUI to give you the ability to have a list to pick values from at design time and whatever type that value is, is what you'll have at runtime. I suspect that GMS is more or less doing a textual replacement when compiling so you could write anything you want there that is a valid expression that could be on the right-hand side of an assignment roughly as if you had written a variable initialization yourself.Is it a ds_list or an array when accessing such a variable in a script, function or action in gml?
Good luck with that kind of saving system, as you cannot distinguish between ds_lists, ds_maps, ds_grids assigned to a variable, etc., due to the creation functions not keeping the values unique across all data structures. Because of this you can have a ds_list with id 0 and a ds_map with id 0, and ds_exists(0, ds_list) as well as ds_exists(0, ds_map) will return true, and you cannot tell without metadata what a given variable refers to (is the given variable a ds_list or a ds_map if both exists, but 0 is assigned to two different variables), or if it's just a number like a position or index and not an data structure id.@chamaeleon , so, I think you're saying that the 'list' I create in that part of the Object Editor can be accessed, interrogated and added to in gml as an array? Presumably, in gml, if I ask if that variable is an array it will return as true?
The reason I'm asking is I'm writing a save system which interrogates all variables in an instance, all defined instance types, and saves their relevant pre-built and defined variables, their type and value... So, will such code think this particular 'list' variable is an array? I think you are saying, yes it will...?
show_debug_message("is_array(testvar) = " + string(is_array(testvar)));
show_debug_message("testvar = " + string(testvar));
show_debug_message("testvar[0] = " + string(testvar[0]));
is_array(testvar) = 1
testvar = { { Item 0,Item 1 }, }
testvar[0] = Item 0