summaryrefslogtreecommitdiff
path: root/wires.lua
diff options
context:
space:
mode:
Diffstat (limited to 'wires.lua')
-rw-r--r--wires.lua401
1 files changed, 0 insertions, 401 deletions
diff --git a/wires.lua b/wires.lua
deleted file mode 100644
index e09fc2a..0000000
--- a/wires.lua
+++ /dev/null
@@ -1,401 +0,0 @@
---LV cable node boxes
-
-
-minetest.register_alias("lv_cable", "technic:lv_cable")
-
-minetest.register_craft({
- output = 'technic:lv_cable 6',
- recipe = {
- {'moreores:copper_ingot', 'moreores:copper_ingot', 'moreores:copper_ingot'},
- }
-})
-
-minetest.register_craftitem("technic:lv_cable", {
- description = "Low Voltage Copper Cable",
- stack_max = 99,
-})
-
-minetest.register_node("technic:lv_cable", {
- description = "Low Voltage Copper Cable",
- tiles = {"technic_lv_cable.png"},
- inventory_image = "technic_lv_cable_wield.png",
- wield_image = "technic_lv_cable_wield.png",
- groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2},
- sounds = default.node_sound_wood_defaults(),
- drop = "technic:lv_cable",
- cablelike=1,
- rules_x1=0,
- rules_x2=0,
- rules_y1=0,
- rules_y2=0,
- rules_z1=0,
- rules_z2=0,
- paramtype = "light",
- drawtype = "nodebox",
- selection_box = {
- type = "fixed",
- fixed = {
- { -0.1 , -0.1 , -0.1 , 0.1 , 0.1 , 0.1 },
- }},
- node_box = {
- type = "fixed",
- fixed = {
- { -0.1 , -0.1 , -0.1 , 0.1 , 0.1 , 0.1 },
- }},
- on_construct = function(pos)
- meta=minetest.env:get_meta(pos)
- meta:set_float("cablelike",1)
- meta:set_float("x1",0)
- meta:set_float("x2",0)
- meta:set_float("y1",0)
- meta:set_float("y2",0)
- meta:set_float("z1",0)
- meta:set_float("z2",0)
- check_connections (pos)
- end,
-
- after_dig_node = function (pos, oldnode, oldmetadata, digger)
- check_connections_on_destroy (pos)
- end,
-
-})
-
-
-str_y1= { -0.1 , -0.1 , -0.1 , 0.1 , 0.5, 0.1 } --0 y+
-str_x1= { -0.1 , -0.1 , -0.1 , 0.5, 0.1 , 0.1 } --0 x+
-str_z1= { -0.1 , -0.1 , 0.1 , 0.1 , 0.1 , 0.5 } --0 z+
-str_z2= { -0.1 , -0.1, -0.5 , 0.1 , 0.1 , 0.1 } --0 z-
-str_y2= { -0.1 , -0.5, -0.1 , 0.1 , 0.1 , 0.1 } --0 y-
-str_x2= { -0.5 , -0.1, -0.1 , 0.1 , 0.1 , 0.1 } --0 x-
-
-
-
-local x1,x2,y1,y2,z1,z2
-local count=0
-
-for x1 = 0, 1, 1 do --x-
-for x2 = 0, 1, 1 do --x+
-for y1 = 0, 1, 1 do --y-
-for y2 = 0, 1, 1 do --y-
-for z1 = 0, 1, 1 do --z-
-for z2 = 0, 1, 1 do --z+
-
-temp_x1={} temp_x2={} temp_y1={} temp_y2={} temp_z1={} temp_z2={}
-
-if x1==1 then temp_x1=str_x1 end
-if x2==1 then temp_x2=str_x2 end
-if y1==1 then temp_y1=str_y1 end
-if y2==1 then temp_y2=str_y2 end
-if z1==1 then temp_z1=str_z1 end
-if z2==1 then temp_z2=str_z2 end
-
-
-minetest.register_node("technic:lv_cable"..count, {
- description = "Low Voltage Copper Cable",
- tiles = {"technic_lv_cable.png"},
- groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2,not_in_creative_inventory=1},
- sounds = default.node_sound_wood_defaults(),
- drop = "technic:lv_cable",
- rules_x1=0,
- rules_x2=0,
- rules_y1=0,
- rules_y2=0,
- rules_z1=0,
- rules_z2=0,
- cablelike=1,
- paramtype = "light",
- drawtype = "nodebox",
- selection_box = {
- type = "fixed",
- fixed = {
- temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
- }},
-
- node_box = {
- type = "fixed",
- fixed = {
- temp_x1,temp_x2,temp_y1,temp_y2,temp_z1,temp_z2,
- }},
-
- after_dig_node = function (pos, oldnode, oldmetadata, digger)
- check_connections_on_destroy (pos)
- end,
-
-})
-
-count=count+1 end end end end end end
-
-check_connections = function(pos)
- local pos1={}
- pos1.x=pos.x
- pos1.y=pos.y
- pos1.z=pos.z
-
- pos1.x=pos1.x+1
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- x2=1
- x1=minetest.env:get_meta(pos1):get_float("x1")
- y1=minetest.env:get_meta(pos1):get_float("y1")
- y2=minetest.env:get_meta(pos1):get_float("y2")
- z1=minetest.env:get_meta(pos1):get_float("z1")
- z2=minetest.env:get_meta(pos1):get_float("z2")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos1,"technic:lv_cable"..rule)
- meta=minetest.env:get_meta(pos1)
- meta:set_float("x2",x2)
- meta=minetest.env:get_meta(pos)
- x1=1
- x2=minetest.env:get_meta(pos):get_float("x2")
- y1=minetest.env:get_meta(pos):get_float("y1")
- y2=minetest.env:get_meta(pos):get_float("y2")
- z1=minetest.env:get_meta(pos):get_float("z1")
- z2=minetest.env:get_meta(pos):get_float("z2")
- meta:set_float("x1",x1)
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos,"technic:lv_cable"..rule)
- end
-
- pos1.x=pos1.x-2
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- x1=1
- x2=minetest.env:get_meta(pos1):get_float("x2")
- y1=minetest.env:get_meta(pos1):get_float("y1")
- y2=minetest.env:get_meta(pos1):get_float("y2")
- z1=minetest.env:get_meta(pos1):get_float("z1")
- z2=minetest.env:get_meta(pos1):get_float("z2")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos1,"technic:lv_cable"..rule)
- meta=minetest.env:get_meta(pos1)
- meta:set_float("x1",x1)
- meta=minetest.env:get_meta(pos)
- x2=1
- x1=minetest.env:get_meta(pos):get_float("x1")
- y1=minetest.env:get_meta(pos):get_float("y1")
- y2=minetest.env:get_meta(pos):get_float("y2")
- z1=minetest.env:get_meta(pos):get_float("z1")
- z2=minetest.env:get_meta(pos):get_float("z2")
- meta:set_float("x2",x2)
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos,"technic:lv_cable"..rule)
- end
-
- pos1.x=pos1.x+1
-
- pos1.y=pos1.y+1
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- y2=1
- x1=minetest.env:get_meta(pos1):get_float("x1")
- x2=minetest.env:get_meta(pos1):get_float("x2")
- y1=minetest.env:get_meta(pos1):get_float("y1")
- z1=minetest.env:get_meta(pos1):get_float("z1")
- z2=minetest.env:get_meta(pos1):get_float("z2")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos1,"technic:lv_cable"..rule)
- meta=minetest.env:get_meta(pos1)
- meta:set_float("y2",y2)
- meta=minetest.env:get_meta(pos)
- y1=1
- x1=minetest.env:get_meta(pos):get_float("x1")
- x2=minetest.env:get_meta(pos):get_float("x2")
- y2=minetest.env:get_meta(pos):get_float("y2")
- z1=minetest.env:get_meta(pos):get_float("z1")
- z2=minetest.env:get_meta(pos):get_float("z2")
- meta:set_float("y1",y1)
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos,"technic:lv_cable"..rule)
- end
-
- if minetest.env:get_meta(pos1):get_float("technic_power_machine")==1 then
- y1=1
- x1=minetest.env:get_meta(pos):get_float("x1")
- x2=minetest.env:get_meta(pos):get_float("x2")
- y2=minetest.env:get_meta(pos):get_float("y2")
- z1=minetest.env:get_meta(pos):get_float("z1")
- z2=minetest.env:get_meta(pos):get_float("z2")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos,"technic:lv_cable"..rule)
- meta=minetest.env:get_meta(pos)
- meta:set_float("y1",y1)
- end
-
-
- pos1.y=pos1.y-2
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- y1=1
- x1=minetest.env:get_meta(pos1):get_float("x1")
- x2=minetest.env:get_meta(pos1):get_float("x2")
- y2=minetest.env:get_meta(pos1):get_float("y2")
- z1=minetest.env:get_meta(pos1):get_float("z1")
- z2=minetest.env:get_meta(pos1):get_float("z2")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos1,"technic:lv_cable"..rule)
- meta=minetest.env:get_meta(pos1)
- meta:set_float("y1",y1)
- meta=minetest.env:get_meta(pos)
- y2=1
- x1=minetest.env:get_meta(pos):get_float("x1")
- x2=minetest.env:get_meta(pos):get_float("x2")
- y1=minetest.env:get_meta(pos):get_float("y1")
- z1=minetest.env:get_meta(pos):get_float("z1")
- z2=minetest.env:get_meta(pos):get_float("z2")
- meta:set_float("y2",y2)
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos,"technic:lv_cable"..rule)
- end
- pos1.y=pos1.y+1
-
- pos1.z=pos1.z+1
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- z2=1
- x1=minetest.env:get_meta(pos1):get_float("x1")
- x2=minetest.env:get_meta(pos1):get_float("x2")
- y1=minetest.env:get_meta(pos1):get_float("y1")
- y2=minetest.env:get_meta(pos1):get_float("y2")
- z1=minetest.env:get_meta(pos1):get_float("z1")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos1,"technic:lv_cable"..rule)
- meta=minetest.env:get_meta(pos1)
- meta:set_float("z2",z2)
- meta=minetest.env:get_meta(pos)
- z1=1
- x1=minetest.env:get_meta(pos):get_float("x1")
- x2=minetest.env:get_meta(pos):get_float("x2")
- y1=minetest.env:get_meta(pos):get_float("y1")
- y2=minetest.env:get_meta(pos):get_float("y2")
- z2=minetest.env:get_meta(pos):get_float("z2")
- meta:set_float("z1",z1)
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos,"technic:lv_cable"..rule)
- end
- pos1.z=pos1.z-2
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- z1=1
- x1=minetest.env:get_meta(pos1):get_float("x1")
- x2=minetest.env:get_meta(pos1):get_float("x2")
- y1=minetest.env:get_meta(pos1):get_float("y1")
- y2=minetest.env:get_meta(pos1):get_float("y2")
- z2=minetest.env:get_meta(pos1):get_float("z2")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos1,"technic:lv_cable"..rule)
- meta=minetest.env:get_meta(pos1)
- meta:set_float("z1",z1)
- meta=minetest.env:get_meta(pos)
- z2=1
- x1=minetest.env:get_meta(pos):get_float("x1")
- x2=minetest.env:get_meta(pos):get_float("x2")
- y1=minetest.env:get_meta(pos):get_float("y1")
- y2=minetest.env:get_meta(pos):get_float("y2")
- z1=minetest.env:get_meta(pos):get_float("z1")
- meta:set_float("z2",z2)
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- hacky_swap_node(pos,"technic:lv_cable"..rule)
- end
- pos1.z=pos1.z+1
-end
-
-function make_rule_number (x1,x2,y1,y2,z1,z2)
-local temp= z2+z1*2+y2*4+y1*8+x2*16+x1*32
-return temp
-end
-
-check_connections_on_destroy = function(pos)
- local pos1={}
- pos1.x=pos.x
- pos1.y=pos.y
- pos1.z=pos.z
-
- pos1.x=pos1.x+1
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- x2=0
- x1=minetest.env:get_meta(pos1):get_float("x1")
- y1=minetest.env:get_meta(pos1):get_float("y1")
- y2=minetest.env:get_meta(pos1):get_float("y2")
- z1=minetest.env:get_meta(pos1):get_float("z1")
- z2=minetest.env:get_meta(pos1):get_float("z2")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
- if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
- meta=minetest.env:get_meta(pos1)
- meta:set_float("x2",x2)
- end
-
- pos1.x=pos1.x-2
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- x1=0
- x2=minetest.env:get_meta(pos1):get_float("x2")
- y1=minetest.env:get_meta(pos1):get_float("y1")
- y2=minetest.env:get_meta(pos1):get_float("y2")
- z1=minetest.env:get_meta(pos1):get_float("z1")
- z2=minetest.env:get_meta(pos1):get_float("z2")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
- if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
- meta=minetest.env:get_meta(pos1)
- meta:set_float("x1",x1)
- end
- pos1.x=pos1.x+1
-
- pos1.y=pos1.y+1
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- y2=0
- x1=minetest.env:get_meta(pos1):get_float("x1")
- x2=minetest.env:get_meta(pos1):get_float("x2")
- y1=minetest.env:get_meta(pos1):get_float("y1")
- z1=minetest.env:get_meta(pos1):get_float("z1")
- z2=minetest.env:get_meta(pos1):get_float("z2")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
- if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
- meta=minetest.env:get_meta(pos1)
- meta:set_float("y2",y2)
- end
-
- pos1.y=pos1.y-2
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- y1=0
- x1=minetest.env:get_meta(pos1):get_float("x1")
- x2=minetest.env:get_meta(pos1):get_float("x2")
- y2=minetest.env:get_meta(pos1):get_float("y2")
- z1=minetest.env:get_meta(pos1):get_float("z1")
- z2=minetest.env:get_meta(pos1):get_float("z2")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
- if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
- meta=minetest.env:get_meta(pos1)
- meta:set_float("y1",y1)
- end
- pos1.y=pos1.y+1
-
- pos1.z=pos1.z+1
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- z2=0
- x1=minetest.env:get_meta(pos1):get_float("x1")
- x2=minetest.env:get_meta(pos1):get_float("x2")
- y1=minetest.env:get_meta(pos1):get_float("y1")
- y2=minetest.env:get_meta(pos1):get_float("y2")
- z1=minetest.env:get_meta(pos1):get_float("z1")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
- if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
- meta=minetest.env:get_meta(pos1)
- meta:set_float("z2",z2)
- end
-
- pos1.z=pos1.z-2
- if minetest.env:get_meta(pos1):get_float("cablelike")==1 then
- z1=0
- x1=minetest.env:get_meta(pos1):get_float("x1")
- x2=minetest.env:get_meta(pos1):get_float("x2")
- y1=minetest.env:get_meta(pos1):get_float("y1")
- y2=minetest.env:get_meta(pos1):get_float("y2")
- z2=minetest.env:get_meta(pos1):get_float("z2")
- rule=make_rule_number(x1,x2,y1,y2,z1,z2)
- if rule==0 then hacky_swap_node(pos1,"technic:lv_cable") end
- if rule>0 then hacky_swap_node(pos1,"technic:lv_cable"..rule) end
- meta=minetest.env:get_meta(pos1)
- meta:set_float("z1",z1)
- end
- pos1.y=pos1.y+1
-
-end
-