From b37bdbf55cf6d3205d5dd7a2491a8bd855cbbd76 Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 9 Dec 2012 00:42:30 +0100 Subject: Port a lot more (basically everything apart from gates, pistons and extrawire crossing) to the new nodedef system. There are some problems with wall button and wall lever (in the way they visually connect to wires) --- mesecons_microcontroller/init.lua | 63 ++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 31 deletions(-) (limited to 'mesecons_microcontroller/init.lua') diff --git a/mesecons_microcontroller/init.lua b/mesecons_microcontroller/init.lua index 121eb25..19fc42d 100644 --- a/mesecons_microcontroller/init.lua +++ b/mesecons_microcontroller/init.lua @@ -23,6 +23,33 @@ if tostring(d)..tostring(c)..tostring(b)..tostring(a) ~= "0000" then else groups = {dig_immediate=2, mesecon = 3} end +local rules={} +if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end +if (b == 1) then table.insert(rules, {x = 0, y = 0, z = 1}) end +if (c == 1) then table.insert(rules, {x = 1, y = 0, z = 0}) end +if (d == 1) then table.insert(rules, {x = 0, y = 0, z = -1}) end + +local input_rules={} +if (a == 0) then table.insert(input_rules, {x = -1, y = 0, z = 0}) end +if (b == 0) then table.insert(input_rules, {x = 0, y = 0, z = 1}) end +if (c == 0) then table.insert(input_rules, {x = 1, y = 0, z = 0}) end +if (d == 0) then table.insert(input_rules, {x = 0, y = 0, z = -1}) end +mesecon:add_rules(nodename, rules) + +local mesecons = {effector = +{ + rules = input_rules, + action_change = function (pos, node) + update_yc(pos) + end +}} +if nodename ~= "mesecons_microcontroller:microcontroller0000" then + mesecons.receptor = { + state = mesecon.state.on, + rules = rules + } +end + minetest.register_node(nodename, { description = "Microcontroller", drawtype = "nodebox", @@ -101,25 +128,12 @@ minetest.register_node(nodename, { yc_reset (pos) update_yc(pos) end, + mesecons = mesecons, + on_dig = function (pos, node) + rules = mesecon:get_rules(node.name) + mesecon:receptor_off(pos, rules) + end, }) - -local rules={} -if (a == 1) then table.insert(rules, {x = -1, y = 0, z = 0}) end -if (b == 1) then table.insert(rules, {x = 0, y = 0, z = 1}) end -if (c == 1) then table.insert(rules, {x = 1, y = 0, z = 0}) end -if (d == 1) then table.insert(rules, {x = 0, y = 0, z = -1}) end - -local input_rules={} -if (a == 0) then table.insert(input_rules, {x = -1, y = 0, z = 0}) end -if (b == 0) then table.insert(input_rules, {x = 0, y = 0, z = 1}) end -if (c == 0) then table.insert(input_rules, {x = 1, y = 0, z = 0}) end -if (d == 0) then table.insert(input_rules, {x = 0, y = 0, z = -1}) end -mesecon:add_rules(nodename, rules) - -mesecon:register_effector(nodename, nodename, input_rules) -if nodename ~= "mesecons_microcontroller:microcontroller0000" then - mesecon:add_receptor_node(nodename, rules) -end end end end @@ -682,16 +696,3 @@ function yc_overheat_off(pos) rules = mesecon:get_rules("mesecons_microcontroller:microcontroller1111") mesecon:receptor_off(pos, rules) end - -mesecon:register_on_signal_change(function(pos, node) - if string.find(node.name, "mesecons_microcontroller:microcontroller")~=nil then - update_yc(pos) - end -end) - -minetest.register_on_dignode(function(pos, node) - if string.find(node.name, "mesecons_microcontroller:microcontroller") then - rules = mesecon:get_rules(node.name) - mesecon:receptor_off(pos, rules) - end -end) -- cgit v1.2.3 From 05def1540a0defb99234bce994352a05f632f69f Mon Sep 17 00:00:00 2001 From: Jeija Date: Sun, 9 Dec 2012 15:32:29 +0100 Subject: Fix microcontroller digging --- mesecons_microcontroller/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'mesecons_microcontroller/init.lua') diff --git a/mesecons_microcontroller/init.lua b/mesecons_microcontroller/init.lua index 19fc42d..a359d05 100644 --- a/mesecons_microcontroller/init.lua +++ b/mesecons_microcontroller/init.lua @@ -129,7 +129,7 @@ minetest.register_node(nodename, { update_yc(pos) end, mesecons = mesecons, - on_dig = function (pos, node) + after_dig_node = function (pos, node) rules = mesecon:get_rules(node.name) mesecon:receptor_off(pos, rules) end, -- cgit v1.2.3