TangentFox icon

Multi-port timer v2 (for minetest luacontroller)

TangentFox | PRO | 01/30/21 09:47:50 PM UTC (Edited) | 0 ⭐ | 444 👁️ | Never ⏰ | []
Lua |

320 B

|

None

|

0 👍

/

0 👎

local seq = 2
 
if event.type == "program" then
  interrupt(seq, 0)
  mem.a = 4
  mem.b = 3
  mem.d = 1
 
elseif event.type == "interrupt" then
  for direction, timing in pairs(mem) do
    if event.iid % timing == 0 then
      port[direction] = not pin[direction]
    end
  end
  interrupt(seq, event.iid + 1)
end

Comments