no, using a data structure is ok for structuring data. But here you are using the wrong kind of structure. A list or gird represents data with some form of order, and really should have each element be of the same base type.
Yes, you can use them for other purposes, but the type of a data structure should convey as much information about how it is used as its name.
a more accurate data structure would be maps. But then they dont offer the best performance.
But really, what you are doing is grouping variables.
So, what in GM represents a bag of variables... instances! (And in the, i hope, not so distant future, lightweight instances).
That way, its clear what the data structure is for.
seriously did you never experience those old GM projects? I mean, I did it too. I would use (abuse?) grids like that a lot, but that was because their was no way to pass data by reference.
exactly, a 2d structure.
what you described, was more like a bag, or perhaps a map of bags.
they are not ordered 2d structures.
(oh by bag, I something kind of like a set.)
So you propose that I create an instance, which will do a lot of processing for all the internal variables/actions checking that GameMaker does on instances, only to store variables ?
There was a time where I would create objects like 'obj_item' and store default item properties there. But then, to access the values, I would need at least one instance of that item in the room.
This means I'd have to instanciate or at least check that the instance existts before trying to access modify the value. That doesn't make any sense to me.
Why would I need an instance, an object, if all I care about is the equivalent of a C++ class ? A very basic structure that does nothing more than hold values ?
GameMaker is an untyped language so I made use of that by treating ds_structures like c++ classes.
I often need to 'hold' 2 or 3 variables inside another varaible. And that variable is part of a collection that is itself part of another collection.
In those situations, you propose that my 2 variable structure be an instance, say 'oToken', and many of those would be inside a ds_list inside a 'oMessage' ?
And then many 'oMessage' would be inside a queue inside an 'oDialog' ?
No thank you. I'm not creating hundreds of instances containing only 2 properties, no thank you.
I think I'll stick to using 1x2 grids inside ds_lists inside ds_queues, which I can free whennever I don't need them anymore.
I abstract everything through the use of scripts in order to make everything conveniently easy to use/remember.
Code:
var _newToken = ???_create_token(val1, val2);
var _tokenFromMessage = ???_message_token_at(token, index);
???_dialog_add_message(_mesgShowTheWay);
This is how I code. I guess we simply see things differently.