blockgame/mods/bg_api/util_random.lua

11 lines
247 B
Lua
Raw Normal View History

local modname = minetest.get_current_modname()
function blockgame.chance (chance)
return math.random(1, chance) == 1
end
function blockgame.random_element (tab)
local keys = blockgame.get_keys(tab)
return tab[keys[math.random(1, #keys)]]
end