how do i
Sorry, I’m not sure what you mean. Like a textbox gets auto-generated, or you just have random words/sentences automatically put into a textbox?
no I mean use the set text command to generate codes like this 82h93u9
or something
Ohhh ok, I got it. Well, first, you would probably want to create a variable that stores your code. Then you assign random numbers/letters to it, then use setText to set the textbox to display that variable. The question is how to assign the random numbers and letters…one way would be to just have all the possible numbers/letters stored in an array. Then you would want to get a random array element multiple times. I can try to put something together, just gimme a minute…
Er well, I forgot it can actually just be one string that you pull characters from. This is how you could do it:
generateCode.wick (1.5 KB)
You can set the ‘codeLength’ variable to how long you want your code to be. And if you only want lowercase letters, just remove all of the uppercase letters from ‘codeParts’.
Just to mention, u don’t have to use arrays to add in random characters, the random.choice(); can randomly choose a character, here’s a never ending code generator example:
generateCode(endless).wick (1.4 KB)
If you have a set of numbers in there, like random.choice("1234567890");
, it’ll choose a random number from 0 to 9 to add in.
You can also have it add new lines randomly
This might be a better example:
generateCode10-31-2020_8-36-27AM.wick (5.3 KB)
Once u have the text that u need, u can make it stop from adding new lines
Thanks
That’s way simpler, thanks for pointing it out!..I don’t know why, but I always forget that strings are basically treated the same as arrays. (At least with indexing and that kind of thing)
WAIT YOU DO NOT KNOW HOW TO USE SET TEXT
how do you not know how to use set text
I didn’t know how to use setText when I started coding
I don’t think anyone did
Replace TextName with the name of your text object
TextName.setText("The text should say this");
nvm
I forgot that i only figured out that set text was a thing a month before I became a rug