hm what do you intend to go inside each if / else branch? Do you just intend to store 20 random values? This would unfortunately be the way in blocks to handle having 18 different branches to the code with unrelated behavior, but if you can give an example of what you intend for it to do on a smaller scale there’s probably a pattern we can use to make it much simpler!
For making each variable, though, any time I see variable{number}
as variable names I’d be a bit suspicious of it / start to think you might want to use an array; e.g. if you just want to have 20 variables each containing a random number, you could do
which will result in list having 20 random values between 1 and 18 (they will be stored in indexes 0-19)
I want 18 random values and put text in them to make a randomized text almost. I’m making a rubiks cube scrambler with notations that are rqndom
Here is the link so you know the extensions and variables I’m using.
I plan to put it in an
A Button Pressed
block
Hm, do you just want random strings then? If that’s the case then you would probably want an array of strings, and pick a random index in that; like this example: Arcade Advanced Stream #10 - Game idea generator
I’m using 20 “randoms” because a scramble takes up 20 notations
There are several ways that you can do this. How you go about this depends on what you want to do with this information.
- Do you need to keep information on all 20 turns, or do you just need to do something with each turn as it’s created?
- How do you want to display the information about these turns, if at all?
- What do you want to do after the 20 turns have been generated?
For really complex projects, it can be tough to write the code. It helps a lot if you write a plan ahead of time.
Let us know what you’re planning for this program. There are a bunch of us here who will be happy to help you with writing your plan or, afterward, with writing your code.
I love the premise of your program! Looking forward to helping you with it!
I want to make these random words like:
R2
Ri
R
and those three will be used because that is only the right side of the cube. 6 sides x 3 notations on 1 side is equal to 18 different notations that can be used for scrambles and there has to be 20 notations on a random scramble
all notations:
L, Li, L2, R, Ri, R2, D, Di, D2, U, Ui, U2, F, Fi, F2, B, Bi, B2
This is what I’m doing so far
You can’t set a string to a number. (This is the power of Typescript in action)
Then what do I do to make randomized text in a text sprite
You have to convert the number to a string.
Note: Original post had a bit of an error in it.
You’re super close!
Like @UnsignedArduino said, your NotationList
is an array of strings, and you’re trying to assign numbers into the array.
You also probably don’t want to change the list of moves. You want a new list instead with some random moves picked from NotationList
.
You want something like this:
Notice I’m passing ShuffledList
to your function, too.
P.S. I really like your use of comments! Good job in putting a plan together!
What’s the ShuffledList
Also noting, @AlexK used a single join _
instead of convert _ to text
. The convert _ to text
makes more sense if you are just going to convert one number, but the join _
is useful if you want to shove a bunch of strings, numbers, etc. together, because it implicitly converts all of the inputs to strings and adds them together. They essentially both do the same.
ShuffledList
will be a new list with random moves selected from NotationList
.
So, NotationList
looks like this:
R, R1, R2, L, L1, L2, F, F1, F2, D, D1, D2, B, B1, B2, U, U1, U2
And ShuffledList
might look like this:
D, U2, L, L, F, D2, R, B, F, U, F, R2, L1, F1, F2, B, U2, F1
ShuffledList
will be different each time that loop runs.
The shuffled list is what I want as multiple text sprites
Is there a picture you can add @AlexK?