mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 10:31:06 +01:00
Use proper keyset for randomisation
This commit is contained in:
parent
0cd2c3993f
commit
544c6cbdb3
1 changed files with 10 additions and 2 deletions
|
@ -13,12 +13,20 @@ local shoulders = {
|
|||
right = vector.new(3.75,10.5,0)
|
||||
}
|
||||
|
||||
local function table_get_rand(tbl)
|
||||
local keys = {}
|
||||
for k in pairs(tbl) do
|
||||
table.insert(keys, k)
|
||||
end
|
||||
return tbl[keys[math.random(#keys)]]
|
||||
end
|
||||
|
||||
local function get_random_mob_sound()
|
||||
local t = table.copy(minetest.registered_entities)
|
||||
table.shuffle(t)
|
||||
for _,e in pairs(t) do
|
||||
if e.is_mob and e.sounds then
|
||||
return e.sounds[math.random(#e.sounds)]
|
||||
if e.is_mob and e.sounds and #e.sounds > 0 then
|
||||
return table_get_rand(e.sounds)
|
||||
end
|
||||
end
|
||||
return minetest.registered_entities["mobs_mc:parrot"].sounds.random
|
||||
|
|
Loading…
Reference in a new issue