dimanche 12 juillet 2015

Select a random value from a table based on another random value

I'm taking all my friend's weapon stats list for an RP he's running and turning it into a generator, but I'm having issues excluding certain values based on others. For example, I don't want a secondary auto rifle. Is there a way I can exclude certain values based on another output?

local myclasses = { 'Primary', 'Secondary', 'Heavy' }
local myprimaries = { 'Auto Rifle', 'Scout Rifle', 'Pulse Rifle', 'Sniper     Rifle', 'Hand Cannon' }
local mysecondaries = { 'Shotgun', 'Sidearm', 'SMG/SEG' }
print( myclasses[ math.random(#myclasses) ] )
if 'Primary' then
print( myprimaries[ math.random(#myprimaries) ] )
elseif 'Secondary' then
print( mysecondaries[ math.random(#mysecondaries) ] )
end




Aucun commentaire:

Enregistrer un commentaire