From cf6080f7237af1c55a6d80bea4725dcb5c8cb1eb Mon Sep 17 00:00:00 2001 From: Jeija Date: Sat, 8 Dec 2012 22:28:46 +0100 Subject: Port more blocks to nodedef system: object detector, extrawires, water turbine, insulated wire --- mesecons_insulated/init.lua | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'mesecons_insulated/init.lua') diff --git a/mesecons_insulated/init.lua b/mesecons_insulated/init.lua index 5b48716..fe929d6 100644 --- a/mesecons_insulated/init.lua +++ b/mesecons_insulated/init.lua @@ -21,9 +21,13 @@ minetest.register_node("mesecons_insulated:insulated_on", { type = "fixed", fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 } }, - groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1, not_in_creative_inventory = 1}, + groups = {dig_immediate = 3, not_in_creative_inventory = 1}, drop = "mesecons_insulated:insulated_off", - + mesecons = {conductor = { + state = mesecon.state.on, + offstate = "mesecons_insulated:insulated_off", + rules = insulated_wire_get_rules + }} }) minetest.register_node("mesecons_insulated:insulated_off", { @@ -49,7 +53,12 @@ minetest.register_node("mesecons_insulated:insulated_off", { type = "fixed", fixed = { -16/32-0.001, -17/32, -3/32, 16/32+0.001, -13/32, 3/32 } }, - groups = {dig_immediate = 3, mesecon = 3, mesecon_conductor_craftable=1}, + groups = {dig_immediate = 3}, + mesecons = {conductor = { + state = mesecon.state.off, + onstate = "mesecons_insulated:insulated_on", + rules = insulated_wire_get_rules + }} }) minetest.register_craft({ @@ -61,21 +70,15 @@ minetest.register_craft({ } }) -mesecon:add_rules("insulated_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("insulated", { {x = 1, y = 0, z = 0}, -{x =-1, y = 0, z = 0},}) +{x =-1, y = 0, z = 0}}) -function insulated_wire_get_rules(param2) +function insulated_wire_get_rules(node) + local rules = {{x = 1, y = 0, z = 0}, + {x =-1, y = 0, z = 0}} if param2 == 1 or param2 == 3 then - return mesecon:rotate_rules_right(mesecon:get_rules("insulated")) + return mesecon:rotate_rules_right(rules) end - return mesecon:get_rules("insulated") + return rules end - -mesecon:register_conductor("mesecons_insulated:insulated_on", "mesecons_insulated:insulated_off", mesecon:get_rules("insulated_all"), insulated_wire_get_rules) -- cgit v1.2.3