Wait Question ^_^ [SOLVED]

Anonynn
07 Dec 2016, 18:58Hello everyone!
I just had a query about "Wait". Here is the original script.
msg (Template("DefaultWait"))
I was wondering if it was possible to make this an "if script" and have the player be able to type in things like..."wait 10" and have it produce the script 10 times. Or something like that. For example...
if (game.wait=("DefaultWait")) {
msg (Template("DefaultWait"))
}
else if (game.wait=10) {
msg (Template("DefaultWait + 10" ))
}
And so on.
Thanks in advance!
The Pixie
07 Dec 2016, 19:49No, but that is a good thing. Create a new command with this pattern:
wait 10;z 10
... or keep it general:
wait #text#;z #text#
The original command will handle WAIT, your new command will handle WAIT 10, o no need for the if script.

Anonynn
08 Dec 2016, 04:38Hm. I think I am missing something...
I made a command: wait 10
put this in the pattern line: wait 10;z 10
and name: wait 10
And when I type "wait 10" in the game, nothing happens.
I was hoping to have the player be able to wait 5, 10 or 15 turns and have the wait message print once for each thing, but if needed I would be okay with the message printing 5, 10, 15 times. Unless it would be easier to just use wait 10 and that's it. Whatever is easier.
I also have some messages on the Template(DefaultWait) --- would the other scripts be able to utilize those?
The Pixie
08 Dec 2016, 08:26You should see this:
> wait
Time passes.
> wait 10
> wait 20
I don't understand your command.
The first is the default command. The second is the new command, which so far does nothing. The third has no command, so triggers the error response.

Anonynn
08 Dec 2016, 19:16Ah, okay! That is what I see. Great! So I can create a Template that reads off some {random:} and connect it to the wait 10 with...
msg (Template("Wait 10" )) ?
Thanks so much, Pix! You're the best :D
The Pixie
08 Dec 2016, 22:17You can, but it would be easier to use a string rather than a template. Templates are not much use outside of libraries.

Anonynn
09 Dec 2016, 06:46Alrighty! I have the command set up with the wait 10;z 10 pattern, the script use message ready. What is the next step I would need to program to get the "wait" part of it to work?
^wait$|^z$
^----- original wait command pattern.
Appreciate the help so far btw too!
The Pixie
09 Dec 2016, 08:14What are you ultimately wanting to do here? Having the "Time passes" message appear 10 times seems kind of pointless. Will you be wanting the turn scripts to all trigger 10 times as well? If so, will you want it to possibly stop if something significant happens (like a hoard of orcs appears after the third one)?
The original wait uses a Regex, and that is equivalent to:
wait;z

Anonynn
09 Dec 2016, 18:07Hahah, the message doesn't have to appear 10 times-just once would be preferable.
But yes, the idea I had was to trigger 10 waits/10 turn-scripts and so on. It doesn't have to stop when something significant happens, but if it does, that would be even better.
:P
Thank you so much so far for helping Pix!

Anonynn
10 Dec 2016, 17:07So whatcha think? :D
The Pixie
10 Dec 2016, 18:52You could have a flag on the game object, say stop_waiting
and any time something important happens in a turn script, it sets that to true. Do it all inside a function (because then you can break out of the loop) that returns a boolean. Give it a parameter, n, the number of turns.
game.stop_waiting
for (i, 1, n) {
RunTurnScripts
if (game.stop_waiting) {
return (true)
}
}
return (false)

Anonynn
10 Dec 2016, 22:16Hm. On second thought maybe keeping it simple for now would be better lol. So I guess just triggering 10 waits/10 turn-scripts with one message would be the best solution. I'll keep what you mentioned above for later :)
So does the command already work or is there another step?
The Pixie
10 Dec 2016, 22:39Just put that function in the command, and it should work (you need both). Remember to put 10 as the parameter.

Anonynn
10 Dec 2016, 23:50Error: Error adding script attribute 'script' to element 'wait 10': Function not found: 'game.stop_waiting'
This is what I have :)
wait 10 command
command pattern: wait 10;z 10
script:
game.stop_waiting
for (i, 1, n) {
RunTurnScripts
if (game.stop_waiting) {
return (true)
}
}
return (false)
msg ("{random:You wait for a while:Time passes:You stand around thinking for a while:You pass the time by letting your mind aimlessly wander:You get distracted and time passes:You space out for a while:You space out and get lost in your thoughts:You let your mind wander for a while}")
game.stop_waiting attribute boolean
Function: stop_waiting
Return Type: Boolean
Parameter: n
Script:
game.stop_waiting
for (i, 1, n) {
RunTurnScripts
if (game.stop_waiting) {
return (true)
}
}
return (false)
Where did I screw it up xD?
The Pixie
11 Dec 2016, 10:20Sorry, my bad. First line wrong. Also, as written it will do one turn more than it should. Change the first two lines like this:
game.stop_waiting = false
for (i, 1, n-1) {
The script in your command (given you called the function stop_waiting
will be:
stop_waiting(10)

Anonynn
11 Dec 2016, 18:23Thanks! It works great now. Appreciate all your time, Pix! :D Hopefully this might help some other people down the road.
The Pixie
12 Dec 2016, 09:43This has inspired a new tutorial:
https://github.com/ThePix/quest/wiki/Enhanced-Waiting