My Alarm Code is Not Working Properly

aisdjioad

Member
I'm just trying a simple thing: Once the game starts, the object.Transition will play a sound effect and then the room changes with alarm[0] = 1.2*room_speed.

BUT, once i start the game, the object plays the audio, then plays it AGAIN (1.2*room_speed later) instead of changing the room, and only then it changes the room...
ALSO, when the object plays the audio for the second time, my player's x and y changes to the initial value...

Heres the code from the oTransition:

Create Event:

audio_play_sound(sfxBattleEncounter, 500, false);
alarm[0] = 1.2*room_speed;

Alarm[0]:

room_goto_next()

Why is this not working?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Try clearing the cache before going any further. :) When something so seemingly simple starts acting weird, that should be the first thing to do (it's the "broom" icon at the top of the IDE). A stale cache can cause all sorts of strange behaviours... Also, how are you creating the object? Is it placed in the room? Or are you doing it through code?
 

Nidoking

Member
Is it possible that you have two identical rooms? Maybe you're going to another copy of the same room, where another instance of Transition activates.
 
Is it possible that you have two identical rooms? Maybe you're going to another copy of the same room, where another instance of Transition activates.
This is what I am thinking too, maybe instead of room_next do room_goto(room you want to go to) and see if that makes a difference
 

aisdjioad

Member
Try clearing the cache before going any further. :) When something so seemingly simple starts acting weird, that should be the first thing to do (it's the "broom" icon at the top of the IDE). A stale cache can cause all sorts of strange behaviours... Also, how are you creating the object? Is it placed in the room? Or are you doing it through code?
I was just placing it in the room for testing it. Now ive just tried to crate it through the o.player's keypressed event.
when i try it first time since the game is started, the o.player just return to its first coordinates. but then, when try for the second time after this, it works... its just not working for the first time (?). (already did the cache stuff)

Is it possible that you have two identical rooms? Maybe you're going to another copy of the same room, where another instance of Transition activates.
idts :/
im using room_goto(room) now, and its still not working. please read my reply to Nocture :)

This is what I am thinking too, maybe instead of room_next do room_goto(room you want to go to) and see if that makes a difference
Did it and still not working :/. Please read my reply to Nocture, i updated the new problems.
 

chamaeleon

Member
Put show_debug_message() statement in all relevant events to display what event runs when, and how often, and for what instance. Since you say you have a sound playing twice when you expect it to play once, it would make sense to have such a statement right before the playing of the sound for instance.
 

Gamebot

Member
Being persistent will mean it runs in every single room.
Starting with the room you first place it. This should be OFF.
Just wanted to make sure it wasn't a quick solution.

I would do what @chamaeleon suggested.
 
Top