GameMaker Access Room Editor Creation Code of Instance

Like the title says, is there a way to access (i.e. run) an instance's room editor creation code? If I want to reset an object, I can do event_perform(ev_create, 0), but this does not take into account any code written in the room editor.

Thanks!
 

FoxyOfJungle

Kazan Games
This is not possible, and the creation event is always executed when starting the room, there is no way to call it again and even access it through an instance. What is possible is just modifying instance variables as far as I know.

There are other ways to reset an instance:
  • Destroying and creating it again;
  • Resetting variables to default
  • ...
Furthermore, objects are different from instances. Instances are copies of objects.
 
Last edited:
Basically my game is set up in a way where the player transitions between "rooms" where the boundaries of a room are defined by the bounding box of a room object instance. So the entire game world is inside one GM room resource. When an enemy is killed, it gets sent to its homeX and homeY coordinates (defined in the object creation code as homeX = x, etc.) and it is deactivated, only to be reactivated when you enter that "room" again -- which gives the illusion of predictable spawing depending on which "room" you enter. But say for example I have an enemy that can either move horizontally or vertically upon creation, and I want to set that using the instance creation code in the room editor, things just get a little funky when I deactivate then reactivate that object. I wish I could just put event_perform(ev_create, 0) and something immediately after it like event_perform(ev_instance_create, 0), but that doesn't exist.

Thanks for your help, I'll try to find a way to work around it.
 

Nidoking

Member
This sounds like the sort of thing you could set using Object Variables, which should then keep their values when you deactivate and reactivate the instance, but can still be set in the Room Editor.
 
This sounds like the sort of thing you could set using Object Variables, which should then keep their values when you deactivate and reactivate the instance, but can still be set in the Room Editor.
That's kind of what I have now. Basically my enemy states are all set up as numbers, so state -1 is when an enemy dies, and the enemy is sent to its home, deactivated, and switched to state 0 (which automatically switches to 1 when activated... state 1 and so on are where I handle the unique behaviors of each enemy). So a parent enemy handles states -1 and 0, but what it looks like I'll have to do is add additional state -1 code in child enemy objects (which for the most part will look similar to the object's original creation code).
 
Top