Darth_Salva
New Member
- Joined
- Oct 15, 2007
- Messages
- 30
- Reaction score
- 0
Well... I'm learning scripting, and some time ago i saw a script where it was used the math.random to select an ID from an array...
That's the question: How to use the math.random to select ONLY ONE of the different IDs inside of an array? Example:
local array = {1234, 4321, 5544, 9966}
And use the math.random() to select one of them.
For now i'm using the only way i know:
That works but is tedious and long if you want to do many possible results...
That's the question: How to use the math.random to select ONLY ONE of the different IDs inside of an array? Example:
local array = {1234, 4321, 5544, 9966}
And use the math.random() to select one of them.
For now i'm using the only way i know:
Code:
local item = 0
local select = math.random(1, 4)
if select == 1 then
item = 1234
elseif select == 2 then
item = 4321
and so on...
That works but is tedious and long if you want to do many possible results...