Trouble with wait script
miepmiep
27 Oct 2014, 08:51Hi there,
I have "finished" (sort of) writing an educational game on statitistics in dutch for my students, and I'm testing it now.
One of my testers gets 'only one wait can be in progress' errors while playing. We didn't record her game and I am not able to reproduce it, so I can't produce a walkthrough that shows this problem.
I think it happens because I use some turn time scripts, with waits in it, that probably just showed up while she was in another wait. Is this possible?
And, am I correct that a turnscript does not interrupt while inside a function? Because then, this would probably solve my problem.
I hope my question is understandable!
Thanks in advance.
I have "finished" (sort of) writing an educational game on statitistics in dutch for my students, and I'm testing it now.
One of my testers gets 'only one wait can be in progress' errors while playing. We didn't record her game and I am not able to reproduce it, so I can't produce a walkthrough that shows this problem.
I think it happens because I use some turn time scripts, with waits in it, that probably just showed up while she was in another wait. Is this possible?
And, am I correct that a turnscript does not interrupt while inside a function? Because then, this would probably solve my problem.
I hope my question is understandable!
Thanks in advance.

jaynabonne
27 Oct 2014, 10:28Were these being run online or via the desktop version? If online, would it be possible to get the link? 
Something is definitely invoking a wait while another wait is active. It's hard to tell without seeing some code to know how for sure how that's happening.
As far as the turn script question goes, I'd probably say no, but I'm not sure what you're asking. (Which function are you referring to in your question and/or how would it solve your problem?)

