Regular scripting command doesn't work in dialogs

Started by Pouyan, Mon 10/02/2025 19:47:13

Previous topic - Next topic

Pouyan

Hello,
This is my first time posting here.
Sorry if my question is stupid/already answered in forums or is in manual.
But I couldn't find my answer anywhere so I gave up and came to ask here.

I want to do this:
My character changes room and in the new room my character isn't visible and the dialog options are displayed after the fade in.
When the player chooses the option number one the room changes again to another room.

in dialog scripts i wrote this:
Code: ags
@1
 player.ChangeRoom(1);

But when i choose option number one in game, nothing happens.
What's the problem?

Kara Jo Kalinowski

I'm not really sure what you are trying to do. What's the complete relevant script here? That command works fine for me inside the dialog.

Rik_Vargard

#2
Did you change "return" to "stop" ? Just an idea I'm not sure this is the solution...

Khris

A room change doesn't happen immediately, it gets scheduled until the game is in an idle state again.
To switch rooms "during" a dialog, you need to
1. end the dialog right after the room change command (using "stop")
2. start the dialog again in the new room's "after fadein" event.

As for changing to a different room each time, you can use "player.Room" to read the number of the current room and do something like
  player.ChangeRoom(player.Room + 1);

heltenjon

Alternatively, depending on what you wish to achieve, you may make some screen-sized objects that you turn visible or invisible, creating the illusion of changing rooms. (I did that in Prep Time, where the entire game takes place inside a dialog.)

Eon_Star

Hi,

Khris' comment is very close to the solution. You should add a command in the new rooms "after fadein" function.

Like: "dDialog1.Start"

So the dialog can go on. You might create a second dialog according to the events of the new room (dDialogNew) and start that one. Just follow the coding logic.

Happy coding.

 :-D

SMF spam blocked by CleanTalk