• 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 A variable that "Holds" another variables name

M

mtski

Guest
Hello all :),

I have been making some headway on my game and have been somewhat trying to polish/ fix up my code to be easily expanded on so that I can start adding "Content".

My question, does something like this exist?

variable_get_name() or maybe, reference_variable()

I am simply trying to store a variables "name" and its respective value into a script to use and reference throughout that script.

Something I have already thought of - place another variable in the step event to stay updated on the variable I am attempting to manipulate. But I feel like I might forget about it if I revisit this later down the road.

Thanks all!
 
M

mtski

Guest
Variable_instance_exists will probably work :). If anything I could update my current object specific variable to a default name to be referenced.

Thank you so much!
 

TheouAegis

Member
Personally I would create an enumerator for each of the general variable names. You would just save the enumerator to your variable so that you could pass the enumerated value to the script. Inside your script, have a switch with each case being the enumerated values. Yes switches are slow, but so is running the variable name string through a lookup table. The switch method I am almost certain would be significantly faster.

varianle_X_exists() functions were one of the features I was glad to see go between GM 8 and Studio 1, although I always suspected that the bloated feature which such functions require was still present in Studio, just harder to find.
 
Top