mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-09 17:23:49 +01:00
random effect on sstew with no meta
This commit is contained in:
parent
3cd87dfe38
commit
6f3c013d41
17
init.lua
17
init.lua
@ -39,13 +39,22 @@ local effects = {
|
|||||||
return eat(itemstack, placer, pointed_thing)
|
return eat(itemstack, placer, pointed_thing)
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
local function get_random_effect()
|
||||||
|
local keys = {}
|
||||||
|
for k in pairs(effects) do
|
||||||
|
table.insert(keys, k)
|
||||||
|
end
|
||||||
|
return effects[keys[math.random(#keys)]]
|
||||||
|
end
|
||||||
|
|
||||||
local function eat_stew(itemstack, placer, pointed_thing)
|
local function eat_stew(itemstack, placer, pointed_thing)
|
||||||
local e = itemstack:get_meta():get_string("effect")
|
local e = itemstack:get_meta():get_string("effect")
|
||||||
if effects[e] then
|
local f = effects[e]
|
||||||
if effects[e](itemstack,placer,pointed_thing) then
|
if not f then
|
||||||
return "mcl_core:bowl"
|
f = get_random_effect()
|
||||||
end
|
end
|
||||||
|
if f(itemstack,placer,pointed_thing) then
|
||||||
|
return "mcl_core:bowl"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user