Wait Question ^_^ [SOLVED]

Hello 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!


No, 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.


Hm. 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?


You 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.


Ah, 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


You can, but it would be easier to use a string rather than a template. Templates are not much use outside of libraries.


Alrighty! 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!


What 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

Hahah, 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!


So whatcha think? :D


You 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)
  

Hm. 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?


Just put that function in the command, and it should work (you need both). Remember to put 10 as the parameter.


Error: 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?


Sorry, 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)

Thanks! It works great now. Appreciate all your time, Pix! :D Hopefully this might help some other people down the road.


This has inspired a new tutorial:
https://github.com/ThePix/quest/wiki/Enhanced-Waiting


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

Support

Forums