nodecore-cd2025/mods/nc_api/issue9043.lua

31 lines
1.1 KiB
Lua
Raw Normal View History

2019-10-13 09:31:22 -04:00
-- LUALOCALS < ---------------------------------------------------------
local minetest, rawset
= minetest, rawset
2019-10-13 09:31:22 -04:00
-- LUALOCALS > ---------------------------------------------------------
-- minetest.rotate_node uses sneak to invert the wall/floor orientation
-- direction, but REMOVES the use of sneak to prevent right-click on the
-- underlying node, which is a far more important function.
2019-10-13 09:31:22 -04:00
minetest.rotate_node = function(itemstack, placer, pointed_thing)
local invert_wall = placer and placer:get_player_control().sneak or false
local function commit()
return minetest.rotate_and_place(itemstack, placer, pointed_thing, false,
{invert_wall = invert_wall}, true)
end
if not invert_wall then return commit() end
local node = minetest.get_node_or_nil(pointed_thing.under)
if not node then return end
local def = minetest.registered_nodes[node.name]
if not def.on_rightclick then return commit() end
local oldrc = def.on_rightclick
local function helper(...)
rawset(def, "on_rightclick", oldrc)
return ...
end
rawset(def, "on_rightclick", nil)
return helper(commit())
2019-10-13 09:31:22 -04:00
end