Advertisement
TangentFox

Multi-port timer (for minetest luacontroller)

Apr 29th, 2019
276
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.45 KB | None | 0 0
  1. if event.type == "program" then
  2.   mem.a = 1 -- export loop
  3.   mem.b = 50 -- grind loop
  4.   -- mem.c = 100 -- don't remember what this was, but obviously I disabled it
  5.   mem.c = nil
  6.   mem.d = 20 -- smelt loop
  7. elseif event.type == "interrupt" then
  8.   for name, timing in pairs(mem) do
  9.     if event.iid % timing == 0 then
  10.       port[name] = not pin[name]
  11.     else
  12.       port[name] = false
  13.     end
  14.   end
  15. end
  16. interrupt(1, event.iid and (event.iid + 1) or 0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement