How to get the variable list that is accessible in room editor?

Hi guys,

In my game I am going through several rooms and copying instances from those rooms. Then I am kind of sticking together these instances to create a level. For this to work I need to copy some data from those instances and then recreate them in the new room.
Currently this copying works perfectly for position, scale, rotation, object type etc. but I want to expand my system to include the Variable Definitions aswell.

So my question is how to get the list of variables that can be accessed in the room editor and reference it in code?
1601174816634.png
I want to reference the names or the values from this specific list in code. I know about this: https://www.reddit.com/r/gamemaker/comments/70ny59 Which refers to these:
  • variable_instance_get_names(instance_id) - Returns an array of strings that contain all variable names for instance_id
  • variable_instance_get(instance_id, string) - Returns the value of the variable named string of instance_id
  • get_string(string, default) - Quick and dirty way to enter a string from the keyboard into GMS
  • string(variable) - Sets variable type to a string
  • real(variable) - Sets variable type to a real number
  • variable_instance_set(instance_id, variable_name, value) - Sets the variable named variable_name of instance_id to value
But I want to only reference and copy this specific variable definitions list. Is there an efficient way of doing this rather than getting all variables?
 

TailBit

Member
What you could check is if variable_instance_get_names(id) always start listing the user added variables at the same index, if that is so then you can skip the build-in ones right away, you might need to create a variable in the create event so that you can use as a marker to when to stop if you don't want the ones defined there.
 
What you could check is if variable_instance_get_names(id) always start listing the user added variables at the same index, if that is so then you can skip the build-in ones right away, you might need to create a variable in the create event so that you can use as a marker to when to stop if you don't want the ones defined there.
Tried this out but the variable I need is somewhere in the middle of the array.
I think what I will do is make sure I have consistent naming for in-editor variables and just reference those.
Something like this:
1601224725796.png
Though they now don't refer to what they actually do which is not ideal. But it will work.
 
Top