Quest Problem with "Get Input" in a loop

0 votes
50 views
asked Sep 17 in Authoring by DavyB

Hi,
I'm in the process of learning Quest so this may have a simple answer:

The following (on entry to room) script

running = true
while (running) {
msg ("Type non-integer to finish")
get input {
running = IsInt(result)
}
}

gives the following:

You are in a room.
Type non-integer to finish
Type non-integer to finish
Error running script: Only one 'get input' can be in progress at a time

3 Answers

0 votes
answered Sep 23 by hegemonkhan (161 points)

you probably just can't use the 'while' loop, due to its nature~behavior, with the ' get input ' (or the ' show menu ' too), as there can only be one ' get input ~ show menu ' running at a time, obviously.

0 votes
answered Oct 10 by The Pixie (121 points)

Quest continues, even while it waits for input. You will get the same result with this code, which is effectively two iterations of your loop:

  msg ("Type non-integer to finish")
  get input {
    running = IsInt(result)
  }
  msg ("Type non-integer to finish")
  get input {
    running = IsInt(result)
  }

It does the first get input, and then puts the code in the block on one side to do later, when it has the input. Then it goes straight on to the second msg, and then the second get input, at which point it realises it is now waiting for two inputs, and gives up.

The solution for my code is to put the second part inside the block:

msg ("Type non-integer to finish")
get input {
  msg ("Type non-integer to finish")
  get input {
  }
}

The solution for you is somewhat more complicated... I had a quick play around and failed to get it to work wth a recursive function and with on ready.

0 votes
answered Oct 10 by hegemonkhan (161 points)
edited Oct 10 by hegemonkhan

@Pixie and DavyB:

I think I just thought of a way to do it (or I'm on the right track if this exact design doesn't work):

handle1 = false
handle2 = false
running = true
while (running)
{
        if (handle1 = false )
        {
                msg ("Type non-integer to finish")
                get input
                {
                        running = IsInt(result)
                        handle2 = true
                }
                if (handle2 = false)
                {
                        handle1 = true
                }
                else if (handle2 = true)
                {
                        handle1 = false
                }
        }
}
This site is now closed.
As of 1st November 2015, this site is a read-only archive. For more information see the intfiction forum post

Welcome to IF Answers, a site for questions and answers about Interactive Fiction.

Technical questions about interactive fiction development tools such as Inform, Twine, Quest, QuestKit, Squiffy, Adrift, TADS etc. are all on-topic here.

Non-technical questions about interactive fiction are also on-topic. These questions could be about general IF design, specific games, entering the IF Comp etc.
...