Fix Microcontroller bug in a different way, define offstate ports as inputs only

This commit is contained in:
Jeija 2012-09-09 13:07:59 +02:00
parent f0e3b13f3f
commit 500e95c331

@ -1,9 +1,3 @@
mesecon:add_rules("microcontroller_all", { --flat rules (looks better with nodebox wires connection)
{x = 1, y = 0, z = 0 },
{x = 0, y = 0, z = 1 },
{x = -1, y = 0, z = 0},
{x = 0, y = 0, z = -1}})
EEPROM_SIZE = 255 EEPROM_SIZE = 255
for a = 0, 1 do for a = 0, 1 do
@ -72,7 +66,6 @@ minetest.register_node(nodename, {
"button_exit[3.5,1;2,3;program;Program]") "button_exit[3.5,1;2,3;program;Program]")
meta:set_string("infotext", "Unprogrammed Microcontroller") meta:set_string("infotext", "Unprogrammed Microcontroller")
meta:set_int("heat", 0) meta:set_int("heat", 0)
meta:set_int("working", 0)
local r = "" local r = ""
for i=1, EEPROM_SIZE+1 do r=r.."0" end --Generate a string with EEPROM_SIZE*"0" for i=1, EEPROM_SIZE+1 do r=r.."0" end --Generate a string with EEPROM_SIZE*"0"
meta:set_string("eeprom", r) meta:set_string("eeprom", r)
@ -115,9 +108,15 @@ 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 (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 (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 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:add_rules(nodename, rules)
mesecon:register_effector(nodename, nodename, mesecon:get_rules("microcontroller_all")) mesecon:register_effector(nodename, nodename, input_rules)
if nodename ~= "mesecons_microcontroller:microcontroller0000" then if nodename ~= "mesecons_microcontroller:microcontroller0000" then
mesecon:add_receptor_node(nodename, rules) mesecon:add_receptor_node(nodename, rules)
end end
@ -183,8 +182,6 @@ end
function yc_parsecode(code, pos) function yc_parsecode(code, pos)
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
if meta:get_int("working") == 1 then return false end
meta:set_int("working", 1)
local endi = 1 local endi = 1
local Lreal = yc_get_real_portstates(pos) local Lreal = yc_get_real_portstates(pos)
local Lvirtual = yc_get_virtual_portstates(pos) local Lvirtual = yc_get_virtual_portstates(pos)
@ -235,7 +232,6 @@ function yc_parsecode(code, pos)
minetest.env:get_meta(pos):set_string("eeprom", eeprom) end minetest.env:get_meta(pos):set_string("eeprom", eeprom) end
end end
yc_action(pos, Lvirtual) yc_action(pos, Lvirtual)
minetest.env:get_meta(pos):set_int("working", 0)
return true return true
end end