Removing a "case" option from a "switch"? #1592
-
Hello, I'm starting out with Quest, and experimenting with various things. I'm trying to set up a puzzle wherein there's a menu featuring several options you can click (basically like signboards you can hang up); so I have my switch script, and I'm trying to make it so when you select an option, it turns that one off and transfers it to a new verb, like so (I only left the first as an example):
So my question is how would I, say, remove the "Blue symbol" option from this verb's menu upon selecting it? I'm not super familiar with the syntax. I think I could do this somewhat easily with simple "if" commands, but if there's some "switch remove" function or similar I don't know which I could use instead, that would obviously be helpful. Cheers! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hello. Many ways to handle it. One way... Make a list attribute for gardensymbols when play begins and clone the displayverbs list attribute to avoid errors later: // Add to game.start
gardensymbols.options = Split("Blue symbol;Yellow symbol;Green symbol;Red symbol;Orange symbol", ";")
// Clone the gardensymbols displayverbs attribute, to make it safe to add/remove during play
gardensymbols.displayverbs = ListExclude(gardensymbols.displayverbs, "") Then have the script you posted behave like this: ShowMenu ("Which symbol do you want to put up?", gardensymbols.options, true) {
switch (result) {
case ("Blue symbol") {
// Remove this option from the options list
gardensymbols.options = ListExclude(gardensymbols.options, "Blue symbol")
msg ("You hang up the blue symbol.")
IncreaseObjectCounter (gardensymbols, "symbolsup")
if (not ListContains(gardensymbols.displayverbs, "Put symbol down")) {
list add (gardensymbols.displayverbs, "Put symbol down")
}
if (GetInt(gardensymbols, "symbolsup") = 5) {
list remove (gardensymbols.displayverbs, "Hang symbol up")
}
}
case ("Yellow symbol") {
}
case ("Green symbol") {
}
case ("Red symbol") {
}
case ("Orange symbol") {
}
default {
msg ("You step away from the pile of symbols.")
}
}
} This way, you control the options displayed by ShowMenu, and it won't matter if you have a case to handle a non-existent option. |
Beta Was this translation helpful? Give feedback.
Hello.
Many ways to handle it. One way...
Make a list attribute for gardensymbols when play begins and clone the displayverbs list attribute to avoid errors later:
Then have the script you posted behave like this: