diff options
author | Jeija <norrepli@gmail.com> | 2012-12-11 19:49:55 +0100 |
---|---|---|
committer | Jeija <norrepli@gmail.com> | 2012-12-11 19:49:55 +0100 |
commit | de46729b971b5e59394834b8a01d4a7005318114 (patch) | |
tree | 5a2cf1f18b485ddefa8e255ac6d6a600ef2e2e12 /mesecons_extrawires | |
parent | 31f3c99288355193dc68a6e83dfc63140fd02fa0 (diff) | |
parent | 5540fcbcb31eb32003fa0391113ed3b1dea25e47 (diff) | |
download | mesecons-de46729b971b5e59394834b8a01d4a7005318114.tar mesecons-de46729b971b5e59394834b8a01d4a7005318114.tar.gz mesecons-de46729b971b5e59394834b8a01d4a7005318114.tar.bz2 mesecons-de46729b971b5e59394834b8a01d4a7005318114.tar.xz mesecons-de46729b971b5e59394834b8a01d4a7005318114.zip |
Merge branch 'mesecons_in_nodedef'
Conflicts:
mesecons/internal.lua
Diffstat (limited to 'mesecons_extrawires')
-rw-r--r-- | mesecons_extrawires/crossing.lua | 2 | ||||
-rw-r--r-- | mesecons_extrawires/init.lua | 3 | ||||
-rw-r--r-- | mesecons_extrawires/tjunction.lua | 54 |
3 files changed, 32 insertions, 27 deletions
diff --git a/mesecons_extrawires/crossing.lua b/mesecons_extrawires/crossing.lua index 9ceb9ac..53f12b2 100644 --- a/mesecons_extrawires/crossing.lua +++ b/mesecons_extrawires/crossing.lua @@ -1,3 +1,5 @@ +-- CODE NOT ACTIVE + for x=-1, 1 do for z=-1, 1 do rules = {} nodename = "mesecons_extrawires:crossing" diff --git a/mesecons_extrawires/init.lua b/mesecons_extrawires/init.lua index a8e937f..c9e0773 100644 --- a/mesecons_extrawires/init.lua +++ b/mesecons_extrawires/init.lua @@ -1,2 +1,3 @@ -dofile(minetest.get_modpath("mesecons_extrawires").."/crossing.lua"); +-- dofile(minetest.get_modpath("mesecons_extrawires").."/crossing.lua"); +-- The crossing code is not active right now because it is hard to maintain dofile(minetest.get_modpath("mesecons_extrawires").."/tjunction.lua"); diff --git a/mesecons_extrawires/tjunction.lua b/mesecons_extrawires/tjunction.lua index 93eac0a..9f0c125 100644 --- a/mesecons_extrawires/tjunction.lua +++ b/mesecons_extrawires/tjunction.lua @@ -9,6 +9,22 @@ local tjunction_selectionbox = { fixed = { -16/32-0.001, -18/32, -16/32, 16/32+0.001, -12/32, 7/32 }, } +local tjunction_get_rules = function (node) + local rules = + {{x = 1, y = 0, z = 0}, + {x =-1, y = 0, z = 0}, + {x = 0, y = 0, z = -1}} + + if node.param2 == 1 then + rules = mesecon:rotate_rules_left(rules) + elseif node.param2 == 2 then + rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules)) + elseif node.param2 == 3 then + rules = mesecon:rotate_rules_right(rules) + end + return rules +end + minetest.register_node("mesecons_extrawires:tjunction_on", { drawtype = "nodebox", tiles = { @@ -27,7 +43,12 @@ minetest.register_node("mesecons_extrawires:tjunction_on", { node_box = tjunction_nodebox, groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1, not_in_creative_inventory = 1}, drop = "mesecons_insulated:insulated_off", - + mesecons = {conductor = + { + state = mesecon.state.on, + rules = tjunction_get_rules, + offstate = "mesecons_extrawires:tjunction_off" + }} }) minetest.register_node("mesecons_extrawires:tjunction_off", { @@ -48,6 +69,12 @@ minetest.register_node("mesecons_extrawires:tjunction_off", { selection_box = tjunction_selectionbox, node_box = tjunction_nodebox, groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1}, + mesecons = {conductor = + { + state = mesecon.state.off, + rules = tjunction_get_rules, + onstate = "mesecons_extrawires:tjunction_on" + }} }) minetest.register_craft({ @@ -58,28 +85,3 @@ minetest.register_craft({ {"", "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) |