Script running twice after entering a room
Marion34
16 Mar 2016, 18:51Hi ! I am programming a game with Quest and I really enjoy this software. But I have a little problem. Sometimes, I program a script in the "After entering the room" part, and the script runs twice in the game. For example, I write the text "This is a nice room" in "After entering the room", but when the player enters the room, instead of writing just
the game shows :
That's quite annoying when there is a long text written at this moment. How does this come from and how can I fix it ?
Thank you very much for your help
This is a nice room
the game shows :
This is a nice room.
This is a nice room.
That's quite annoying when there is a long text written at this moment. How does this come from and how can I fix it ?
Thank you very much for your help


XanMag
16 Mar 2016, 21:13Probably a dumb question on my part, but do you also have the same description written in the room description on the setup tab for the room AND also have the box ticked for automatically display room descriptions in the room description tab under the game object?

jaynabonne
16 Mar 2016, 22:37It would help if you could post your code or game, which experiences the problem. What you're describing shouldn't be happening, and yet it is.
So either it's something in your game or a bug in Quest. Either way, I just tried it, and it worked ok for me, so code that has the problem would be helpful.

Marion34
16 Mar 2016, 23:06I don't use the the room description, I only use the After entering room script. But yes the box for automatically display room descriptions in the room description tab under the game object is ticked... I will try again by unticking it. Thank you 

Marion34
16 Mar 2016, 23:27Still got the problem after unticking it. Here is the code of one room with the problem, but others have too. I have nothing on this room but the text when entering it :
<object name="Skaro">
<inherit name="editor_room" />
<usedefaultprefix type="boolean">false</usedefaultprefix>
<enter type="script">
msg ("Vous ĂȘtes sur Skaro.")
</enter>
</object>

jaynabonne
17 Mar 2016, 07:25The reason I wanted to see code (as in a full failing set of code) is to that often the problem isn't where you think it is. That's what makes it so hard to work out - it's something you did and forgot, or it's something obscure elsewhere in the code that you didn't realize would have that effect.
For example, does that string appear anywhere else in the code? Do you have turn scripts doing anything fancy (e.g. moving the player or other objects around)? Or any manner of other things? Viewing a single piece of code in isolation is often not helpful.
If you don't wish to post your game code, can you reproduce the problem in a smaller sample game? If not, then it might be useful to work out what's different between the two. If you can get something complete you can post, then post it!
(I also notice you have French in your msg. Are you using the French language library? If so, then perhaps there's a problem in there.)
For example, does that string appear anywhere else in the code? Do you have turn scripts doing anything fancy (e.g. moving the player or other objects around)? Or any manner of other things? Viewing a single piece of code in isolation is often not helpful.
If you don't wish to post your game code, can you reproduce the problem in a smaller sample game? If not, then it might be useful to work out what's different between the two. If you can get something complete you can post, then post it!
(I also notice you have French in your msg. Are you using the French language library? If so, then perhaps there's a problem in there.)
Marion34
17 Mar 2016, 08:43No, this is the only time this string appears in the all code. I have no turn script at all.
Yes I am using the French language library. I will try to make a very short game with a very few script, and see if there is the same problem.
Thank you for your help
Yes I am using the French language library. I will try to make a very short game with a very few script, and see if there is the same problem.
Thank you for your help

Marion34
17 Mar 2016, 10:06I made a test creating another game with the french library, I have ticked and unticked the same boxes in the two games. The texts appears once. It doesn't seem to have the same problem.
Maybe it's because I have made a long game with long strings... I can post the code here but it is really, really long :-/
Maybe it's because I have made a long game with long strings... I can post the code here but it is really, really long :-/
The Pixie
17 Mar 2016, 10:22If you click on Full Editor & Preview, you can then upload your game as an attachment.
Marion34
17 Mar 2016, 10:35I have changed something in the script in order to upload the game as an attachment, and it doesn't have the problem any more.
I think it's something related to the "After entering the room the first time" script, because I just added a simple condition for the script to run the first time the player enters the room, and the double string thing stopped when entering the next room (when it did that before). That's strange...
I think it's something related to the "After entering the room the first time" script, because I just added a simple condition for the script to run the first time the player enters the room, and the double string thing stopped when entering the next room (when it did that before). That's strange...

XanMag
01 Apr 2016, 04:40I have a room a player gets moved into frequently after "retreating" from other rooms.
I was getting the double room description as well.
I switched the room description to print only once using the 'First time' script and left the otherwise blank.
The game functions just fine, but now I am getting two room titles printed when being "thrown" back into this room. It's just ugly. Any ideas to fix? Thanks!
I was getting the double room description as well.
I switched the room description to print only once using the 'First time' script and left the otherwise blank.
The game functions just fine, but now I am getting two room titles printed when being "thrown" back into this room. It's just ugly. Any ideas to fix? Thanks!
The Pixie
01 Apr 2016, 06:40My first guess is that you are moving the player to the room twice, and each time Quest prints the room name and description. Can you paste the "retreating" script into a post? Also, the entire code, XML and all, for the room, could be useful.

XanMag
01 Apr 2016, 07:36Here is code that returns the player to the 'forest room'.
And here is the code for the forest room description.
Below is the entire .aslx file.
<beforefirstenter type="script"><![CDATA[
msg ("You take a peek into the bar,<br/>and your eyes do not stray far<br/>before you see an awful sight<br/>drunks and thugs prepared to fight.<br/><br/>Do you wish to walk on through,<br/>or do you want a plan perused?<br/>Going in without a plan<br/>may equate to one dead man.<br/><br/>It is your choice. It is your day.<br/>Yes or no, what do you say?")
get input {
switch (LCase(result)) {
case ("yes","yea","yep","y") {
msg ("You step inside the rough saloon.<br/>The patrons glare at the new bafoon.<br/>They whisper in such soft mumbles,<br/>Their voices rise, a million bumbles.<br/><br/>You continue on like you have a pair,<br/>but there's anxiousness up in the air. <br/>You grab a seat upon a stool,<br/>you're near the bar. Let's see it fool. ")
MoveObject (player, saloon)
}
case ("no","nope","nay","n") {
msg ("Wise to plan before you jump<br/>into a bar where you're the chump.<br/>Come back when you're good and able,<br/>and saunter up and grab a table.")
MoveObject (player, forest room)
}
}
}
And here is the code for the forest room description.
<object name="forest room">
<inherit name="editor_room" />
<description type="script"><![CDATA[
firsttime {
msg ("This is a room shrouded in trees.<br/>There are three directions, if you please.<br/><br/>Go north if you do not scare<br/>into a cave, the home of bear.<br/><br/>Or do go west if you so choose<br/>into the land that's filled with booze.<br/><br/>Or maybe east is what is sought,<br/>the lands of dragons to be fought!")
}
It is a first time description with a blank otherwise. For now I figured printing the room name twice is better than the entire description. The player has another room that is set up identically to this one (the 'saloon'). Same thing happens.Below is the entire .aslx file.
The Pixie
01 Apr 2016, 11:33Generally when you go in a room this happens:
What you are doing is moving the player in that first step. And that then triggers those three steps as well.
So ShowRoomDescription is run twice, once for entering the saloon, and once for entering the forest, but in reverse order, and the function itself just describes the current room, whatever it is, so the ShowRoomDescription for entering the saloon gives the description for the forest instead. Does that make sense?
To fix it, the best way is probably to have the script on the exit going to the saloon, rather than the saloon itself.
The before enter script is run
ShowRoomDescription is run
The after enter script is run
What you are doing is moving the player in that first step. And that then triggers those three steps as well.
The before enter script is run, player is moved
The before enter script is run
ShowRoomDescription is run
The after enter script is run
ShowRoomDescription is run
The after enter script is run
So ShowRoomDescription is run twice, once for entering the saloon, and once for entering the forest, but in reverse order, and the function itself just describes the current room, whatever it is, so the ShowRoomDescription for entering the saloon gives the description for the forest instead. Does that make sense?
To fix it, the best way is probably to have the script on the exit going to the saloon, rather than the saloon itself.