• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Quick #macro question

GMWolf

aka fel666
How is using a "data structure" bad for "structuring" "data" ?
Using a grid to store information in a 2d structure is what it's meant for if I'm not mistaken.
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.

Using a grid to store information in a 2d structure is what it's meant for if I'm not mistaken.
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.)
 
C

CedSharp

Guest
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.
 

GMWolf

aka fel666
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 ?
yes
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.
no, you can name instances, allowing for "direct" access to it.
also, do you suggest i should check if the global variable has been declared? same logic...
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 was unaware that is all we cared about.
I personally care about maintainability and compatibility.

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' ?
Actually in that case I suggest you use the "array struct" pattern. Far from perfect, but eh.
Notice how structs are different than global variables though. slightly different use cases.

No thank you. I'm not creating hundreds of instances containing only 2 properties, no thank you.
again, not 100s.
I'm talking about systems.
If you want to have something more akin to a struct, then arrays are the way to go (passed by reference, garbage collected, and uniquely identified. can use enums to identify fields) Data structures are not uniquely identified, that can cause problems, and instances are too heavy to create/destroy).

but notice that systems and structs serve different roles.
 
Top