Always return the ItemStack for on_rightclick and on_place to comply with the api.
This commit is contained in:
parent
a2b7ebc6f2
commit
73a29be691
@ -52,7 +52,7 @@ function cauldron.filling(pos, node, clicker, itemstack)
|
|||||||
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 bucket of water.")
|
"No room in your inventory to add a bucket of water.")
|
||||||
return
|
return itemstack
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
itemstack:replace("bucket:bucket_water")
|
itemstack:replace("bucket:bucket_water")
|
||||||
@ -128,15 +128,15 @@ function cauldron.take_soup(pos, node, clicker, itemstack)
|
|||||||
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
|
return itemstack
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
itemstack:replace("xdecor:bowl_soup 1")
|
itemstack:replace("xdecor:bowl_soup 1")
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.set_node(pos, {name="xdecor:cauldron_empty", param2=node.param2})
|
minetest.set_node(pos, {name="xdecor:cauldron_empty", param2=node.param2})
|
||||||
return itemstack
|
|
||||||
end
|
end
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
xdecor.register("cauldron_empty", {
|
xdecor.register("cauldron_empty", {
|
||||||
|
@ -71,7 +71,9 @@ function itemframe.rightclick(pos, node, clicker, itemstack)
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local player = clicker:get_player_name()
|
local player = clicker:get_player_name()
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
if player ~= owner or not itemstack then return end
|
if player ~= owner or not itemstack then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
drop_item(pos, node)
|
drop_item(pos, node)
|
||||||
local itemstring = itemstack:take_item():to_string()
|
local itemstring = itemstack:take_item():to_string()
|
||||||
|
@ -96,7 +96,7 @@ function mailbox.after_place_node(pos, placer)
|
|||||||
inv:set_size("drop", 1)
|
inv:set_size("drop", 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
function mailbox.rightclick(pos, _, clicker)
|
function mailbox.rightclick(pos, node, clicker, itemstack, pointed_thing)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local player = clicker:get_player_name()
|
local player = clicker:get_player_name()
|
||||||
local owner = meta:get_string("owner")
|
local owner = meta:get_string("owner")
|
||||||
@ -106,6 +106,7 @@ function mailbox.rightclick(pos, _, clicker)
|
|||||||
else
|
else
|
||||||
minetest.show_formspec(player, "xdecor:mailbox", mailbox:formspec(pos, owner, 0))
|
minetest.show_formspec(player, "xdecor:mailbox", mailbox:formspec(pos, owner, 0))
|
||||||
end
|
end
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
function mailbox.put(pos, listname, _, stack, player)
|
function mailbox.put(pos, listname, _, stack, player)
|
||||||
|
@ -92,8 +92,10 @@ xdecor.register("lever_off", {
|
|||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
on_rotate = screwdriver.rotate_simple,
|
on_rotate = screwdriver.rotate_simple,
|
||||||
on_rightclick = function(pos, node, clicker)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
if not doors.get then return end
|
if not doors.get then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
local minp = {x=pos.x-2, y=pos.y-1, z=pos.z-2}
|
local minp = {x=pos.x-2, y=pos.y-1, z=pos.z-2}
|
||||||
local maxp = {x=pos.x+2, y=pos.y+1, z=pos.z+2}
|
local maxp = {x=pos.x+2, y=pos.y+1, z=pos.z+2}
|
||||||
local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
|
local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
|
||||||
@ -101,6 +103,7 @@ xdecor.register("lever_off", {
|
|||||||
for i = 1, #doors do
|
for i = 1, #doors do
|
||||||
door_toggle(pos, doors[i], clicker)
|
door_toggle(pos, doors[i], clicker)
|
||||||
end
|
end
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
14
nodes.lua
14
nodes.lua
@ -141,9 +141,10 @@ xdecor.register("chair", {
|
|||||||
{11, 0, 3, 2, 6, 2}, {3, 6, 3, 10, 2, 8}
|
{11, 0, 3, 2, 6, 2}, {3, 6, 3, 10, 2, 8}
|
||||||
}),
|
}),
|
||||||
can_dig = xdecor.sit_dig,
|
can_dig = xdecor.sit_dig,
|
||||||
on_rightclick = function(pos, node, clicker, _, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
pos.y = pos.y + 0 -- Sitting position.
|
pos.y = pos.y + 0 -- Sitting position.
|
||||||
xdecor.sit(pos, node, clicker, pointed_thing)
|
xdecor.sit(pos, node, clicker, pointed_thing)
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -175,8 +176,9 @@ for _, c in pairs({"red"}) do -- Add more curtains colors simply here.
|
|||||||
paramtype2 = "wallmounted",
|
paramtype2 = "wallmounted",
|
||||||
groups = {dig_immediate=3, flammable=3},
|
groups = {dig_immediate=3, flammable=3},
|
||||||
selection_box = {type="wallmounted"},
|
selection_box = {type="wallmounted"},
|
||||||
on_rightclick = function(pos, node)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
minetest.set_node(pos, {name="xdecor:curtain_open_"..c, param2=node.param2})
|
minetest.set_node(pos, {name="xdecor:curtain_open_"..c, param2=node.param2})
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -188,8 +190,9 @@ for _, c in pairs({"red"}) do -- Add more curtains colors simply here.
|
|||||||
groups = {dig_immediate=3, flammable=3, not_in_creative_inventory=1},
|
groups = {dig_immediate=3, flammable=3, not_in_creative_inventory=1},
|
||||||
selection_box = {type="wallmounted"},
|
selection_box = {type="wallmounted"},
|
||||||
drop = "xdecor:curtain_"..c,
|
drop = "xdecor:curtain_"..c,
|
||||||
on_rightclick = function(pos, node)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
minetest.set_node(pos, {name="xdecor:curtain_"..c, param2=node.param2})
|
minetest.set_node(pos, {name="xdecor:curtain_"..c, param2=node.param2})
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -207,9 +210,10 @@ xdecor.register("cushion", {
|
|||||||
on_place = minetest.rotate_node,
|
on_place = minetest.rotate_node,
|
||||||
node_box = xdecor.nodebox.slab_y(0.5),
|
node_box = xdecor.nodebox.slab_y(0.5),
|
||||||
can_dig = xdecor.sit_dig,
|
can_dig = xdecor.sit_dig,
|
||||||
on_rightclick = function(pos, node, clicker, _, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
pos.y = pos.y + 0 -- Sitting position.
|
pos.y = pos.y + 0 -- Sitting position.
|
||||||
xdecor.sit(pos, node, clicker, pointed_thing)
|
xdecor.sit(pos, node, clicker, pointed_thing)
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -372,8 +376,8 @@ xdecor.register("painting_1", {
|
|||||||
end
|
end
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
return itemstack
|
|
||||||
end
|
end
|
||||||
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
4
rope.lua
4
rope.lua
@ -12,7 +12,9 @@ function rope.place(itemstack, placer, pointed_thing)
|
|||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
local oldnode = minetest.get_node(pos)
|
local oldnode = minetest.get_node(pos)
|
||||||
local stackname = itemstack:get_name()
|
local stackname = itemstack:get_name()
|
||||||
if minetest.is_protected(pos, placer:get_player_name()) then return end
|
if minetest.is_protected(pos, placer:get_player_name()) then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
while oldnode.name == "air" and not itemstack:is_empty() do
|
while oldnode.name == "air" and not itemstack:is_empty() do
|
||||||
local newnode = {name = stackname, param1 = 0}
|
local newnode = {name = stackname, param1 = 0}
|
||||||
|
Loading…
Reference in New Issue
Block a user