forked from VoxeLibre/VoxeLibre
Simplified stew on_craft function with table lookup
This commit is contained in:
parent
dae24a5bb1
commit
666fdf31f9
|
@ -17,4 +17,5 @@ Conveniently register a sus stew effect which gives the eater a status effect.
|
||||||
## mcl_sus_stew.register_sus_stew(secret_ingredient, effect_name)
|
## mcl_sus_stew.register_sus_stew(secret_ingredient, effect_name)
|
||||||
Register a suspicious stew crafted with a bowl, red mushroom, brown mushroom and <secret_ingredient>.
|
Register a suspicious stew crafted with a bowl, red mushroom, brown mushroom and <secret_ingredient>.
|
||||||
* secret_ingredient: itemstring of the fourth ingredient
|
* secret_ingredient: itemstring of the fourth ingredient
|
||||||
|
DON'T use bowl or red/brown mushroom as this will mess up all sus stews
|
||||||
* effect_name: the name of the sus stew effect to be activated when the sus stew is eaten
|
* effect_name: the name of the sus stew effect to be activated when the sus stew is eaten
|
||||||
|
|
|
@ -89,12 +89,11 @@ end
|
||||||
|
|
||||||
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
|
minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv)
|
||||||
if itemstack:get_name() ~= "mcl_sus_stew:stew" then return end
|
if itemstack:get_name() ~= "mcl_sus_stew:stew" then return end
|
||||||
for f,e in pairs(ingredient_effect) do
|
for _,it in pairs(old_craft_grid) do
|
||||||
for _,it in pairs(old_craft_grid) do
|
local effect = ingredient_effect[it:get_name()]
|
||||||
if it:get_name() == f then
|
if effect ~= nil then
|
||||||
itemstack:get_meta():set_string("effect",e)
|
itemstack:get_meta():set_string("effect", effect)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue