Set (text variable) to random (text) or (text) or (text) or… block
I’d use it for this type of project:
Any project where I want to set a text variable to a random word. Personally, I’d use it to make the code for my Character Generator project simpler.
Here are some examples of Hopscotch code that could be improved if we had this:
I’m not sure.
Here is an example design I’ve made:
Basically it would be the same as the Set (variable) to random (number) to (number) block except instead of random (number) to (number) it would be random (text) or (text). (Actually, an “or” random block would be helpful for numbers too.)
I’ve seen something similar in another programming languages, it looks like this:
I haven’t seen something similar in other programming languages because I don’t use other programming languages.
when game starts {
set variable OHYEAH to random 1 to 6
if OHYEAH = 1 {
OHYEAH = Oh no
} else if OHYEAH = 2 {
OHYEAH = Oh maybe
} else if OHYEAH = 3 {
OHYEAH = OH NOOO
} else if OHYEAH = 4 {
OHYEAH = sure
} else if OHYEAH = 5 {
OHYEAH = skittles
} else {
OHYEAH = Oh yeah yeah
}
// I wanted to end these with a semicolon so badly
}
Another solution is to set variable to random blank to blank and then check once if variable equals 1 and then set the text to whatever you want. It’s more complicated, but still effective.