1
0
Fork 0

Prevent eating cake if full

This commit is contained in:
Wuzzy 2017-05-23 02:09:47 +02:00
parent c2c9a2f4a4
commit fa3cd83f5a
1 changed files with 17 additions and 7 deletions

View File

@ -49,8 +49,11 @@ minetest.register_node("mcl_cake:cake", {
groups = {handy=1, cake=7, food=2,no_eat_delay=1, attached_node=1, dig_by_piston=1},
drop = '',
on_rightclick = function(pos, node, clicker, itemstack)
minetest.do_item_eat(2, ItemStack("mcl_cake:cake_6"), ItemStack("mcl_cake:cake"), clicker, {type="nothing"})
local newcake = minetest.do_item_eat(2, ItemStack("mcl_cake:cake_6"), ItemStack("mcl_cake:cake"), clicker, {type="nothing"})
-- Check if we were allowed to eat
if newcake:get_name() ~= "mcl_cake:cake" then
minetest.add_node(pos,{type="node",name="mcl_cake:cake_6",param2=0})
end
end,
sounds = mcl_sounds.node_sound_leaves_defaults(),
@ -66,16 +69,23 @@ local register_slice = function(level, nodebox, desc)
local on_rightclick
if level > 1 then
on_rightclick = function(pos, node, clicker, itemstack)
minetest.do_item_eat(2, ItemStack(after_eat), ItemStack(this), clicker, {type="nothing"})
local newcake = minetest.do_item_eat(2, ItemStack(after_eat), ItemStack(this), clicker, {type="nothing"})
-- Check if we were allowed to eat
if newcake:get_name() ~= this then
minetest.add_node(pos,{type="node",name=after_eat,param2=0})
end
end
else
-- Last slice
on_rightclick = function(pos, node, clicker, itemstack)
minetest.do_item_eat(2, ItemStack("mcl:cake:cake 0"), ItemStack("mcl_cake:cake_1"), clicker, {type="nothing"})
local newcake = minetest.do_item_eat(2, ItemStack("mcl:cake:cake 0"), ItemStack("mcl_cake:cake_1"), clicker, {type="nothing"})
-- Check if we were allowed to eat
if newcake:get_name() ~= this then
minetest.remove_node(pos)
core.check_for_falling(pos)
end
end
end
minetest.register_node(this, {
description = desc,