Use item meta to store effect information #1

Merged
chmodsayshello merged 3 commits from :master into master 2022-06-07 20:46:14 +02:00
1 changed files with 13 additions and 4 deletions
Showing only changes of commit 6f3c013d41 - Show all commits

View File

@ -39,13 +39,22 @@ local effects = {
return eat(itemstack, placer, pointed_thing)
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 e = itemstack:get_meta():get_string("effect")
if effects[e] then
if effects[e](itemstack,placer,pointed_thing) then
return "mcl_core:bowl"
end
local f = effects[e]
if not f then
f = get_random_effect()
end
if f(itemstack,placer,pointed_thing) then
return "mcl_core:bowl"
end
end