Login
Remember
IF Answers
Ask a Question

# 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

- quest
- loop

## 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
                    }
            }
    }

## Related questions

- Is there an easy way to loop text in Inform 7?
- What's a good method when dealing with a ton of objects in Quest?
- In Quest, will save files from an older game work with a newer verison of a game?
- How do I work with lists in Quest?
- Quest Gamebook: Return to a previous page with multiple links, and make link already chosen inactive

...