How to choose a random word from a string?

I know this isn’t required to know in a level, but I’m trying to make it so my ring of flowers shows more than one color; And yes I know that there is a hero.setFlowerColor("random") function, but I like having more than one color in a row.

1 Like

From my knowledge of Lua, you probably need to make a table of the colors you want.

I have already done that, I’m trying to find a way to have it randomly choose a word from the table

Maybe like random = Math.random() and then like a huge function of like 100 lines of code for something like

if random =  1:
    hero.move(p)
    wait(1)
    1 = "blue"
    hero.say(1)
elif random = 2:
    hero.move(p)
    wait(1)
    2 = "green"
    hero.say(2)

etc. etc.
Anyhow, I haven’t explored the “random selection” since i dont use it alot(actually never used it XD). But if anyone has a shorter and less tedious way pls share it to us.(Also for the colors, umm dont set any color? Cause it gives this


if you dont set any color)

1 Like