Double Lines of Description When Changing the Player Object(SOLVED)

For some reason, whenever I try to move the player object, quest will print the description of the room twice. This also happens when I change the player object. I was just wondering if there is any way to fix this.


I had that issue before and got it fixed. I’ll dig through my code and try and find out why that happens and what I did to fix it. Until then...

Happy gaming!


Are you moving the player object twice? For example moving the player again within an enter or exit script; this can cause duplicate descriptions because the second move triggers another one before the first move finishes.


I don't believe that that is it @mrangel. I thought that was the problem at first also but I have tested it and found out that it is not.


Can you share the game so we can take a look at it?

What happens if you turn off automatically printing the room description? Does that make it appear once (in which case I'd assume you're manually calling ShowRoomDescription somewhere), or not at all?


@mrangel
Since the game is not yet finished, I'll message it to you privately.
I turned off "Automatically generate room descriptions" and then called the ShowRoomDescription function under "Script when entering a room". The room description was not printed.


I turned off "Automatically generate room descriptions" and then called the ShowRoomDescription function under "Script when entering a room"

I can't understand why you would do that.

I would expect that to show the room description twice, but skip the room name, "You can see:", "You can go:" and all the other automatically-generated stuff.


OK, I see your issue.

When you enter a room or change characters, Quest does the following:

  1. Run exit scripts for the room you just left (if any)
  2. Run "before enter" scripts for room you are now in
  3. show the description for the room you are now in
  4. Run "on enter" scripts for the room you are in

So at the start, it does this for the first room

  1. Run exit scripts
  2. Run "before enter" script for creation room
    • which runs character creation functions
      • which changes the POV to player1
        • which runs the enter room sequence for the new POV's room
          1. Run exit scripts
          2. Run before enter scripts for current room (hut)
          3. Display description for current room (hut)
          4. Run on enter scripts for hut ("You hear screaming ...")
  3. Display description for current room (hut)
  4. Run on enter scripts for hut

It's displaying twice because you're still in the middle of the "enter room" process for the creation room, and it will finish even if you're no longer in that room.

The easiest way to change

ChangePOV (player1)

to

game.pov = player1

This doesn't automatically call OnEnterRoom after switching POV, but still does the other initialisation stuff. So the sequence becomes:

  1. Run exit scripts
  2. Run "before enter" script for creation room
    • which runs character creation functions
      • which changes the POV to player1 without running room entry
  3. Display description for current room (hut)
  4. Run on enter scripts for hut ("You hear screaming ...")

Hope that makes sense… I tried to explain why it's doing that rather than just giving a solution, because if you know why the problem occurs, you can avoid similar issues in future.

(Note: if you use this method later in the game when changing characters, you may have problems with the map. ChangePOV basically does 3 things: changes the value of game.pov, clears the map, and shows the room description. If the map had already been drawn you would also need to include the lines:

JS.Grid_ClearAllLayers ()
Grid_Redraw

or it might be easier if you avoid moving the player or changing POV from within a room enter/exit script)


Thanks a lot, the problem is completely solved and I feel like I understand what happened and will not make that mistake again.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums