I'm trying to send the player back to a "mainMenu" room after death. Upon entering the "dead" state, I present a dialog with the say command, and then navigate the user to the "mainMenu" after they dismiss the dialog.
The issue I'm running into is that the dialog persists, so after entering the "mainMenu" room as expected, the say dialog is presented again and every time I dismiss it, it pops back up. Is there some other code required to formally dismiss that dialog?
// look for dead player
if playerState=="dead" then
if event.room=="playRoom" then
ignore
shake 2 then
say "You pulled my finger...and lost."
goto 0,0 in "mainMenu"
end
end
end
Hi @scarboy, appreciate the response. Either approach is allowed according to the documentation, and I actually tried it your suggested way first. Both result in the same outcome - the dialog persists across rooms.
// look for dead player
if playerState=="dead" then
if event.room=="playRoom" then
ignore
shake 2 then
say "You pulled my finger...and lost." then
goto 0,0 in "mainMenu"
end
end
end
end
Do you have that logic inside the any event? I tried and was able to recreate it that way. I think what's happening is the event gets trigged a bunch of times while the shake is happening, causing the say prompt to get triggered many times. I was able to fix it like this:
on any do
// look for dead player
if playerState=="dead" then
if event.room=="playRoom" then
log "{playerState} {event.room}"
ignore
playerState = "not_dead"
shake 2 then
say "You pulled my finger...and lost." then
goto 0,0 in "mainMenu"
listen
end
end
end
end
end
on confirm do
log "confirmed"
playerState = "dead"
end
If that's not what you're doing let me know and I can check it out.
Thank you all for the debug support. I think the issue had to do with calling the dialog from the main game loop event. I moved it into the room's any event, and then changed the order of my state calls. It's working as expected now, though I still suspect there might be a bug somewhere.
on any do
if playerState=="dead" then
say "You pulled my finger...and lost." then
playerState = "static"
goto 0,0 in "mainMenu"
end
end
end
I would not recommend adding arbitrary behavior to the any event handler. That catch-all event is really only meant to be used to call mimic "anotherTile”.
Instead of checking if the player is dead in an arbitrary event, I would suggest calling the game over logic where you’re currently setting playerState to “dead”. If you’re setting that state in multiple places I would recommend moving it to a custom event handler on the player like:
on die do
playerState="dead"
ignore
say "You pulled my finger...and lost." then
playerState = "static"
listen
goto 0,0 in "mainMenu"
end
end
Thanks again @shaun. Great suggestion. moved my player death event to the player script and rewired the state change commands. Everything working as expected.