Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » I want to make a project have a specific response if your answer is not in a list, how do I do that?
- M1mikyu
-
Scratcher
1000+ posts
I want to make a project have a specific response if your answer is not in a list, how do I do that?
I'm making an Established Titles simulator, and it's asking what Title Pack you want. The 3 responses are Lordship (or Lord), Ladyship (or Lady), and Couples (or Couples). As any other answer won't correspond to a possible title pack, I need there to be a message for if your answer isn't any of those titles, since if your answer isn't any of those the project won't be able to progress, and I thought it'd be a funny easter egg if there's specific dialog when you input another answer.
I decided a solution for this issue would be making a list containing all of the valid answers, and if the answer you give when asked isn't in that list the dialog for when you say an invalid answer will show up
Here is the coding for how responses work:

I want to add another line of code saying if the answer you give is not in the list of possible Titles to say the special dialog before telling you to ask which one you want again, as you need a valid answer to continue. Or I might make it so it chooses a random Title Pack
But I can't find any blocks which would do “if answer is not in (title packs) then….” when put together
Does anyone here know how to do this? It'd be greatly appreciated if you did! I just need a way for if the answer you give not being one of the valid answers to be still able to continue the project, since if your answer isn't one of the valid ones you'll have to start the project over, and then you can't get to the next part where you purchase your land.
I decided a solution for this issue would be making a list containing all of the valid answers, and if the answer you give when asked isn't in that list the dialog for when you say an invalid answer will show up
Here is the coding for how responses work:

I want to add another line of code saying if the answer you give is not in the list of possible Titles to say the special dialog before telling you to ask which one you want again, as you need a valid answer to continue. Or I might make it so it chooses a random Title Pack
But I can't find any blocks which would do “if answer is not in (title packs) then….” when put together
Does anyone here know how to do this? It'd be greatly appreciated if you did! I just need a way for if the answer you give not being one of the valid answers to be still able to continue the project, since if your answer isn't one of the valid ones you'll have to start the project over, and then you can't get to the next part where you purchase your land.
- cIoudyness
-
Scratcher
500+ posts
I want to make a project have a specific response if your answer is not in a list, how do I do that?
use the “if list contains” block, with a “not” boolean
so if the list does not contain the answer, then say stuff.
or use if list contains with an if else loop. same effect.
so if the list does not contain the answer, then say stuff.
or use if list contains with an if else loop. same effect.
Last edited by cIoudyness (Jan. 15, 2023 17:51:08)
- cIoudyness
-
Scratcher
500+ posts
I want to make a project have a specific response if your answer is not in a list, how do I do that?
when I receive [message v]
ask [what strikes your fancy?] and wait
if <[possible answers v] contains (answer)::list> then
if <(answer) contains [Lord]::operators> then
say [yay!]
broadcast (lordship v)
end
// etc for lady, so on
else
say [nope, not possible, go again]
broadcast (message v)
end
Last edited by cIoudyness (Jan. 15, 2023 17:50:13)
- M1mikyu
-
Scratcher
1000+ posts
I want to make a project have a specific response if your answer is not in a list, how do I do that?
I don’t think that’d work with what I’m doing…when I receive [message v]
ask [what strikes your fancy?] and wait
if <[possible answers v] contains (answer)::list> then
if <(answer) contains [Lord]::operators> then
say [yay!]
broadcast (lordship v)
end
// etc for lady, so on
else
say [nope, not possible, go again]
broadcast (message v)
end
- medians
-
Scratcher
1000+ posts
I want to make a project have a specific response if your answer is not in a list, how do I do that?
Uhh like this?


- cIoudyness
-
Scratcher
500+ posts
I want to make a project have a specific response if your answer is not in a list, how do I do that?
i don’t know what’s happening above, so new solution!
a chain of if else’s. nothing simpler
or, if you prefer, the fancy griffpatch way. do keep in mind that this will stop your scripts that clear the speech bubble too - instead of using “say” blocks, you can use “say for () seconds” blocks instead. problems solved.
a chain of if else’s. nothing simpler
if <(answer)contains[Lord]::operators> then
say [your lordship!]
else
if <(answer) contains [Lady]::operators> then
say [my lady!]
else
if <(answer) contains [couple]::operators> then
say [oh my!]
else
say [no.]
end
end
end
or, if you prefer, the fancy griffpatch way. do keep in mind that this will stop your scripts that clear the speech bubble too - instead of using “say” blocks, you can use “say for () seconds” blocks instead. problems solved.
when I receive [choose v]
if <(answer)contains[lord]::operators> then
say [confetti] for (5) secs
broadcast [lordship v]
stop [this script v]
end
if <(answer)contains[lady]::operators> then
say [baubles] for (5) secs
broadcast [ladyship v]
stop [this script v]
end
if <(answer)contains[couple]::operators> then
say [parfait] for (5) secs
broadcast [coupleship? v]
stop [this script v]
end
say [charcoal.] for (5) secs
broadcast [choose v]
Last edited by cIoudyness (Jan. 16, 2023 00:37:13)
- Discussion Forums
- » Help with Scripts
-
» I want to make a project have a specific response if your answer is not in a list, how do I do that?


