Hi,
As part of my game, I want there to be several chapter or parts, which the adventurer will have to complete.
The game moves the player to a new room, once certain conditions have been met, the screen goes blank, and Part 2, or Part 3, is then displayed, along with the title of that segment of the game, the screen clears again and puts the player in the new room to start the next section.
I've got the code running in the before entering room script
HidePanes
ShowPanes ("wait", room1)
And then the ShowPanes function is as follows
<function name="ShowPanes" parameters="con, newroom"><![CDATA[
if (con = "keypress") {
msg ("<br><br>{c:{b:{size:12:Press any key to continue}}}")
wait {
ClearScreen
request (Show, "Panes")
request (Show, "Location")
request (Show, "Command")
game.autodescription_youarein = 1
MoveObject (player, newroom)
}
}
else if (con = "wait") {
msg ("<br><br>{c:{b:{size:12:Please Wait. . .}}}")
SetTimeout (5) {
ClearScreen
request (Show, "Panes")
request (Show, "Location")
request (Show, "Command")
game.autodescription_youarein = 1
MoveObject (player, newroom)
}
}
]]></function>
As you can see it takes two parameters,
con which is either "keypress" or "wait"
and newroom which is the room the player moves to, to start the next section of the adventure.
For some reason, and there is probably a very simple solution, which I'm not seeing, the game is throwing an error message when I'm trying to move the player.
Any help is greatly appreciated or any thoughts.
(Oh, ignore {c: and {size:12:, these are custom text commands that centre the text and increase the font size)
Hello.
I bet it's the wait
and the SetTimeout()
I'm guessing neither of them have the newroom
variable defined.
What is your error message?
Regardless of the error message, try this:
<function name="ShowPanes" parameters="con, newroom"><![CDATA[
game.temp_newroom = newroom
if (con = "keypress") {
msg ("<br><br>{c:{b:{size:12:Press any key to continue}}}")
wait {
ClearScreen
request (Show, "Panes")
request (Show, "Location")
request (Show, "Command")
game.autodescription_youarein = 1
MoveObject (player, game.temp_newroom)
game.temp_newroom = null
}
}
else if (con = "wait") {
msg ("<br><br>{c:{b:{size:12:Please Wait. . .}}}")
SetTimeout (5) {
ClearScreen
request (Show, "Panes")
request (Show, "Location")
request (Show, "Command")
game.autodescription_youarein = 1
MoveObject (player, game.temp_newroom)
game.temp_newroom = null
}
}
]]></function>
https://docs.textadventures.co.uk/quest/functions/corelibrary/settimeout.html
Note: This function is “non-blocking”, and its script has no access to local variables.
Edit
I'm not sure if the wait
script needs that change, but it should work this way regardless.
Always a pleasure, good sir.
(Plus, it seems wise to stay on good terms with folks who have red dragons.)