Set (text variable) to random (text) or (text) block

A feature I’d like to see in Hopscotch is:

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.

13 Likes

why not use check if else?

1 Like

Wdym?

2 Likes

you can use check if else blocks to do this (typing out how)

2 Likes
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 

}
6 Likes

Thanks for providing the perfect example of code that could be improved with this block. :))

I want to optimize my Character Generator project so I don’t have to do this.

5 Likes

if you knew that would be improved then why not say it in the “what could be improved” section lol?

3 Likes

This is how programming works though

2 Likes

Didn’t know how to explain it

Oh

2 Likes

screenshots: exist

2 Likes

Well I guess this should be clived then since it’s apparently a pretty useless idea

1 Like

I like it
I think it’s an excellent idea

1 Like

an or thingy could be useful in general

2 Likes

Well you said this could be done already with check once ifs and TCMS said that way was how programming works

1 Like

Good idea, but I would prefer a switch block with cases (it’s a switch block right?).

3 Likes

yes

2 Likes

It can be done but I think the block would make it easier and the code neater, like the random number block.

Leave the topic open, see what other people think too

3 Likes

I’d love the implementation of lists in Hopscotch and the ability to pick a random item from them.

2 Likes

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.

1 Like

This would still be 10x better lol

1 Like