summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeija <norrepli@gmail.com>2012-09-09 13:34:21 +0200
committerJeija <norrepli@gmail.com>2012-09-09 13:34:21 +0200
commite92387695de188159b314bb12b35035da8f896ac (patch)
tree4484d9d94494e8a5ee7a6ab46822397c8aa9ca4a
parent500e95c3319536b293bd4545e54edf5a0ad39d1e (diff)
downloadmesecons-e92387695de188159b314bb12b35035da8f896ac.tar
mesecons-e92387695de188159b314bb12b35035da8f896ac.tar.gz
mesecons-e92387695de188159b314bb12b35035da8f896ac.tar.bz2
mesecons-e92387695de188159b314bb12b35035da8f896ac.tar.xz
mesecons-e92387695de188159b314bb12b35035da8f896ac.zip
Add T-junction extrawire (no good textures yet)
-rw-r--r--mesecons_extrawires/crossing.lua138
-rw-r--r--mesecons_extrawires/init.lua140
-rw-r--r--mesecons_extrawires/tjunction.lua85
-rw-r--r--mesecons_receiver/init.lua2
4 files changed, 226 insertions, 139 deletions
diff --git a/mesecons_extrawires/crossing.lua b/mesecons_extrawires/crossing.lua
new file mode 100644
index 0000000..9ceb9ac
--- /dev/null
+++ b/mesecons_extrawires/crossing.lua
@@ -0,0 +1,138 @@
+for x=-1, 1 do for z=-1, 1 do
+ rules = {}
+ nodename = "mesecons_extrawires:crossing"
+ if x == -1 then
+ nodename = nodename .. "A"
+ table.insert(rules, {x=-1, y=0, z=0})
+ end
+ if z == 1 then
+ nodename = nodename .. "B"
+ table.insert(rules, {x=0, y=0, z=1})
+ end
+ if x == 1 then
+ nodename = nodename .. "C"
+ table.insert(rules, {x=1, y=0, z=0})
+ end
+ if z == -1 then
+ nodename = nodename .. "D"
+ table.insert(rules, {x=0, y=0, z=-1})
+ end
+ mesecon:add_rules(nodename, rules)
+ mesecon:register_effector(nodename, nodename, all_rules)
+ if nodename == "mesecons_extrawires:crossing" then
+ description = "Insulated Crossing"
+ groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1}
+ else
+ description = "You hacker you!"
+ drop = "mesecons_extrawires:crossing"
+ groups = {dig_immediate = 3, not_in_creative_inventory=1, mesecon = 3}
+ mesecon:add_receptor_node(nodename, rules)
+ end
+ minetest.register_node(nodename, {
+ drawtype = "nodebox",
+ description = description,
+ tiles = {
+ "jeija_insulated_wire_sides.png",
+ },
+ paramtype = "light",
+ walkable = false,
+ stack_max = 99,
+ selection_box = {
+ type = "fixed",
+ fixed = { -16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001 },
+ },
+ node_box = {
+ type = "fixed",
+ fixed = {
+ { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
+ { -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
+ { -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
+ { -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
+ { -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
+ { -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
+ },
+ },
+ groups = groups,
+ drop = drop,
+ })
+end end
+
+function receptor_set(pos, rules, on)
+ if on then
+ mesecon:receptor_on(pos, rules)
+ else
+ mesecon:receptor_off(pos, rules)
+ end
+end
+
+function update_plus(pos, name)
+ vL = {
+ a = string.find(name, "A")~=nil,
+ b = string.find(name, "B")~=nil,
+ c = string.find(name, "C")~=nil,
+ d = string.find(name, "D")~=nil,
+ }
+ rL = yc_get_real_portstates(pos)
+ L = {
+ a = rL.c and not vL.c,
+ b = rL.d and not vL.d,
+ c = rL.a and not vL.a,
+ d = rL.b and not vL.b,
+ }
+ newname = "mesecons_extrawires:crossing"
+ if L.a then newname = newname .. "A" end
+ if L.b then newname = newname .. "B" end
+ if L.c then newname = newname .. "C" end
+ if L.d then newname = newname .. "D" end
+ if newname ~= name then
+ minetest.env:add_node(pos, {name = newname})
+ end
+ if L.a ~= vL.a then
+ receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingA"), L.a)
+ if not L.a and yc_get_real_portstates(pos).a then
+ --catch signal changing direction while on
+ update_plus(pos, newname)
+ end
+ end
+ if L.b ~= vL.b then
+ receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingB"), L.b)
+ if not L.b and yc_get_real_portstates(pos).b then
+ update_plus(pos, newname)
+ end
+ end
+ if L.c ~= vL.c then
+ receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingC"), L.c)
+ if not L.c and yc_get_real_portstates(pos).c then
+ update_plus(pos, newname)
+ end
+ end
+ if L.d ~= vL.d then
+ receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingD"), L.d)
+ if not L.c and yc_get_real_portstates(pos).d then
+ update_plus(pos, newname)
+ end
+ end
+end
+
+mesecon:register_on_signal_change(function(pos, node)
+ if string.find(node.name, "mesecons_extrawires:crossing")~=nil then
+ update_plus(pos, node.name)
+ end
+end)
+
+minetest.register_craft({
+ type = "shapeless",
+ output = "mesecons_extrawires:crossing",
+ recipe = {
+ "mesecons_insulated:insulated_off",
+ "mesecons_insulated:insulated_off",
+ },
+})
+
+minetest.register_craft({
+ type = "shapeless",
+ output = "mesecons_insulated:insulated_off 2",
+ recipe = {
+ "mesecons_extrawires:crossing",
+ },
+})
diff --git a/mesecons_extrawires/init.lua b/mesecons_extrawires/init.lua
index 9ceb9ac..a8e937f 100644
--- a/mesecons_extrawires/init.lua
+++ b/mesecons_extrawires/init.lua
@@ -1,138 +1,2 @@
-for x=-1, 1 do for z=-1, 1 do
- rules = {}
- nodename = "mesecons_extrawires:crossing"
- if x == -1 then
- nodename = nodename .. "A"
- table.insert(rules, {x=-1, y=0, z=0})
- end
- if z == 1 then
- nodename = nodename .. "B"
- table.insert(rules, {x=0, y=0, z=1})
- end
- if x == 1 then
- nodename = nodename .. "C"
- table.insert(rules, {x=1, y=0, z=0})
- end
- if z == -1 then
- nodename = nodename .. "D"
- table.insert(rules, {x=0, y=0, z=-1})
- end
- mesecon:add_rules(nodename, rules)
- mesecon:register_effector(nodename, nodename, all_rules)
- if nodename == "mesecons_extrawires:crossing" then
- description = "Insulated Crossing"
- groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1}
- else
- description = "You hacker you!"
- drop = "mesecons_extrawires:crossing"
- groups = {dig_immediate = 3, not_in_creative_inventory=1, mesecon = 3}
- mesecon:add_receptor_node(nodename, rules)
- end
- minetest.register_node(nodename, {
- drawtype = "nodebox",
- description = description,
- tiles = {
- "jeija_insulated_wire_sides.png",
- },
- paramtype = "light",
- walkable = false,
- stack_max = 99,
- selection_box = {
- type = "fixed",
- fixed = { -16/32-0.0001, -18/32, -16/32-0.001, 16/32+0.001, -5/32, 16/32+0.001 },
- },
- node_box = {
- type = "fixed",
- fixed = {
- { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
- { -3/32, -17/32, -16/32-0.001, 3/32, -13/32, -6/32 },
- { -3/32, -13/32, -9/32, 3/32, -6/32, -6/32 },
- { -3/32, -9/32, -9/32, 3/32, -6/32, 9/32 },
- { -3/32, -13/32, 6/32, 3/32, -6/32, 9/32 },
- { -3/32, -17/32, 6/32, 3/32, -13/32, 16/32+0.001 },
- },
- },
- groups = groups,
- drop = drop,
- })
-end end
-
-function receptor_set(pos, rules, on)
- if on then
- mesecon:receptor_on(pos, rules)
- else
- mesecon:receptor_off(pos, rules)
- end
-end
-
-function update_plus(pos, name)
- vL = {
- a = string.find(name, "A")~=nil,
- b = string.find(name, "B")~=nil,
- c = string.find(name, "C")~=nil,
- d = string.find(name, "D")~=nil,
- }
- rL = yc_get_real_portstates(pos)
- L = {
- a = rL.c and not vL.c,
- b = rL.d and not vL.d,
- c = rL.a and not vL.a,
- d = rL.b and not vL.b,
- }
- newname = "mesecons_extrawires:crossing"
- if L.a then newname = newname .. "A" end
- if L.b then newname = newname .. "B" end
- if L.c then newname = newname .. "C" end
- if L.d then newname = newname .. "D" end
- if newname ~= name then
- minetest.env:add_node(pos, {name = newname})
- end
- if L.a ~= vL.a then
- receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingA"), L.a)
- if not L.a and yc_get_real_portstates(pos).a then
- --catch signal changing direction while on
- update_plus(pos, newname)
- end
- end
- if L.b ~= vL.b then
- receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingB"), L.b)
- if not L.b and yc_get_real_portstates(pos).b then
- update_plus(pos, newname)
- end
- end
- if L.c ~= vL.c then
- receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingC"), L.c)
- if not L.c and yc_get_real_portstates(pos).c then
- update_plus(pos, newname)
- end
- end
- if L.d ~= vL.d then
- receptor_set(pos, mesecon:get_rules("mesecons_extrawires:crossingD"), L.d)
- if not L.c and yc_get_real_portstates(pos).d then
- update_plus(pos, newname)
- end
- end
-end
-
-mesecon:register_on_signal_change(function(pos, node)
- if string.find(node.name, "mesecons_extrawires:crossing")~=nil then
- update_plus(pos, node.name)
- end
-end)
-
-minetest.register_craft({
- type = "shapeless",
- output = "mesecons_extrawires:crossing",
- recipe = {
- "mesecons_insulated:insulated_off",
- "mesecons_insulated:insulated_off",
- },
-})
-
-minetest.register_craft({
- type = "shapeless",
- output = "mesecons_insulated:insulated_off 2",
- recipe = {
- "mesecons_extrawires:crossing",
- },
-})
+dofile(minetest.get_modpath("mesecons_extrawires").."/crossing.lua");
+dofile(minetest.get_modpath("mesecons_extrawires").."/tjunction.lua");
diff --git a/mesecons_extrawires/tjunction.lua b/mesecons_extrawires/tjunction.lua
new file mode 100644
index 0000000..80a7261
--- /dev/null
+++ b/mesecons_extrawires/tjunction.lua
@@ -0,0 +1,85 @@
+local tjunction_nodebox = {
+ type = "fixed",
+ fixed = {{ -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 },
+ { -3/32, -17/32, -16/32+0.001, 3/32, -13/32, -3/32},}
+}
+
+local tjunction_selectionbox = {
+ type = "fixed",
+ fixed = { -16/32-0.001, -18/32, -16/32, 16/32+0.001, -12/32, 7/32 }
+},
+
+minetest.register_node("mesecons_extrawires:tjunction_on", {
+ drawtype = "nodebox",
+ tiles = {
+ "jeija_insulated_wire_sides.png",
+ "jeija_insulated_wire_sides.png",
+ "jeija_insulated_wire_ends_on.png",
+ "jeija_insulated_wire_ends_on.png",
+ "jeija_insulated_wire_sides.png",
+ "jeija_insulated_wire_ends_on.png"
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ walkable = false,
+ sunlight_propagates = true,
+ selection_box = tjunction_selectionbox,
+ node_box = tjunction_nodebox,
+ groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1, not_in_creative_inventory = 1},
+ drop = "mesecons_insulated:insulated_off",
+
+})
+
+minetest.register_node("mesecons_extrawires:tjunction_off", {
+ drawtype = "nodebox",
+ description = "T-junction",
+ tiles = {
+ "jeija_insulated_wire_sides.png",
+ "jeija_insulated_wire_sides.png",
+ "jeija_insulated_wire_ends_off.png",
+ "jeija_insulated_wire_ends_off.png",
+ "jeija_insulated_wire_sides.png",
+ "jeija_insulated_wire_ends_off.png"
+ },
+ paramtype = "light",
+ paramtype2 = "facedir",
+ walkable = false,
+ sunlight_propagates = true,
+ selection_box = tjunction_selectionbox,
+ node_box = tjunction_nodebox,
+ groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1},
+})
+
+minetest.register_craft({
+ output = '"mesecons_extrawires:tjunction_off" 3',
+ recipe = {
+ {"", "", ""},
+ {"mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off", "mesecons_insulated:insulated_off"},
+ {"", "mesecons_insulated:insulated_off", ""},
+ }
+})
+
+mesecon:add_rules("tjunction_all", { --all possible rules
+{x = 1, y = 0, z = 0},
+{x =-1, y = 0, z = 0},
+{x = 0, y = 0, z = 1},
+{x = 0, y = 0, z =-1},})
+
+mesecon:add_rules("tjunction", {
+{x = 1, y = 0, z = 0},
+{x =-1, y = 0, z = 0},
+{x = 0, y = 0, z = -1},})
+
+function tjunction_get_rules(param2)
+ local rules = mesecon:get_rules("tjunction")
+ if param2 == 1 then
+ rules = mesecon:rotate_rules_left(mesecon:get_rules("tjunction"))
+ elseif param2 == 2 then
+ rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(mesecon:get_rules("tjunction")))
+ elseif param2 == 3 then
+ rules = mesecon:rotate_rules_right(mesecon:get_rules("tjunction"))
+ end
+ return rules
+end
+
+mesecon:register_conductor("mesecons_extrawires:tjunction_on", "mesecons_extrawires:tjunction_off", mesecon:get_rules("tjunction_all"), tjunction_get_rules)
diff --git a/mesecons_receiver/init.lua b/mesecons_receiver/init.lua
index c364682..e67b980 100644
--- a/mesecons_receiver/init.lua
+++ b/mesecons_receiver/init.lua
@@ -53,7 +53,7 @@ minetest.register_node("mesecons_receiver:receiver_off", {
type = "fixed",
fixed = rcvboxes
},
- groups = {dig_immediate = 3, mesecon = 3},
+ groups = {dig_immediate = 3, mesecon = 3, not_in_creative_inventory = 1},
drop = "mesecons:wire_00000000_off",
})