how can i limit random(min, max) values
for example i have at first change attribute to random(1,5), but when the game progresses some of the values are not valid anymore, for example, if the value 3 is not valid anymore, when the attribute changes to random(1,5) i wan't it to change to any vaue between 1 and 5 except for 3, is that possible?
Answers
To do this, you could create a boolean for each number that could become invalid (for exmaple: game.Invalid3). Then, just create a rule that says when game.Invalid3 = true and your number = 3, then regenerate the random number.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
-- 4 Attributes (Types) (explained) --
1. StartRan (Integer) (trigger to start the function)
2. RanNumber (Integer) (where the preliminary random number is stored)
3. RanPicks (Text) (where previously chosen random numbers are stored)
4. MyNewRandomPick (Integer) (your final random number you need)
-- 4 Seperate Rules --
1. Start the choose random number function with one switch
2. After the random number is chosen, check if the pick is unique
3. If number is not unique, reset RanNumber
4. If number is not unique, start the function over again
1. If StartRan = 1 (Flip switch to Start Function)
1a. Change Attribute RanNumber to Random(1,5) (Pick a random number 1-5 in this case)
2. If RanNumber Not= 0 (Start next part of function after random number has been picked)
2a. Change Attribute StartRan = 0 (Reset the choose random number switch)
2b. If RanPicks contains "!"..(RanNumber).."!" (check if number has already been used)
2b-b. Change attribute StartRan = 2 (If number already been used, need to restart function)
otherwise
2c. Change Attribute RanPicks to (RanPicks).."!"..(RanNumber).."!" (If not used, add number to picked list for later use)
2c-a. Change attribute MyNewRandomPick = RanNumber (Store your new unique random number to be used how you want)
2c-a. Change attribute RanNumber = 0 (Clear attribute to fully reset function)
3. If StartRan = 2, Change Attribute RanNumber = 0 (Reset random number)
4. If StartRan = 2 and RanNumber = 0, Constrain StartRan = 1 (Start function over)
Notes:
- The "!"..(RanNumber).."!" is used to make each number unique in the RanPicks attribute. This will allow you to use this function for numbers with more than one digit.
- Do Not place Rules 1, 2, 3 or 4 inside of each other.
- Constrain attribute must be used in rule 4
Let me know if you have any questions. Hope this helps, thanks!
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
I think I get what your saying, but what if you want to list out numbers 1-1000 in random order. Does it still work?
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS