diff options
author | Jeija <norrepli@gmail.com> | 2012-12-09 00:42:30 +0100 |
---|---|---|
committer | Jeija <norrepli@gmail.com> | 2012-12-09 00:42:30 +0100 |
commit | b37bdbf55cf6d3205d5dd7a2491a8bd855cbbd76 (patch) | |
tree | ffc05ac9f096fc635535701cd287d4e5ad6b5073 /mesecons_microcontroller/init.lua | |
parent | cf6080f7237af1c55a6d80bea4725dcb5c8cb1eb (diff) |
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)
Diffstat (limited to 'mesecons_microcontroller/init.lua')
-rw-r--r-- | mesecons_microcontroller/init.lua | 63 |
1 files changed, 32 insertions, 31 deletions
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) |