Combining A Question With A List.
Samuel014
22 Feb 2023, 04:56Hi EveryOne,
Maybe some of you will remember me. Was active on this forum about two years ago. By "active," I mean I asked a lot of questions. You guys were very helpful. Mr. Angel in particular took time to explain things and showed me code to do what I wanted. Not sure I ever properly thanked him.
Well, I got busy with other things. Recently I again got interested in IF. Tried to write a game in Excel VBA. It would work, I think, but not easily. So I'm trying Quest again. Going through the tutorial. I remember a lot; Forgotten a lot too.
Now what I'm specifically trying to do, in the tutorial game, is empty the garbage bin. That's easy enough. But I want to make it more complicated. Want to give User a choice.
"Empty garbage bin."
"Where do you want to empty it?
- Kitchen floor.
- Out the window.
- In the dumpster."
Any ideas??
GeminiNeule
23 Feb 2023, 14:57Welcome back. I am new here (started using Quest since the beginning of the year), but I also started by expanding that tutorial. If you are setting up a verb to empty the garbage bin, it would work like this:
options = NewStringList()
list add (options , "Kitchen floor.")
list add (options , "Out the window.")
list add (options , "In the dumpster.")
ShowMenu ("Where do you want to empty it?", options, false) {
msg ("You empty the garbage bin " + result)
switch (result) {
case ("Kitchen floor.") {
// Handle kitchen floor choice
}
case ("Out the window.") {
// Handle window choice
}
case ("In the dumpster.") {
// Handle dumpster choice
}
}
}
You can also create the list using the split function if you like it more compact. the first message below ShowMenu is in order to show the result chosen and optional. You may tweak it a little bit to get proper grammar in both the menu options and the message.. or you just deal with this within the cases.
Samuel014
24 Feb 2023, 03:26Thank you for taking time to reply. I'm not sure exactly where in the code to insert your code. Will keep plugging away at it.
GeminiNeule
24 Feb 2023, 11:40I guess you have set up a verb "empty" for the garbage bin?
On the right side of that verb you need to set it to a script. One of the buttons you will see there looks like this: "</>"
This will switch to code view. You can copy & paste my snippet from above over there and can get back to the editor view if you want to.
Not sure about how to share images here.. You will find URLs to the screenshots below.
Copy code here:
https://pasteboard.co/BaY8gpr6uWq3.png
Result will look like this:
https://pasteboard.co/RAGFupFLcuA2.png
My UI is set to german, but I think you will recognize it.
Samuel014
25 Feb 2023, 04:28OK, thank you.