Fix errors caused by right-clicking unknown nodes
Some checks failed
Check & Release / lint (push) Has been cancelled

This commit is contained in:
SmallJoker 2023-10-18 21:57:58 +02:00
parent aca720dc0f
commit d6d43a4828
2 changed files with 20 additions and 12 deletions

View File

@ -106,21 +106,26 @@ if lavastuff.enable_tool_fire == true and lavastuff.fire_node then
function lavastuff.tool_fire_func(itemstack, user, pointed) function lavastuff.tool_fire_func(itemstack, user, pointed)
local name = user:get_player_name() local name = user:get_player_name()
if pointed.type == "node" then if pointed.type ~= "node" then
local node = minetest.get_node(pointed.under) return
local def = minetest.registered_nodes[node.name] end
if def.on_rightclick then local node = minetest.get_node(pointed.under)
return def.on_rightclick(pointed.under, node, user, itemstack, pointed) local def = minetest.registered_nodes[node.name]
end if not def then
return -- Unknown node
end
if minetest.is_protected(pointed.under, name) then return end if def.on_rightclick then
return def.on_rightclick(pointed.under, node, user, itemstack, pointed)
end
-- Only allow fire every 1+ second(s) if minetest.is_protected(pointed.under, name) then return end
if not COOLDOWN:get(user) then
activate_func(user, node.name, def, pointed) -- Only allow fire every 1+ second(s)
COOLDOWN:set(user, 1) if not COOLDOWN:get(user) then
end activate_func(user, node.name, def, pointed)
COOLDOWN:set(user, 1)
end end
end end
end end

View File

@ -74,6 +74,9 @@ minetest.override_item("lavastuff:shovel", {
local node = minetest.get_node(pointed_thing.under) local node = minetest.get_node(pointed_thing.under)
local def = minetest.registered_nodes[node.name] local def = minetest.registered_nodes[node.name]
if not def then
return -- Unknown node
end
if not cooldown:get(user) and (def.groups.sand or (def.groups.silica_molten and def.liquidtype == "source")) then if not cooldown:get(user) and (def.groups.sand or (def.groups.silica_molten and def.liquidtype == "source")) then
cooldown:set(user, 0) cooldown:set(user, 0)