It’s simple, im making a random value 1-4 and let’s say the player rolled the action. It hits 3 then next time he does it he gets 3 again. I want them to get 1,2 but not 3 again 4. Like first they roll the decide it gets 3 and again they do they get 3 but this time i want the game to choose the other numbers 1, 2 and 4. So how do i? This is my current code it’s a mess but take a look. Etc for other numbers
Hey Da-Just!
Recently, I had to use this system in my Color Bounce Template, but with Colors instead of numbers!
Let me explain how to do it:
First, download the “Array Tools” extension.
Create an array called “Numbers”. Make the children of it “1”, “2”, “3”, and “4”.
Follow the screenshots below:
To explain what happens, the Numbers array makes all puts all 4 of those numbers in a “list”. The code runs through the list each time until it reaches the bottom, the randomizes it and starts from the top again.
If there is any part of it that you don’t understand, or if I misunderstood the question, let me know!
I love your minimalistic approach. I love lean events. Array tools is extremely useful.
As is, the first 4 items would be in the sequence of the array. You could add a shuffle to an at the beginning event or move the shuffle to an event before the number is picked.
If Count = 0 then shuffle
RandomNumber = numbers[count]
Count +1
Count = number of children in NUMBERS then set count to 0
You could also use mod() instead of adding 1 to make the number loop automatically but it’s early and mod() takes time to explain and I’m never sure which number to use. Number of children or children +/- 1. Again, it’s early.
Random like this. 1st the player gets num 4 then let’s say they get roll again and they ger num. 3rd time they roll the dice they shouldn’t be getting 4, but should be getting between 1 and 3. Since we started with 4 then went to 2 it should be between 1 and 3. Also going from 1 2 3 4 that’s not random but we’re +1 eveytime
Can you post a screenshot of your events. It seems like SnowyRawrGamer events should do that except, to be truly random, it needs to shuffle before the 1st play. Either through an at the beginning or the version that I posted.
I’m using the events from the SnowyRawrGamer showed me. Also here’s a vid link wut i’m tryin to do Watch record_2026-01-31_23-49-14 | Streamable I couldn’t understand your adds on, on the first comment you made too.
These are the changes that I was suggesting but I realize there is a flaw in the concept. I used different variable names, a button to trigger it and a text object to display the result.
This will shuffle the array and go through it without repeating. The issue is that when it’s reshuffled, the item that was the last item in the array could become the 1st item. So, it could repeat.
I don’t fully understand your setup and I unfortunately don’t have the free time at the moment.
One solution would be to remove the last picked item, shuffle and then add the item back either as the first item or the last item. If it was the last item then the index would have to be reduced instead of increased. Yeah, I’m confusing myself.
You need a way to shuffle the list while making sure the last item doesn’t become the first item. Although, you want to make it possible for the item to be the 2nd choice.
True randomness can be a complicated concept.
I’m hoping someone else has the time to fix the concept.
There’s another option that would use the object themselves with an object variable boolean to filter out the selected object so the pick random condition would only choose from the objects with a boolean value of false. The selected object would be set to true.
I create 3 text objects and put them into a group name Items. I used the RandomItem value to pick the text object with the same text. This could just as easily be an object variable like an ID.
It doesn’t shuffle the array, so it doesn’t use the array tools.
I’ve never been a fan of the “brute force” method where it continues to create a random number. There’s too much unpredictability for me.
It did remind me of another method. You use mod().Think of it like your walking around in a pie divided by the number of items. Each time you take a random number of steps from 1 to the number of items minus 1. If it was the number of items you might end up where you started. So, you use minus 1. Then mod() will make the number wrap.