9951 explained code solutions for 126 technologies


luaHow to get random table item


math.randomseed(os.time())
el = tbl[math.random(1, #tbl)]ctrl + c
math.randomseed(os.time())

init unique random generator (use local time for seed)

math.random(

return random number within given range

tbl

table to get random element from

1,

min random value (first index of table)

#tbl

max random value (table size)

el

will contain random element from given table