Cooking : replace itemstack when empty bowl stack does not exceed 1
This commit is contained in:
parent
092e969f97
commit
8aae802f1c
12
cooking.lua
12
cooking.lua
@ -76,15 +76,23 @@ xdecor.register("cauldron_soup", {
|
|||||||
collision_box = cauldron_cbox,
|
collision_box = cauldron_cbox,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack)
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
local inv = clicker:get_inventory()
|
local inv = clicker:get_inventory()
|
||||||
if clicker:get_wielded_item():get_name() == "xdecor:bowl" then
|
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
|
if inv:room_for_item("main", "xdecor:bowl_soup 1") then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
inv:add_item("main", "xdecor:bowl_soup 1")
|
inv:add_item("main", "xdecor:bowl_soup 1")
|
||||||
minetest.set_node(pos, {name="xdecor:cauldron_empty", param2=node.param2})
|
|
||||||
else
|
else
|
||||||
minetest.chat_send_player(clicker:get_player_name(),
|
minetest.chat_send_player(clicker:get_player_name(),
|
||||||
"No room in your inventory to add a bowl of soup!")
|
"No room in your inventory to add a bowl of soup!")
|
||||||
|
return
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
itemstack:replace("xdecor:bowl_soup 1")
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.set_node(pos, {name="xdecor:cauldron_empty", param2=node.param2})
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user