Sdzen Boco
2012-12-22 eea96621e8cb558ad58c4afb46502d183438b9da
commit | author | age
67425a 1
MK 2 minetest.register_craft({
3     type = "shapeless",
4     output = 'technic:constructor_mk1_off 1',
5     recipe = {'technic:nodebreaker_off', 'technic:deployer_off'},
6
7 })
8 minetest.register_craft({
9     type = "shapeless",
10     output = 'technic:constructor_mk2_off 1',
11     recipe = {'technic:constructor_mk1_off', 'technic:constructor_mk1_off'},
12
13 })
14
15 minetest.register_craft({
16     type = "shapeless",
17     output = 'technic:constructor_mk3_off 1',
18     recipe = {'technic:constructor_mk2_off', 'technic:constructor_mk2_off'},
19
20 })
21
22 minetest.register_node("technic:constructor_mk1_off", {
23     description = "Constructor MK1",
24     tile_images = {"technic_constructor_mk1_top_off.png","technic_constructor_mk1_bottom_off.png","technic_constructor_mk1_side2_off.png","technic_constructor_mk1_side1_off.png",
25             "technic_constructor_back.png","technic_constructor_front_off.png"},
26     is_ground_content = true,
27     paramtype2 = "facedir",
28     groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2},
29     sounds = default.node_sound_stone_defaults(),
30     on_construct = function(pos)
31     local meta = minetest.env:get_meta(pos)
32     meta:set_string("formspec",
33                 "invsize[8,9;]"..
34                 "label[0,0;Constructor MK1]"..
35                 "label[5,0;Slot 1]"..
36                 "list[current_name;slot1;6,0;1,1;]"..
37                 "list[current_player;main;0,5;8,4;]")
38         meta:set_string("infotext", "Constructor MK1")
39         local inv = meta:get_inventory()
40         inv:set_size("slot1", 1)
41     end,
42
43     can_dig = function(pos,player)
44         local meta = minetest.env:get_meta(pos)
45         local inv = meta:get_inventory()
46         return inv:is_empty("slot1")
47     end,    
48 })
49
50 minetest.register_node("technic:constructor_mk1_on", {
51     description = "Constructor MK1",
52     tile_images = {"technic_constructor_mk1_top_on.png","technic_constructor_mk1_bottom_on.png","technic_constructor_mk1_side2_on.png","technic_constructor_mk1_side1_on.png",
53             "technic_constructor_back.png","technic_constructor_front_on.png"},
54     is_ground_content = true,
55     paramtype2 = "facedir",
56     groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2,not_in_creative_inventory=1},
57     sounds = default.node_sound_stone_defaults(),
58 })
59
60 mesecon:register_on_signal_on(function(pos, node)
61     local meta = minetest.env:get_meta(pos)
62     local inv = meta:get_inventory()
63     local pos1={}
64     pos1.x=pos.x
65     pos1.y=pos.y
66     pos1.z=pos.z
67     if node.param2==3 then pos1.x=pos1.x+1 end
68     if node.param2==2 then pos1.z=pos1.z+1 end
69     if node.param2==1 then pos1.x=pos1.x-1 end
70     if node.param2==0 then pos1.z=pos1.z-1 end
71
72     if node.name == "technic:constructor_mk1_off" then
73         hacky_swap_node(pos,"technic:constructor_mk1_on")
74         nodeupdate(pos)
75         local node1=minetest.env:get_node(pos1)
76         deploy_node (inv,"slot1",pos1,node1,node)
77     end
78
79 end)
80
81 mesecon:register_on_signal_off(function(pos, node)
82     if node.name == "technic:constructor_mk1_on" then
83         hacky_swap_node(pos,"technic:constructor_mk1_off")
84         nodeupdate(pos)
85     end
86 end)
87
88 mesecon:register_effector("technic:constructor_mk1_on", "technic:constructor_mk1_off")
89
90 minetest.register_node("technic:constructor_mk2_off", {
91     description = "Constructor MK2",
92     tile_images = {"technic_constructor_mk2_top_off.png","technic_constructor_mk2_bottom_off.png","technic_constructor_mk2_side2_off.png","technic_constructor_mk2_side1_off.png",
93             "technic_constructor_back.png","technic_constructor_front_off.png"},
94     is_ground_content = true,
95     paramtype2 = "facedir",
96     groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2},
97     sounds = default.node_sound_stone_defaults(),
98     on_construct = function(pos)
99     local meta = minetest.env:get_meta(pos)
100     meta:set_string("formspec",
101                 "invsize[8,9;]"..
102                 "label[0,0;Constructor MK2]"..
103                 "label[5,0;Slot 1]"..
104                 "list[current_name;slot1;6,0;1,1;]"..
105                 "label[5,1;Slot 2]"..
106                 "list[current_name;slot2;6,1;1,1;]"..
107                 "list[current_player;main;0,5;8,4;]")
108         meta:set_string("infotext", "Constructor MK2")
109         local inv = meta:get_inventory()
110         inv:set_size("slot1", 1)
111         inv:set_size("slot2", 1)
112     end,
113
114     can_dig = function(pos,player)
115         local meta = minetest.env:get_meta(pos)
116         local inv = meta:get_inventory()
117         if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false then return false end
118         return true
119     end,    
120 })
121
122 minetest.register_node("technic:constructor_mk2_on", {
123     description = "Constructor MK2",
124     tile_images = {"technic_constructor_mk2_top_on.png","technic_constructor_mk2_bottom_on.png","technic_constructor_mk2_side2_on.png","technic_constructor_mk2_side1_on.png",
125             "technic_constructor_back.png","technic_constructor_front_on.png"},
126     is_ground_content = true,
127     paramtype2 = "facedir",
128     groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2,not_in_creative_inventory=1},
129     sounds = default.node_sound_stone_defaults(),
130 })
131
132 mesecon:register_on_signal_on(function(pos, node)
133     local meta = minetest.env:get_meta(pos)
134     local inv = meta:get_inventory()
135     local pos1={}
136     local pos2={}
137     pos1.x=pos.x
138     pos1.y=pos.y
139     pos1.z=pos.z
140     pos2.x=pos.x
141     pos2.y=pos.y
142     pos2.z=pos.z
143     if node.param2==3 then pos1.x=pos1.x+1 pos2.x=pos2.x+2 end
144     if node.param2==2 then pos1.z=pos1.z+1 pos2.z=pos2.z+2 end
145     if node.param2==1 then pos1.x=pos1.x-1 pos2.x=pos2.x-2 end
146     if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 end
147
148     if node.name == "technic:constructor_mk2_off" then
149         hacky_swap_node(pos,"technic:constructor_mk2_on")
150         nodeupdate(pos)
151         local node1=minetest.env:get_node(pos1)
152         deploy_node (inv,"slot1",pos1,node1,node)
153         local node1=minetest.env:get_node(pos2)    
154         deploy_node (inv,"slot2",pos2,node1,node)
155     end
156
157 end)
158
159
160 mesecon:register_on_signal_off(function(pos, node)
161     if node.name == "technic:constructor_mk2_on" then
162         hacky_swap_node(pos,"technic:constructor_mk2_off")
163         nodeupdate(pos)
164     end
165 end)
166
167 mesecon:register_effector("technic:constructor_mk2_on", "technic:constructor_mk2_off")
168
169 minetest.register_node("technic:constructor_mk3_off", {
170     description = "Constructor MK3",
171     tile_images = {"technic_constructor_mk3_top_off.png","technic_constructor_mk3_bottom_off.png","technic_constructor_mk3_side2_off.png","technic_constructor_mk3_side1_off.png",
172             "technic_constructor_back.png","technic_constructor_front_off.png"},
173     is_ground_content = true,
174     paramtype2 = "facedir",
175     groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2},
176     sounds = default.node_sound_stone_defaults(),
177     on_construct = function(pos)
178     local meta = minetest.env:get_meta(pos)
179     meta:set_string("formspec",
180                 "invsize[8,9;]"..
181                 "label[0,0;Constructor MK2]"..
182                 "label[5,0;Slot 1]"..
183                 "list[current_name;slot1;6,0;1,1;]"..
184                 "label[5,1;Slot 2]"..
185                 "list[current_name;slot2;6,1;1,1;]"..
186                 "label[5,2;Slot 3]"..
187                 "list[current_name;slot3;6,2;1,1;]"..
188                 "label[5,3;Slot 4]"..
189                 "list[current_name;slot4;6,3;1,1;]"..
190                 "list[current_player;main;0,5;8,4;]")
191         meta:set_string("infotext", "Constructor MK3")
192         local inv = meta:get_inventory()
193         inv:set_size("slot1", 1)
194         inv:set_size("slot2", 1)
195         inv:set_size("slot3", 1)
196         inv:set_size("slot4", 1)
197
198     end,
199
200     can_dig = function(pos,player)
201         local meta = minetest.env:get_meta(pos)
202         local inv = meta:get_inventory()
203         if inv:is_empty("slot1")==false or inv:is_empty("slot2")==false or inv:is_empty("slot3")==false or inv:is_empty("slot4")==false then return false end
204         return true
205     end,    
206 })
207
208 minetest.register_node("technic:constructor_mk3_on", {
209     description = "Constructor MK3",
210     tile_images = {"technic_constructor_mk3_top_on.png","technic_constructor_mk3_bottom_on.png","technic_constructor_mk3_side2_on.png","technic_constructor_mk3_side1_on.png",
211             "technic_constructor_back.png","technic_constructor_front_on.png"},
212     is_ground_content = true,
213     paramtype2 = "facedir",
214     groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon_receptor_off = 1, mesecon_effector_off = 1, mesecon = 2,not_in_creative_inventory=1},
215     sounds = default.node_sound_stone_defaults(),
216 })
217
218 mesecon:register_on_signal_on(function(pos, node)
219     local meta = minetest.env:get_meta(pos)
220     local inv = meta:get_inventory()
221     
222     local pos1={}
223     local pos2={}
224     local pos3={}
225     local pos4={}
226     
227     pos1.x=pos.x
228     pos1.y=pos.y
229     pos1.z=pos.z
230     
231     pos2.x=pos.x
232     pos2.y=pos.y
233     pos2.z=pos.z
234     
235     pos3.x=pos.x
236     pos3.y=pos.y
237     pos3.z=pos.z
238
239     pos4.x=pos.x
240     pos4.y=pos.y
241     pos4.z=pos.z
242
243     if node.param2==3 then pos1.x=pos1.x+1 pos2.x=pos2.x+2 pos3.x=pos3.x+3 pos4.x=pos4.x+4 end
244     if node.param2==2 then pos1.z=pos1.z+1 pos2.z=pos2.z+2 pos3.z=pos3.z+3 pos4.z=pos4.z+4 end
245     if node.param2==1 then pos1.x=pos1.x-1 pos2.x=pos2.x-2 pos3.x=pos3.x-3 pos4.x=pos4.x-4 end
246     if node.param2==0 then pos1.z=pos1.z-1 pos2.z=pos2.z-2 pos3.z=pos3.z-3 pos4.z=pos4.z-4 end
247
248     if node.name == "technic:constructor_mk3_off" then
249         hacky_swap_node(pos,"technic:constructor_mk3_on")
250         nodeupdate(pos)
251         local node1=minetest.env:get_node(pos1)
252         deploy_node (inv,"slot1",pos1,node1,node)
253         local node1=minetest.env:get_node(pos2)    
254         deploy_node (inv,"slot2",pos2,node1,node)
255         local node1=minetest.env:get_node(pos3)    
256         deploy_node (inv,"slot3",pos3,node1,node)
257         local node1=minetest.env:get_node(pos4)    
258         deploy_node (inv,"slot4",pos4,node1,node)
259     end
260
261 end)
262
263
264 mesecon:register_on_signal_off(function(pos, node)
265     if node.name == "technic:constructor_mk3_on" then
266         hacky_swap_node(pos,"technic:constructor_mk3_off")
267         nodeupdate(pos)
268     end
269 end)
270
271 mesecon:register_effector("technic:constructor_mk3_on", "technic:constructor_mk3_off")
272
273
274 deploy_node =function (inv, slot_name, pos1, node1, node)
275 if node1.name == "air" then 
276             if not inv:is_empty(slot_name) then
277             stack1=inv:get_list(slot_name)
278             node_to_be_placed={name=stack1[1]:get_name(), param1=0, param2=node.param2}
279             minetest.env:set_node(pos1,node_to_be_placed)
280             stack1[1]:take_item()
281             inv:set_stack(slot_name, 1, stack1[1])
282             return
283             end
284         return 
285         end
286         if node1.name == "ignore" or
287            node1.name == "default:lava_source" or
288            node1.name == "default:lava_flowing" or    
289            node1.name == "default:water_source" or
290            node1.name == "default:water_flowing" 
291            then return end
292         if inv:room_for_item(slot_name,node1) then    
293             inv:add_item(slot_name,node1)
294             minetest.env:remove_node(pos1)
295         end
296
297 end