@@ -72,61 +72,59 @@ local function screwdriver_handler(itemstack, user, pointed_thing)
72
72
end
73
73
local node = minetest .get_node (pos )
74
74
local ndef = minetest .registered_nodes [node .name ]
75
- if ndef and ndef .paramtype2 == " facedir" then
76
- if ndef .drawtype == " nodebox" and ndef .node_box .type ~= " fixed" then
77
- return
78
- end
79
- if node .param2 == nil then
80
- return
81
- end
82
- -- Get ready to set the param2
83
- local n = node .param2
84
- local axisdir = math.floor (n / 4 )
85
- local rotation = n - axisdir * 4
86
- if mode == 1 then
75
+ if not ndef or not ndef .paramtype2 == " facedir" or
76
+ (ndef .drawtype == " nodebox" and
77
+ not ndef .node_box .type == " fixed" ) or
78
+ node .param2 == nil then
79
+ return
80
+ end
81
+ -- Get ready to set the param2
82
+ local n = node .param2
83
+ local axisdir = math.floor (n / 4 )
84
+ local rotation = n - axisdir * 4
85
+ if mode == 1 then
86
+ n = axisdir * 4 + nextrange (rotation , 3 )
87
+ elseif mode == 2 then
88
+ -- If you are pointing at the axisdir face or the
89
+ -- opposite one then you can just rotate the node.
90
+ -- Otherwise change the axisdir, avoiding the facing
91
+ -- and opposite axes.
92
+ local face = get_node_face (pointed_thing )
93
+ if axisdir == face or axisdir == opposite_faces [face ] then
87
94
n = axisdir * 4 + nextrange (rotation , 3 )
88
- elseif mode == 2 then
89
- -- If you are pointing at the axisdir face or the
90
- -- opposite one then you can just rotate the node.
91
- -- Otherwise change the axisdir, avoiding the facing
92
- -- and opposite axes.
93
- local face = get_node_face (pointed_thing )
95
+ else
96
+ axisdir = nextrange (axisdir , 5 )
97
+ -- This is repeated because switching from the face
98
+ -- can move to to the opposite and vice-versa
94
99
if axisdir == face or axisdir == opposite_faces [face ] then
95
- n = axisdir * 4 + nextrange (rotation , 3 )
96
- else
97
100
axisdir = nextrange (axisdir , 5 )
98
- -- This is repeated because switching from the face
99
- -- can move to to the opposite and vice-versa
100
- if axisdir == face or axisdir == opposite_faces [face ] then
101
- axisdir = nextrange (axisdir , 5 )
102
- end
103
- if axisdir == face or axisdir == opposite_faces [face ] then
104
- axisdir = nextrange (axisdir , 5 )
105
- end
106
- n = axisdir * 4
107
101
end
108
- elseif mode == 3 then
109
- n = nextrange (axisdir , 5 ) * 4
110
- elseif mode == 4 then
111
- local face = get_node_face (pointed_thing )
112
- if axisdir == face then
113
- n = axisdir * 4 + nextrange (rotation , 3 )
114
- else
115
- n = face * 4
102
+ if axisdir == face or axisdir == opposite_faces [face ] then
103
+ axisdir = nextrange (axisdir , 5 )
116
104
end
105
+ n = axisdir * 4
117
106
end
118
- -- print (dump(axisdir..", "..rotation))
119
- node . param2 = n
120
- minetest . swap_node ( pos , node )
121
- local item_wear = tonumber ( itemstack : get_wear () )
122
- item_wear = item_wear + 327
123
- if item_wear > 65535 then
124
- itemstack : clear ()
125
- return itemstack
107
+ elseif mode == 3 then
108
+ n = nextrange ( axisdir , 5 ) * 4
109
+ elseif mode == 4 then
110
+ local face = get_node_face ( pointed_thing )
111
+ if axisdir == face then
112
+ n = axisdir * 4 + nextrange ( rotation , 3 )
113
+ else
114
+ n = face * 4
126
115
end
127
- itemstack :set_wear (item_wear )
116
+ end
117
+ -- print (dump(axisdir..", "..rotation))
118
+ node .param2 = n
119
+ minetest .swap_node (pos , node )
120
+ local item_wear = tonumber (itemstack :get_wear ())
121
+ item_wear = item_wear + 327
122
+ if item_wear > 65535 then
123
+ itemstack :clear ()
128
124
return itemstack
129
125
end
126
+ itemstack :set_wear (item_wear )
127
+ return itemstack
130
128
end
131
129
132
130
minetest .register_craft ({
0 commit comments