WAP only opens if sneak is pressed when pointing at nodes defining on_rightclick

This commit is contained in:
Ocraw 2024-08-24 15:16:31 +02:00
parent 521b351ccd
commit f8ba3efdac

View File

@ -50,6 +50,16 @@ end
local function on_wireless_pad_secondary(itemstack, placer, pointed_thing)
if not placer or not placer:is_player() then return end
-- Make sure the wap doesn't open if clicking on a node with on_rightclick function
-- unless sneak is pressed.
if pointed_thing.type == "node" then
local node = minetest.get_node(pointed_thing.under)
if not placer:get_player_control().sneak and node then
if minetest.registered_nodes[node.name] and minetest.registered_nodes[node.name].on_rightclick then
return minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack) or itemstack
end
end
end
local playerName = placer:get_player_name()
local itemMeta = itemstack:get_meta()