The place to discuss the ADRIFT Interactive Fiction toolkit

Requesting Input on Requesting Input

This forum is the place to learn about and discuss ADRIFT 5. Feel free to mention any bugs you find here, but please also add these to the Bugs & Enhancements list.

Please also refer to the ADRIFT 5 Wiki for more information.

Requesting Input on Requesting Input

Postby Jjbee62 » Tue May 03, 2016 4:30 am

This is part of a larger issue I'm trying to work around.

The simple part is, I want a task which requests player input, which will be stored in a variable. I know I can use PopUpInput, but I also want to restrict their options to a particular list. As an example, let's say the player has to mix a potion, which requires adding the correct 4 ingredients in the correct order. With PopUpInput they can enter anything, which would require a loop to check the input against available ingredients, until a correct ingredient is entered. This would work fine, except I don't see any way to have a conditional loop, in other words, keep repeating the task with the PopUpInput call until a correct ingredient is chosen. Am I missing something?
Posts: 64
Joined: Fri Apr 15, 2016 5:20 pm

Re: Requesting Input on Requesting Input

Postby ElliotM » Tue May 03, 2016 5:04 am

Looping of that sort can be done if you have a task execute or call itself, but you have to be careful about not spawning an infinite loop. I would recommend splitting this into two tasks.

Task A: Does anything that should only be done once, to setup things, such as clearing your input variable to be blank. Calls Task B, which will ask the question of which ingredient:

Task B: In the actions set your input variable equal to the input of the player using PopUpInput. At the end of the action list, have Task B call itself. In the restrictions, we will say that the input variable must be blank or not equal one of the available ingredients in order for it to run. If either is true, it will run because the input variable doesn't have valid input yet. The first time it will run it will be because input is blank, since we updated it in Task A before calling Task B. When it runs the first time it will grab the new input from the player, and will get to the end of the action list and call itself. When it tries to run the second time, it will check the input variable but will only run if the player input wasn't a valid ingredient or it is still blank. That way you loop until you get valid input.

You'll want to be very careful with that because you don't want the player to get stuck in a loop they can' get out, so you'll need to find a way to let the player break out of the loop. Perhaps add another word to check for in the restriction such as undo or quit. If one of these words is detected, Task B should not run again in order to break the cycle.

I posted about popup inputs awhile ago if you need a reference/example: viewtopic.php?f=14&t=11363
Posts: 1227
Joined: Tue Apr 17, 2007 8:04 pm
Location: The Midwest in the USA
Points: 13

Re: Requesting Input on Requesting Input

Postby Jjbee62 » Tue May 03, 2016 6:10 pm

I was halfway there. I think that resolves my major roadblock at this point. Thanks.
Posts: 64
Joined: Fri Apr 15, 2016 5:20 pm

Re: Requesting Input on Requesting Input

Postby ParadoxGames » Wed May 04, 2016 8:36 pm

Thank you. I had something similar, where the character has to throw four switches in the right order and I will be needing this reference too.
Posts: 161
Joined: Sat Sep 05, 2015 2:33 am
Points: 10

Return to ADRIFT 5.0

Who is online

Users browsing this forum: No registered users and 5 guests