mirror of
https://github.com/minetest-mods/mesecons.git
synced 2025-06-28 05:50:17 +02:00
Fix #155 (option 2 used). Remove non-ActionQueue system. Enable overheat for more than 20 actions per second on lua- / microcontrollers and gates.
Fix a bug where a burnt luacontroller didn't have the correct pin-states as the burnt controller does not register any changes from outside.
This commit is contained in:
@ -93,7 +93,6 @@ minetest.register_node(nodename, {
|
||||
"button[7.5,0.2;1.5,3;brsflop;RS-Flop]"..
|
||||
"button_exit[3.5,1;2,3;program;Program]")
|
||||
meta:set_string("infotext", "Unprogrammed Microcontroller")
|
||||
meta:set_int("heat", 0)
|
||||
local r = ""
|
||||
for i=1, EEPROM_SIZE+1 do r=r.."0" end --Generate a string with EEPROM_SIZE*"0"
|
||||
meta:set_string("eeprom", r)
|
||||
@ -156,7 +155,6 @@ minetest.register_craft({
|
||||
function yc_reset(pos)
|
||||
yc_action(pos, {a=false, b=false, c=false, d=false})
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_int("heat", 0)
|
||||
meta:set_int("afterid", 0)
|
||||
local r = ""
|
||||
for i=1, EEPROM_SIZE+1 do r=r.."0" end --Generate a string with EEPROM_SIZE*"0"
|
||||
@ -165,11 +163,12 @@ end
|
||||
|
||||
function update_yc(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
yc_heat(meta)
|
||||
--minetest.after(0.5, yc_cool, meta)
|
||||
if (yc_overheat(meta)) then
|
||||
|
||||
if (mesecon.do_overheat(pos)) then
|
||||
minetest.remove_node(pos)
|
||||
minetest.after(0.2, yc_overheat_off, pos) --wait for pending parsings
|
||||
minetest.after(0.2, function (pos)
|
||||
mesecon:receptor_off(pos, mesecon.rules.flat)
|
||||
end , pos) -- wait for pending parsings
|
||||
minetest.add_item(pos, "mesecons_microcontroller:microcontroller0000")
|
||||
end
|
||||
|
||||
@ -698,34 +697,3 @@ function yc_merge_portstates(Lreal, Lvirtual)
|
||||
if Lvirtual.d or Lreal.d then L.d = true end
|
||||
return L
|
||||
end
|
||||
|
||||
--"Overheat" protection
|
||||
function yc_heat(meta)
|
||||
h = meta:get_int("heat")
|
||||
if h ~= nil then
|
||||
meta:set_int("heat", h + 1)
|
||||
end
|
||||
end
|
||||
|
||||
--function yc_cool(meta)
|
||||
-- h = meta:get_int("heat")
|
||||
-- if h ~= nil then
|
||||
-- meta:set_int("heat", h - 1)
|
||||
-- end
|
||||
--end
|
||||
|
||||
function yc_overheat(meta)
|
||||
if MESECONS_GLOBALSTEP then return false end
|
||||
h = meta:get_int("heat")
|
||||
if h == nil then return true end -- if nil the overheat
|
||||
if h>60 then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
function yc_overheat_off(pos)
|
||||
rules = mesecon:get_rules("mesecons_microcontroller:microcontroller1111")
|
||||
mesecon:receptor_off(pos, rules)
|
||||
end
|
||||
|
Reference in New Issue
Block a user