Skip to content


Screwdriver: simplify logic, allow wallmounted rotation.
Browse files Browse the repository at this point in the history
- Allow rotation of wallmounted nodeboxes (signs) since they are
  now rotating properly.
- Instead of testing `ndef` several times, do it once, correctly.
- Simplify exception logic for nodes that have `on_rotate` set.
- For simplicity, return itemstack, always.
- Remove a useless nil check.
  • Loading branch information
sofar authored and paramat committed Mar 20, 2017
1 parent 6a55e15 commit ecf160d
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions mods/screwdriver/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,38 +93,33 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses)

local node = minetest.get_node(pos)
local ndef = minetest.registered_nodes[]
if not ndef then
return itemstack
-- can we rotate this paramtype2?
local fn = screwdriver.rotate[ndef.paramtype2]
if not fn then
return itemstack

local should_rotate = true
local new_param2 = fn(pos, node, mode)

-- Node provides a handler, so let the handler decide instead if the node can be rotated
if ndef and ndef.on_rotate then
if ndef.on_rotate then
-- Copy pos and node because callback can modify it
local result = ndef.on_rotate(,
{name =, param1 = node.param1, param2 = node.param2},
user, mode, new_param2)
if result == false then -- Disallow rotation
return itemstack
elseif result == true then
should_rotate = false
if not ndef or
ndef.on_rotate == false or
(ndef.drawtype == "nodebox" and
(ndef.node_box and ndef.node_box.type ~= "fixed")) or
node.param2 == nil then

if ndef.can_dig and not ndef.can_dig(pos, user) then
elseif ndef.on_rotate == false then
return itemstack
elseif ndef.can_dig and not ndef.can_dig(pos, user) then
return itemstack

if should_rotate then
Expand Down

0 comments on commit ecf160d

Please sign in to comment.