• 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 Script can be called by room's Create Event, but not by persistent object?

Focksbot

Member
Hi. I have a simple script:

Code:
instance_create(room_width/2, room_height/2, obj_jamjar);
instance_create(room_width/2, room_height/2 + 200, obj_fingerbone);
audio_play_sound(bone_chime_2, 1, false);
If I tell the room's Create Event to call this script, it functions fine. If I use a persistent object to call it at the very moment the room changes, it will play the audio but NOT create any instances.

Any idea of the reason for this?
 

FrostyCat

Redemption Seeker
With the persistent object approach, it still created the instances you asked for, except they would be left behind if they were not also persistent. You should time it so that the instances are created after the room changes (i.e. the Room Start event), not before.
 

Focksbot

Member
With the persistent object approach, it still created the instances you asked for, except they would be left behind if they were not also persistent. You should time it so that the instances are created after the room changes (i.e. the Room Start event), not before.
When I check the order of events, my persistent object calls up the room change, then resets a timeline position, and only then calls the script to populate the room. So the order should be fine?

Code:
transitionOut = false;
room = changeTo;
obj_control.timeline_position = 0;
if !(runSetUp = noone) script_execute(runSetUp);
 

Focksbot

Member
However, on further inspection, changing those objects to 'Persistent' does solve the problem, so it must be the case that I can't populate a room in the same series of instructions as the room change.
 
Top