From 194155fff8e848750dc716fd920045b3c340310d Mon Sep 17 00:00:00 2001 From: Jeija Date: Sat, 22 Nov 2014 11:37:47 +0100 Subject: Rewrite mesecon wires. This should increase the efficiency and speed of large machines. It also makes the wires.lua code easier to understand and more maintainable. In case any other mod depends on mesecon:update_autoconnect, please update it to use mesecon.update_autoconnect. This should also fix some other minor bugs. Please report bugs if this commit creates new ones. This commit changes wire looks and removes some unneccesary textures. --- mesecons_microcontroller/init.lua | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'mesecons_microcontroller') diff --git a/mesecons_microcontroller/init.lua b/mesecons_microcontroller/init.lua index 8c9f3b8..9883b85 100644 --- a/mesecons_microcontroller/init.lua +++ b/mesecons_microcontroller/init.lua @@ -1,5 +1,7 @@ EEPROM_SIZE = 255 +local microc_rules = {} + for a = 0, 1 do for b = 0, 1 do for c = 0, 1 do @@ -34,7 +36,7 @@ if (a == 0) then table.insert(input_rules, {x = -1, y = 0, z = 0, name = "A"}) if (b == 0) then table.insert(input_rules, {x = 0, y = 0, z = 1, name = "B"}) end if (c == 0) then table.insert(input_rules, {x = 1, y = 0, z = 0, name = "C"}) end if (d == 0) then table.insert(input_rules, {x = 0, y = 0, z = -1, name = "D"}) end -mesecon:add_rules(nodename, rules) +microc_rules[nodename] = rules local mesecons = {effector = { @@ -131,7 +133,7 @@ minetest.register_node(nodename, { sounds = default.node_sound_stone_defaults(), mesecons = mesecons, after_dig_node = function (pos, node) - rules = mesecon:get_rules(node.name) + rules = microc_rules[node.name] mesecon:receptor_off(pos, rules) end, }) @@ -600,22 +602,22 @@ function yc_action_setports(pos, L, Lv) local name = "mesecons_microcontroller:microcontroller" local rules if Lv.a ~= L.a then - rules = mesecon:get_rules(name.."0001") + rules = microc_rules[name.."0001"] if L.a == true then mesecon:receptor_on(pos, rules) else mesecon:receptor_off(pos, rules) end end if Lv.b ~= L.b then - rules = mesecon:get_rules(name.."0010") + rules = microc_rules[name.."0010"] if L.b == true then mesecon:receptor_on(pos, rules) else mesecon:receptor_off(pos, rules) end end if Lv.c ~= L.c then - rules = mesecon:get_rules(name.."0100") + rules = microc_rules[name.."0100"] if L.c == true then mesecon:receptor_on(pos, rules) else mesecon:receptor_off(pos, rules) end end if Lv.d ~= L.d then - rules = mesecon:get_rules(name.."1000") + rules = microc_rules[name.."1000"] if L.d == true then mesecon:receptor_on(pos, rules) else mesecon:receptor_off(pos, rules) end end -- cgit v1.2.3