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