Fix error caused by returning invalid itemstack (#13)

master
fluxionary 2022-04-16 03:27:56 -07:00 committed by GitHub
parent 4dff9943d9
commit 1431a640b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 23 deletions

View File

@ -15,39 +15,17 @@ flowerpot = {}
-- Translation
local S = minetest.get_translator("flowerpot")
-- handle plant removal from flowerpot
local function flowerpot_on_punch(pos, node, puncher, pointed_thing)
if puncher and not minetest.check_player_privs(puncher, "protection_bypass") then
local name = puncher:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return false
end
end
local nodedef = minetest.registered_nodes[node.name]
local plant = nodedef.flowerpot_plantname
assert(plant, "unknown plant in flowerpot: " .. node.name)
minetest.sound_play(nodedef.sounds.dug, {pos = pos})
minetest.handle_node_drops(pos, {plant}, puncher)
minetest.swap_node(pos, {name = "flowerpot:empty"})
end
-- handle plant insertion into flowerpot
local function flowerpot_on_rightclick(pos, node, clicker, itemstack, pointed_thing)
if clicker and not minetest.check_player_privs(clicker, "protection_bypass") then
local name = clicker:get_player_name()
if minetest.is_protected(pos, name) then
minetest.record_protection_violation(pos, name)
return false
return itemstack
end
end
local nodename = itemstack:get_name()
if not nodename then
return false
end
if nodename:match("grass_1") then
nodename = nodename:gsub("grass_1", "grass_" .. math.random(5))