• 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!

Legacy GM Check if object has creation code

X

xxTheFryxx

Guest
I have an object and I need to check to see if it’s been given creation code, otherwise it sets a variable. How can I go about this?
 
H

Homunculus

Guest
The creation code is run after the create event, can't you just set the variable in the create event and overwrite it in the creation code instead?
 
X

xxTheFryxx

Guest
The creation code is run after the create event, can't you just set the variable in the create event and overwrite it in the creation code instead?
I tried this, but it seems the creation code runs before the create event.
 
H

Homunculus

Guest
The creation code is definitely run after the create event. If you find some variables are not the way they should be, there may be something else going on (like some code in the room start event or step that changes those values).
You can check the above by adding a show_debug_message in both events and look for the resulting order in the console, if you are unsure.

Can't really help you more than this without the actual code or more details.
 

TsukaYuriko

☄️
Forum Staff
Moderator
The creation code runs before the Create event in old versions - pre-Studio, if memory serves me right. Any version that's not 5 years old should run the creation code after the Create event.
 
X

xxTheFryxx

Guest
The creation code is definitely run after the create event. If you find some variables are not the way they should be, there may be something else going on (like some code in the room start event or step that changes those values).
You can check the above by adding a show_debug_message in both events and look for the resulting order in the console, if you are unsure.

Can't really help you more than this without the actual code or more details.
I’m running 1.4
 
X

xxTheFryxx

Guest
The creation code runs before the Create event in old versions - pre-Studio, if memory serves me right. Any version that's not 5 years old should run the creation code after the Create event.
It’s 1.4, I mean it would be very nice if the create event came after but on my version it sadly just doesn’t. Is there any workaround?
 

TsukaYuriko

☄️
Forum Staff
Moderator
It’s 1.4, I mean it would be very nice if the create event came after but on my version it sadly just doesn’t. Is there any workaround?
The manual said:
http://docs.yoyogames.com/source/dadiospice/001_advanced use/more about rooms/index.html
  • Creation Code: This option opens up a code editor where you can add code into the specific instance that you have clicked on. This is a very powerful feature that allows you to further change individual instances of objects and so give several instances different values or variables to change their behaviour. This code is run after the normal create event, but before the room start event (see Using GameMaker: Events for the complete order of events).
o_O

If this isn't working on your end, there might be a problem with how your project is set up. Please post all relevant code and how you're checking when which event runs, as there should be absolutely no way for the Create event to run after the creation code.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
For a workaround you could have a controller object call event_user() on all object types of interest and process variables there
 

TsukaYuriko

☄️
Forum Staff
Moderator
A workaround should not be necessary, though, as the event order of these two was changed specifically to accommodate for this exact situation - setting a variable in the Create event to a default value with the option to override in the instance creation code.
 
H

Homunculus

Guest
I can think of a few workarounds, but I’m always wary of workarounds for code that should not be broken to begin with, you may potentially end up treating the symptoms without addressing the cause
 
X

xxTheFryxx

Guest
Okay so I took a look. Thank you all for your info and help, I managed to get it working.
 
Top