Something is definitely invoking a wait while another wait is active. It's hard to tell without seeing some code to know how for sure how that's happening.
As far as the turn script question goes, I'd probably say no, but I'm not sure what you're asking. (Which function are you referring to in your question and/or how would it solve your problem?)
miepmiep
27 Oct 2014, 16:57It was written offline, runs online, but it is in Dutch, so it would be hard for you to walk through the game without being extremely bored (assuming you don't speak dutch). Ofcourse I can give you the link (http://play.textadventures.co.uk/Play.aspx?id=ds6sgjtxpkingoq63byz3a), or (possibly better) attach the gamefile, so you could look at the code. That would be great!
However, what I meant with the function remark, was that it seems to me that if I use "SetTurnTimeout" on, like, 15, and I count the turns while playing, it doesn't interrupt while I'm in some kind of function that I wrote myself (something with 'get input's and looping on itself when the answer is wrong).
I have some scripts that work with SetTurnTimeout that start counting after the player for example has entered a certain room, or even follow up another SetTurnTimeout. They obviously showed up just when the player was "waiting" for something else and created an error. However, I don't seem to be able to get the same error, and it looks like my functions aren't interrupted. So, if I only use "waits" in my functions, that would solve my problem. Does that make any sense?
The error happened around the "ijzeren deur" "bronzen deur" and "gouden deur" and the script that caused the problem was probably invoked by entering "vergaderruimte".
I hope this makes some sense to you
However, what I meant with the function remark, was that it seems to me that if I use "SetTurnTimeout" on, like, 15, and I count the turns while playing, it doesn't interrupt while I'm in some kind of function that I wrote myself (something with 'get input's and looping on itself when the answer is wrong).
I have some scripts that work with SetTurnTimeout that start counting after the player for example has entered a certain room, or even follow up another SetTurnTimeout. They obviously showed up just when the player was "waiting" for something else and created an error. However, I don't seem to be able to get the same error, and it looks like my functions aren't interrupted. So, if I only use "waits" in my functions, that would solve my problem. Does that make any sense?
The error happened around the "ijzeren deur" "bronzen deur" and "gouden deur" and the script that caused the problem was probably invoked by entering "vergaderruimte".
I hope this makes some sense to you

miepmiep
27 Oct 2014, 20:29I think I solved it.
I just removed all the "waits" out of all the scripts that were started by a "SetTurnTimeout" command, and replaced them with SetTimeouts. Additionally I copied he HandleCommand command and added a line to it that makes sure that if a player has a 'freeze' flag, it does nothing at all, like you suggested in another post. That works pretty well, I think.
It's a small problem that walkthroughs can't handle the SetTimeouts very well, but that's not a problem in the game, so that's fine.
I just removed all the "waits" out of all the scripts that were started by a "SetTurnTimeout" command, and replaced them with SetTimeouts. Additionally I copied he HandleCommand command and added a line to it that makes sure that if a player has a 'freeze' flag, it does nothing at all, like you suggested in another post. That works pretty well, I think.
It's a small problem that walkthroughs can't handle the SetTimeouts very well, but that's not a problem in the game, so that's fine.

jaynabonne
27 Oct 2014, 20:40I managed to reproduce the problem (as far as I can tell) in a reduced case. See the attached. (I see now that you solved it, but here is more info anyway.)
The problem occurs if two different turn timeouts have waits and they both hit at the same time. In the sample, command "t1" has a turn timeout of 3, and "t2" has a turn timeout of 2. So if you execute t1 and then t2, they are both primed to go off on the next command. Typing some command at that point (e.g. "l") will trigger them both, they both try to execute "wait", and you get the problem.
It could be considered a bug in how Quest handles such things, but I don't really know what it could do instead. It has no idea that different turn timeouts will be executing waits simultaneously - and once you execute wait, something has to happen.
I see that you solved it, so that's good.
The problem occurs if two different turn timeouts have waits and they both hit at the same time. In the sample, command "t1" has a turn timeout of 3, and "t2" has a turn timeout of 2. So if you execute t1 and then t2, they are both primed to go off on the next command. Typing some command at that point (e.g. "l") will trigger them both, they both try to execute "wait", and you get the problem.
It could be considered a bug in how Quest handles such things, but I don't really know what it could do instead. It has no idea that different turn timeouts will be executing waits simultaneously - and once you execute wait, something has to happen.
I see that you solved it, so that's good.

miepmiep
27 Oct 2014, 21:18That is indeed what must have happened.
I wouldn't know how to solve this in Quest either, but at least I've learned that, when using multiple turn timeouts it is not a good idea to put "waits" inside of them
Thanks for your help!
I wouldn't know how to solve this in Quest either, but at least I've learned that, when using multiple turn timeouts it is not a good idea to put "waits" inside of them

Thanks for your help!
HegemonKhan
28 Oct 2014, 05:35I'm having a bit of trouble myself (being still a noobie with coding) with scripts' Order Structure, as I try to do too organized but complex usage of Functions, laughs.
the problem with scripts:
Script 1
|....\
|.... Script 2
|
Script 3
|....\
|.... Script 4
|
Script 5
Script 2 and Script 3 (and also: Script 4 and Script 5, and maybe too: Script 2 and Script 4) can run at the same time (which can be problematic in of itself), so if they both use a 'wait' or 'on ready' or 'get input' or 'show menu', then you get a quest error, as computers~coding can't do two same things at once.
I've found that 'on ready' (using it for Script 3), doesn't wait for (Script 2) to finish, it only waits for (Script 1) to finish, thus my encountered errors of Script 2 and Script 3 (or is it Script 4, meh) conflicting with each other, argh!
it's order structure is actually this from my experimentations~scenarios, in my own code work, lol:
Script 1
|....\
|.... Script 2
|
Script 2
|....\
|.... Script 3
|
Script 3
--------------
the only safe way is to have it error-free is a 'single contiguous chain' :
Script 1
........\
........ Script 2
..................\
..................Script 3
...........................\
............................Script 4
-------------
I haven't worked with Return Value Functions... so I don't know if this takes order priority, before another script runs (which would prevent any errors), nor have I worked with Script Dictionaries in this 'testing scenario of mine (self discovery, lol)' of the order structure of scripts.
the problem with scripts:
Script 1
|....\
|.... Script 2
|
Script 3
|....\
|.... Script 4
|
Script 5
Script 2 and Script 3 (and also: Script 4 and Script 5, and maybe too: Script 2 and Script 4) can run at the same time (which can be problematic in of itself), so if they both use a 'wait' or 'on ready' or 'get input' or 'show menu', then you get a quest error, as computers~coding can't do two same things at once.
I've found that 'on ready' (using it for Script 3), doesn't wait for (Script 2) to finish, it only waits for (Script 1) to finish, thus my encountered errors of Script 2 and Script 3 (or is it Script 4, meh) conflicting with each other, argh!
it's order structure is actually this from my experimentations~scenarios, in my own code work, lol:
Script 1
|....\
|.... Script 2
|
Script 2
|....\
|.... Script 3
|
Script 3
--------------
the only safe way is to have it error-free is a 'single contiguous chain' :
Script 1
........\
........ Script 2
..................\
..................Script 3
...........................\
............................Script 4
-------------
I haven't worked with Return Value Functions... so I don't know if this takes order priority, before another script runs (which would prevent any errors), nor have I worked with Script Dictionaries in this 'testing scenario of mine (self discovery, lol)' of the order structure of scripts.
miepmiep
28 Oct 2014, 18:50I'm actually not sure whether you are asking another question, or replying to mine 

Silver
28 Oct 2014, 20:38He thinks out loud.

Avantar
29 Oct 2014, 08:38@miepmiep
I have played your game and I am not sure how far you are with it, but so far I enjoyed it a lot. Descriptions for the lamp, table, bed...You could even lift up stuff. I guess the rabbit hole was like a worm hole? Like the fact that I had a backpack too. It is evident that a lot of work already went into it.
So I was following the dim lit hall all the way in the starboard direction, got locked in and ultimately shoved into outer space. Seems like a timer kicks in for you to read the conclusion of your death and then the game restarts which is actually very cool - but I am a slow reader and did not finish reading about my demise.
(Is it possible to use a 'Wait' command instead?)
I will be eager to play this title when finished....
Just putting it out there - 'Wel gedaan!'
I have played your game and I am not sure how far you are with it, but so far I enjoyed it a lot. Descriptions for the lamp, table, bed...You could even lift up stuff. I guess the rabbit hole was like a worm hole? Like the fact that I had a backpack too. It is evident that a lot of work already went into it.
So I was following the dim lit hall all the way in the starboard direction, got locked in and ultimately shoved into outer space. Seems like a timer kicks in for you to read the conclusion of your death and then the game restarts which is actually very cool - but I am a slow reader and did not finish reading about my demise.

I will be eager to play this title when finished....
Just putting it out there - 'Wel gedaan!'
miepmiep
29 Oct 2014, 09:07@Avantar,
Thanks for your nice words and especially your feedback. Really, really very welcome.
It is funny you mention the "wait scripts" because I just took them out, because they caused other problems (as described in this thread). However, probably not in the part you're talking about. So I could make the timertime longer, or indeed put back in the waits.
Any other feedback will be greatly appreciated
Thanks for your nice words and especially your feedback. Really, really very welcome.
It is funny you mention the "wait scripts" because I just took them out, because they caused other problems (as described in this thread). However, probably not in the part you're talking about. So I could make the timertime longer, or indeed put back in the waits.
Any other feedback will be greatly appreciated


Avantar
29 Oct 2014, 10:23Probably not the correct place to give feedback on the game, but I am happy to do so when time permits and always a pleasure doing so on something well done.
I often ran into the 'Wait' command problem and I guess what HK also tried to explain in his reply is that you can have the wait commands nested to eliminate the error in most cases. I guess in your case it was a little bit more unique.
Apart from entering your name in the beginning I am not sure what other input you would need from your players. If clicking on objects in the Inventory/Places panes and/or clicking on the links in the text body is all you need to progress, then you may want to consider just getting rid of the command prompt after asking for the player's name.
This will make the task lighter of having descriptions of descriptions in each room and players typing in any old thing in the command prompt and getting a not so clever response. Like 'kick the table' or something to that effect. It will also make it clear as to what you can/cannot do.
(This is just a preference and certainly not a must)
I am certainly going that route for my next game.
That is all the feedback I have for now until I play some more.
I see it is almost finished. Good luck in completing it.

I often ran into the 'Wait' command problem and I guess what HK also tried to explain in his reply is that you can have the wait commands nested to eliminate the error in most cases. I guess in your case it was a little bit more unique.

Apart from entering your name in the beginning I am not sure what other input you would need from your players. If clicking on objects in the Inventory/Places panes and/or clicking on the links in the text body is all you need to progress, then you may want to consider just getting rid of the command prompt after asking for the player's name.
This will make the task lighter of having descriptions of descriptions in each room and players typing in any old thing in the command prompt and getting a not so clever response. Like 'kick the table' or something to that effect. It will also make it clear as to what you can/cannot do.
(This is just a preference and certainly not a must)
I am certainly going that route for my next game.

That is all the feedback I have for now until I play some more.
I see it is almost finished. Good luck in completing it.

jaynabonne
29 Oct 2014, 14:59Just avoid waits in SetTurnTimeout, especially if you have more than one in effect at once. You should be fine to use them anywhere else! 
