Wait while a loop/recursive function is running?

cm97878
If you need input in a loop, how would you go about making the loop wait until the input is received before re-looping if need be? I've seen the possibility of using a function, but I run into a similar issue there. For example:


msg("What is your name?")
setPlayerName
msg("Blah blah blah")

//And the function setPlayerName is as follows:
get input {
msg ("So, your name is " + result + "?")
ShowMenu ("", split ("yes;no", ";"), false) {
if (result = "yes") {
set (player, "alias", result)
}
else if (result = "no") {
msg ("It's not? Well, what is it, then?")
setPlayerName
}
}
}


Instead of waiting until setPlayerName is finished recursing, the next message will be printed immediately and everything will continue on. How can I make it wait until this has been set?

The Pixie
Kind of a cheat, but move this line:
msg("Blah blah blah")
... into the "Before entering the room for the first time" script of the room where the player starts.

cm97878
Ah, dang. I see how that would work, but this isn't taking place right at the start of the game, it's after a bit of an 'introduction' of sorts. The player is already a few rooms 'ahead.'

XanMag
What I did, which I think is similar to your problem is using the 'get input' then 'switch' to add your cases of 'yes' and 'no' then loop your no script case and advance to whatever comes next on your yes script. Add a default response that asks the question again.

Would that work? I've got an.aslx file I could attach I used for a computer simulation if you want to look at it.

HegemonKhan
Unfortunately, this is a big issue with quest, as anything that requires input and/or uses a popup, causes errors, as obviously you can't have multiple instances of them (inputs and/or popups) running at the same time. Quest just doesn't have such a method for handling this stuff, like most high level languages do. Best course of action is to try to develop a different design to completely not even deal with this issue. With quest, looping isn't handled very well. It was a quest design decision, if I remember right, as I think someone explained why it was so to me.

Pixie, I think, did find some way I think, but it was extremely complex and very roundabout (too much extra work/overhead).

------

there's also another (partial) way... using Commands to handle the input... but, this was a big "discovery" for me with my own attempt at creating a 'pedia' system (for character creation, and the rest of the aspects of a game), as I too was having the trouble of dealing with input and looping... which Jay helped hinted at for me, and which I'm now hinting at for you. But, I don't want to openly say how this is done yet. So, if you can use my hint, and "discover" this method on your own too, great. But, I don't want to openly share it yet, sorry XanMag (who was also needing help with this issue) and others. If others share it, that's their call, but I don't want to at the moment, myself. It's one of the first "code tricks" that I was helped (by Jay) at "own-discovering", so it has the feel of "intellectual property" to me, and so I don't want to share it just yet.

XanMag
I churned something up that seems to work alright. Below the code is the .aslx file for your perusal. I did not try to use a 'ShowMenu' but I imagine I could get it to work.

<!--Saved by Quest 5.6.5783.24153-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="Menu Loop Test">
<gameid>8b1d533d-3175-4c01-acf9-0c58d1e02c54</gameid>
<version>1.0</version>
<firstpublished>2016</firstpublished>
<pov type="object">player</pov>
<autodescription_youarein_newline />
</game>
<object name="room">
<inherit name="editor_room" />
<enter type="script">
</enter>
<firstenter type="script"><![CDATA[
msg ("An omnipotent Wizard stands before you.<b>\"What shall I call you?\"</b> he bellows.<br/>")
get input {
set (player, "alias", result)
msg ("<b>'So, you really want to be called... " + result + "?<br/><br/>'Once you state 'yes' it will be forever so. What say you? Is " + result + " really what you want printed in the annals of history?</b><br/>")
get input {
switch (LCase(result)) {
case ("yes","yea","y","yep","sure","affirmative") {
msg ("<b>\"Okay then,\"</b> the mighty Wizard proclaims!<br/\"")
msg ("<b>'You are hereby known around the world as " + GetDisplayAlias(player) + "! PLEASE DO NOT disappoint me!'<br/><br/>'Now go east and let your adventure begin!'</b>")
MakeExitVisible (exit1)
}
case ("no","nay","nope","n") {
msg ("<b>\"Ugh,\"</b> the Wizard utters in protest. <b>\"Did you make a typo or something? Please CORRECTLY state your name.</b>")
namefunction
}
default {
msg ("<b>\"I do not understand your response. You'll have to try English next time. Shall we do this again? <u>WHAT IS YOUR NAME?\"</u></b>")
namefunction
}
}
}
}
]]></firstenter>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
<usedefaultprefix type="boolean">false</usedefaultprefix>
</object>
<exit name="exit1" alias="east" to="room2">
<inherit name="eastdirection" />
<visible type="boolean">false</visible>
</exit>
<object name="Wizard">
<inherit name="editor_object" />
<look>He's omnipotent. It hurts your eyes to look at him. You avert your gaze.</look>
<speak type="script"><![CDATA[
msg ("<b>'My job is done here, " + GetDisplayName(player) + ". Go forth and adventure!'</b>")
]]></speak>
</object>
</object>
<object name="room2">
<inherit name="editor_room" />
<object name="Mr Name Checker">
<inherit name="editor_object" />
<alias>Mr. Name Checker</alias>
<look>Talk to him.</look>
<speak type="script">
msg ("Ah. You must be " + GetDisplayAlias(player) + "! Nice to meet you!")
</speak>
</object>
<exit alias="west" to="room">
<inherit name="westdirection" />
</exit>
</object>
<function name="namefunction"><![CDATA[
get input {
set (player, "alias", result)
msg ("<b><br/>'So, you really want to be called... " + result + "?<br/><br/>'Once you state 'yes' it will be forever so. What say you? Is " + result + " really what you want printed in the annals of history?</b><br/>")
get input {
switch (LCase(result)) {
case ("yes","yea","y","yep","sure","affirmative") {
msg ("<b>\"Okay then,\"</b> the mighty Wizard proclaims!<br/>")
msg ("<b>'You are hereby known around the world as " + GetDisplayAlias(player) + "! PLEASE DO NOT disappoint me!'<br/><br/>'Now go east and let your adventure begin!'</b>")
MakeExitVisible (exit1)
}
case ("no","nay","nope","n") {
msg ("<b>\"Ugh,\"</b> the Wizard utters in protest. <b>\"Are you serious? This isn't THAT difficult! Please <u>CORRECTLY</u> state your name NOW!</b>")
namefunction
}
default {
msg ("<b>\"I do not understand your response. You'll have to try English next time. Shall we do this again? <u>WHAT IS YOUR NAME?\"</u></b>")
namefunction
}
}
}
}
]]></function>
</asl>




btw, Quite proud of achieving this in as little time as I did WITHOUT asking for additional help! :D

Let me know if you need help or if it works for you. Good luck!

cm97878
Looks like I could certainly use this, and I'll keep the other things said in mind. Thanks everyone.

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

Support

Forums