Skip to content

Commit 8d43b98

Browse files
thePalindromeparamat
authored andcommittedApr 11, 2017
Screwdriver: Allow non-native rotations if supported by targeted node
This also allows custom actions (such as using the screwdriver as a wrench).
1 parent fe02128 commit 8d43b98

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
 

Diff for: ‎mods/screwdriver/init.lua

+8-3
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,17 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses)
9898
end
9999
-- can we rotate this paramtype2?
100100
local fn = screwdriver.rotate[ndef.paramtype2]
101-
if not fn then
101+
if not fn and not ndef.on_rotate then
102102
return itemstack
103103
end
104104

105105
local should_rotate = true
106-
local new_param2 = fn(pos, node, mode)
106+
local new_param2
107+
if fn then
108+
new_param2 = fn(pos, node, mode)
109+
else
110+
new_param2 = node.param2
111+
end
107112

108113
-- Node provides a handler, so let the handler decide instead if the node can be rotated
109114
if ndef.on_rotate then
@@ -122,7 +127,7 @@ screwdriver.handler = function(itemstack, user, pointed_thing, mode, uses)
122127
return itemstack
123128
end
124129

125-
if should_rotate then
130+
if should_rotate and new_param2 ~= node.param2 then
126131
node.param2 = new_param2
127132
minetest.swap_node(pos, node)
128133
minetest.check_for_falling(pos)

0 commit comments

Comments
 (0)
Please sign in to comment.