1
- rcvboxes = {
1
+ local rcvboxes = {
2
2
{ - 3 / 16 , - 3 / 16 , - 8 / 16 , 3 / 16 , 3 / 16 , - 13 / 32 }, -- the smaller bump
3
3
{ - 1 / 32 , - 1 / 32 , - 3 / 2 , 1 / 32 , 1 / 32 , - 1 / 2 }, -- the wire through the block
4
4
{ - 2 / 32 , - 1 / 2 , - .5 , 2 / 32 , 0 , - .5002 + 3 / 32 }, -- the vertical wire bit
5
5
{ - 2 / 32 , - 1 / 2 , - 7 / 16 + 0.002 , 2 / 32 , - 14 / 32 , 16 / 32 + 0.001 } -- the horizontal wire
6
6
}
7
7
8
+ local down_rcvboxes = {
9
+ {- 6 / 16 , - 8 / 16 , - 6 / 16 , 6 / 16 , - 7 / 16 , 6 / 16 }, -- Top plate
10
+ {- 2 / 16 , - 6 / 16 , - 2 / 16 , 2 / 16 , - 7 / 16 , 2 / 16 }, -- Bump
11
+ {- 1 / 16 , - 8 / 16 , - 1 / 16 , 1 / 16 , - 24 / 16 , 1 / 16 }, -- Wire through the block
12
+ {- 1 / 16 , - 8 / 16 , 6 / 16 , 1 / 16 , - 7 / 16 , 8 / 16 }, -- Plate extension (North)
13
+ {- 1 / 16 , - 8 / 16 , - 6 / 16 , 1 / 16 , - 7 / 16 , - 8 / 16 }, -- Plate extension (South)
14
+ {- 8 / 16 , - 8 / 16 , 1 / 16 , - 6 / 16 , - 7 / 16 , - 1 / 16 }, -- Plate extension (West)
15
+ {6 / 16 , - 8 / 16 , 1 / 16 , 8 / 16 , - 7 / 16 , - 1 / 16 }, -- Plate extension (East)
16
+ }
17
+
18
+ local up_rcvboxes = {
19
+ {- 6 / 16 , - 8 / 16 , - 6 / 16 , 6 / 16 , - 7 / 16 , 6 / 16 }, -- Top plate
20
+ {- 2 / 16 , - 6 / 16 , - 2 / 16 , 2 / 16 , - 7 / 16 , 2 / 16 }, -- Bump
21
+ {- 1 / 16 , - 6 / 16 , - 1 / 16 , 1 / 16 , 24 / 16 , 1 / 16 }, -- Wire through the block
22
+ {- 1 / 16 , - 8 / 16 , 6 / 16 , 1 / 16 , - 7 / 16 , 8 / 16 }, -- Plate extension (North)
23
+ {- 1 / 16 , - 8 / 16 , - 6 / 16 , 1 / 16 , - 7 / 16 , - 8 / 16 }, -- Plate extension (South)
24
+ {- 8 / 16 , - 8 / 16 , 1 / 16 , - 6 / 16 , - 7 / 16 , - 1 / 16 }, -- Plate extension (West)
25
+ {6 / 16 , - 8 / 16 , 1 / 16 , 8 / 16 , - 7 / 16 , - 1 / 16 }, -- Plate extension (East)
26
+ }
27
+
8
28
local receiver_get_rules = function (node )
9
29
local rules = { {x = 1 , y = 0 , z = 0 },
10
30
{x = - 2 , y = 0 , z = 0 }}
@@ -18,8 +38,38 @@ local receiver_get_rules = function (node)
18
38
return rules
19
39
end
20
40
21
- minetest .register_node (" mesecons_receiver:receiver_on " , {
41
+ mesecon .register_node (" mesecons_receiver:receiver " , {
22
42
drawtype = " nodebox" ,
43
+ paramtype = " light" ,
44
+ paramtype2 = " facedir" ,
45
+ sunlight_propagates = true ,
46
+ walkable = false ,
47
+ on_rotate = false ,
48
+ selection_box = {
49
+ type = " fixed" ,
50
+ fixed = { - 3 / 16 , - 8 / 16 , - 8 / 16 , 3 / 16 , 3 / 16 , 8 / 16 }
51
+ },
52
+ node_box = {
53
+ type = " fixed" ,
54
+ fixed = rcvboxes
55
+ },
56
+ groups = {dig_immediate = 3 , not_in_creative_inventory = 1 },
57
+ drop = " mesecons:wire_00000000_off" ,
58
+ }, {
59
+ tiles = {
60
+ " receiver_top_off.png" ,
61
+ " receiver_bottom_off.png" ,
62
+ " receiver_lr_off.png" ,
63
+ " receiver_lr_off.png" ,
64
+ " receiver_fb_off.png" ,
65
+ " receiver_fb_off.png" ,
66
+ },
67
+ mesecons = {conductor = {
68
+ state = mesecon .state .off ,
69
+ rules = receiver_get_rules ,
70
+ onstate = " mesecons_receiver:receiver_on"
71
+ }}
72
+ }, {
23
73
tiles = {
24
74
" receiver_top_on.png" ,
25
75
" receiver_bottom_on.png" ,
@@ -28,83 +78,133 @@ minetest.register_node("mesecons_receiver:receiver_on", {
28
78
" receiver_fb_on.png" ,
29
79
" receiver_fb_on.png" ,
30
80
},
81
+ mesecons = {conductor = {
82
+ state = mesecon .state .on ,
83
+ rules = receiver_get_rules ,
84
+ offstate = " mesecons_receiver:receiver_off"
85
+ }}
86
+ })
87
+
88
+ mesecon .register_node (" mesecons_receiver:receiver_up" , {
89
+ drawtype = " nodebox" ,
31
90
paramtype = " light" ,
32
91
paramtype2 = " facedir" ,
33
92
sunlight_propagates = true ,
34
93
walkable = false ,
94
+ on_rotate = false ,
35
95
selection_box = {
36
96
type = " fixed" ,
37
- fixed = { - 3 / 16 , - 8 / 16 , - 8 / 16 , 3 / 16 , 3 / 16 , 8 / 16 }
97
+ fixed = up_rcvboxes
38
98
},
39
99
node_box = {
40
100
type = " fixed" ,
41
- fixed = rcvboxes
101
+ fixed = up_rcvboxes
42
102
},
43
103
groups = {dig_immediate = 3 , not_in_creative_inventory = 1 },
44
104
drop = " mesecons:wire_00000000_off" ,
105
+ }, {
106
+ tiles = {" mesecons_wire_off.png" },
107
+ mesecons = {conductor = {
108
+ state = mesecon .state .off ,
109
+ rules = {{x = 1 , y = 0 , z = 0 },
110
+ {x =- 1 , y = 0 , z = 0 },
111
+ {x = 0 , y = 0 , z = 1 },
112
+ {x = 0 , y = 0 , z =- 1 },
113
+ {x = 0 , y = 1 , z = 0 },
114
+ {x = 0 , y = 2 , z = 0 }},
115
+ onstate = " mesecons_receiver:receiver_up_on"
116
+ }}
117
+ }, {
118
+ tiles = {" mesecons_wire_on.png" },
45
119
mesecons = {conductor = {
46
120
state = mesecon .state .on ,
47
- rules = receiver_get_rules ,
48
- offstate = " mesecons_receiver:receiver_off"
121
+ rules = {{x = 1 , y = 0 , z = 0 },
122
+ {x =- 1 , y = 0 , z = 0 },
123
+ {x = 0 , y = 0 , z = 1 },
124
+ {x = 0 , y = 0 , z =- 1 },
125
+ {x = 0 , y = 1 , z = 0 },
126
+ {x = 0 , y = 2 , z = 0 }},
127
+ offstate = " mesecons_receiver:receiver_up_off"
49
128
}}
50
129
})
51
130
52
- minetest .register_node (" mesecons_receiver:receiver_off " , {
131
+ mesecon .register_node (" mesecons_receiver:receiver_down " , {
53
132
drawtype = " nodebox" ,
54
- description = " You hacker you" ,
55
- tiles = {
56
- " receiver_top_off.png" ,
57
- " receiver_bottom_off.png" ,
58
- " receiver_lr_off.png" ,
59
- " receiver_lr_off.png" ,
60
- " receiver_fb_off.png" ,
61
- " receiver_fb_off.png" ,
62
- },
63
133
paramtype = " light" ,
64
134
paramtype2 = " facedir" ,
65
135
sunlight_propagates = true ,
66
136
walkable = false ,
137
+ on_rotate = false ,
67
138
selection_box = {
68
139
type = " fixed" ,
69
- fixed = { - 3 / 16 , - 8 / 16 , - 8 / 16 , 3 / 16 , 3 / 16 , 8 / 16 }
140
+ fixed = down_rcvboxes
70
141
},
71
142
node_box = {
72
143
type = " fixed" ,
73
- fixed = rcvboxes
144
+ fixed = down_rcvboxes
74
145
},
75
146
groups = {dig_immediate = 3 , not_in_creative_inventory = 1 },
76
147
drop = " mesecons:wire_00000000_off" ,
148
+ }, {
149
+ tiles = {" mesecons_wire_off.png" },
77
150
mesecons = {conductor = {
78
151
state = mesecon .state .off ,
79
- rules = receiver_get_rules ,
80
- onstate = " mesecons_receiver:receiver_on"
152
+ rules = {{x = 1 ,y = 0 , z = 0 },
153
+ {x =- 1 ,y = 0 , z = 0 },
154
+ {x = 0 , y = 0 , z = 1 },
155
+ {x = 0 , y = 0 , z =- 1 },
156
+ {x = 0 , y =- 2 ,z = 0 }},
157
+ onstate = " mesecons_receiver:receiver_down_on"
158
+ }}
159
+ }, {
160
+ tiles = {" mesecons_wire_on.png" },
161
+ mesecons = {conductor = {
162
+ state = mesecon .state .on ,
163
+ rules = {{x = 1 ,y = 0 , z = 0 },
164
+ {x =- 1 ,y = 0 , z = 0 },
165
+ {x = 0 , y = 0 , z = 1 },
166
+ {x = 0 , y = 0 , z =- 1 },
167
+ {x = 0 , y =- 2 ,z = 0 }},
168
+ offstate = " mesecons_receiver:receiver_down_off"
81
169
}}
82
170
})
83
171
84
172
function mesecon .receiver_get_pos_from_rcpt (pos , param2 )
85
173
local rules = {{x = 2 , y = 0 , z = 0 }}
86
174
if param2 == nil then param2 = minetest .get_node (pos ).param2 end
87
- if param2 == 2 then
175
+ local rcvtype = " mesecons_receiver:receiver_off"
176
+ local dir = minetest .facedir_to_dir (param2 )
177
+
178
+ if dir .x == 1 then
179
+ -- No action needed
180
+ elseif dir .z == - 1 then
88
181
rules = mesecon .rotate_rules_left (rules )
89
- elseif param2 == 3 then
182
+ elseif dir . x == - 1 then
90
183
rules = mesecon .rotate_rules_right (mesecon .rotate_rules_right (rules ))
91
- elseif param2 == 0 then
184
+ elseif dir . z == 1 then
92
185
rules = mesecon .rotate_rules_right (rules )
186
+ elseif dir .y == - 1 then
187
+ rules = mesecon .rotate_rules_up (rules )
188
+ rcvtype = " mesecons_receiver:receiver_up_off"
189
+ elseif dir .y == 1 then
190
+ rules = mesecon .rotate_rules_down (rules )
191
+ rcvtype = " mesecons_receiver:receiver_down_off"
93
192
end
94
193
local np = { x = pos .x + rules [1 ].x ,
95
194
y = pos .y + rules [1 ].y ,
96
195
z = pos .z + rules [1 ].z }
97
- return np
196
+ return np , rcvtype
98
197
end
99
198
100
199
function mesecon .receiver_place (rcpt_pos )
101
200
local node = minetest .get_node (rcpt_pos )
102
- local pos = mesecon .receiver_get_pos_from_rcpt (rcpt_pos , node .param2 )
201
+ local pos , rcvtype = mesecon .receiver_get_pos_from_rcpt (rcpt_pos , node .param2 )
103
202
local nn = minetest .get_node (pos )
203
+ local param2 = minetest .dir_to_facedir (minetest .facedir_to_dir (node .param2 ))
104
204
105
205
if string.find (nn .name , " mesecons:wire_" ) ~= nil then
106
206
minetest .dig_node (pos )
107
- minetest .set_node (pos , {name = " mesecons_receiver:receiver_off " , param2 = node . param2 })
207
+ minetest .set_node (pos , {name = rcvtype , param2 = param2 })
108
208
mesecon .on_placenode (pos , nn )
109
209
end
110
210
end
@@ -133,11 +233,13 @@ minetest.register_on_dignode(function(pos, node)
133
233
end )
134
234
135
235
minetest .register_on_placenode (function (pos , node )
136
- if string.find (node .name , " mesecons:wire_" ) ~= nil then
137
- local rules = { {x = 2 , y = 0 , z = 0 },
138
- {x =- 2 , y = 0 , z = 0 },
139
- {x = 0 , y = 0 , z = 2 },
140
- {x = 0 , y = 0 , z =- 2 }}
236
+ if string.find (node .name , " mesecons:wire_" ) ~= nil then
237
+ local rules = { {x = 2 , y = 0 , z = 0 },
238
+ {x =- 2 , y = 0 , z = 0 },
239
+ {x = 0 , y = 0 , z = 2 },
240
+ {x = 0 , y = 0 , z =- 2 },
241
+ {x = 0 , y = 2 , z = 0 },
242
+ {x = 0 , y = - 2 , z = 0 }}
141
243
local i = 1
142
244
while rules [i ] ~= nil do
143
245
local np = { x = pos .x + rules [i ].x ,
@@ -150,3 +252,8 @@ minetest.register_on_placenode(function (pos, node)
150
252
end
151
253
end
152
254
end )
255
+
256
+ function mesecon .buttonlike_onrotate (pos , node )
257
+ minetest .after (0 , mesecon .receiver_remove , pos , node )
258
+ minetest .after (0 , mesecon .receiver_place , pos )
259
+ end
0 commit comments