X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=cooking.lua;h=c35bcd099d443b81f3e492057c33f6814641977c;hb=c7633ffd2029fea899a6156a01176b578ab4029b;hp=3cad827f35c7f444d45d5e469a7b7c1e5f2d025a;hpb=43824cb4f5d6b96de2dac46e63395c7319c370fc;p=xdecor.git diff --git a/cooking.lua b/cooking.lua index 3cad827..c35bcd0 100644 --- a/cooking.lua +++ b/cooking.lua @@ -76,15 +76,23 @@ xdecor.register("cauldron_soup", { collision_box = cauldron_cbox, on_rightclick = function(pos, node, clicker, itemstack) local inv = clicker:get_inventory() - if clicker:get_wielded_item():get_name() == "xdecor:bowl" then - if inv:room_for_item("main", "xdecor:bowl_soup 1") then - itemstack:take_item() - inv:add_item("main", "xdecor:bowl_soup 1") - minetest.set_node(pos, {name="xdecor:cauldron_empty", param2=node.param2}) - else - minetest.chat_send_player(clicker:get_player_name(), + local wield_item = clicker:get_wielded_item() + + if wield_item:get_name() == "xdecor:bowl" then + if wield_item:get_count() > 1 then + if inv:room_for_item("main", "xdecor:bowl_soup 1") then + itemstack:take_item() + inv:add_item("main", "xdecor:bowl_soup 1") + else + minetest.chat_send_player(clicker:get_player_name(), "No room in your inventory to add a bowl of soup!") + return + end + else + itemstack:replace("xdecor:bowl_soup 1") end + + minetest.set_node(pos, {name="xdecor:cauldron_empty", param2=node.param2}) return itemstack end end @@ -103,7 +111,7 @@ minetest.register_abm({ minetest.register_abm({ nodenames = {"xdecor:cauldron_boiling_water"}, - interval = 3, chance = 1, + interval = 5, chance = 1, action = function(pos, node) local objs = minetest.get_objects_inside_radius(pos, 0.5) if not objs then return end @@ -116,7 +124,7 @@ minetest.register_abm({ for _, obj in pairs(objs) do if obj and obj:get_luaentity() then - local itemstring = obj:get_luaentity().itemstring:match("[%w_]+:([%w_]+)") + local itemstring = obj:get_luaentity().itemstring:match("[^:]+$") if not next(ingredients) then for _, rep in pairs(ingredients) do if itemstring == rep then return end