diff options
author | Jeija <norrepli@gmail.com> | 2012-12-08 22:28:46 +0100 |
---|---|---|
committer | Jeija <norrepli@gmail.com> | 2012-12-08 22:28:46 +0100 |
commit | cf6080f7237af1c55a6d80bea4725dcb5c8cb1eb (patch) | |
tree | 6e858459204230ad5cc0ea2c39c10a161a738d5e /mesecons_extrawires/tjunction.lua | |
parent | 00e071b695574928fce2ca56e3e8eca6ad3d35ef (diff) |
Port more blocks to nodedef system: object detector, extrawires, water turbine, insulated wire
Diffstat (limited to 'mesecons_extrawires/tjunction.lua')
-rw-r--r-- | mesecons_extrawires/tjunction.lua | 54 |
1 files changed, 28 insertions, 26 deletions
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) |