LDDestroier

Syncro - File-based event duplicator (beta)

Nov 18th, 2016
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- pastebin get yGQWBTve syncro
  2. -- std PB yGQWBTve syncro
  3.  
  4. syncpath = ".syncro"
  5. seed = math.random(1,65535)
  6. local dennis = false
  7. local tArg = {...}
  8.  
  9. function writeDown(evtbl)
  10.     if not evtbl then return false, "no event table, you idiot" end
  11.     if type(evtbl[1]) == "string" then
  12.         evtbl[1] = "'"..evtbl[1].."'"
  13.     end
  14.     local file = fs.open(syncpath,"a")
  15.     file.writeLine("if seed~="..seed.." then os.queueEvent("..table.concat(evtbl,",")..") end")
  16.     file.close()
  17. end
  18.  
  19. function record()
  20.     local evt
  21.     while true do
  22.         evt = {os.pullEvent()}
  23.         if evt[1] == "timer" then
  24.             dofile(syncpath)
  25.             fs.delete(syncpath)
  26.         else
  27.             writeDown(evt)
  28.         end
  29.         dennis = false
  30.     end
  31. end
  32.  
  33. function carryOn(...)
  34.     if arg then
  35.         dofile(...)
  36.     else
  37.         dofile("/rom/programs/shell")
  38.     end
  39.     write("Goodbye")
  40.     sleep(1)
  41.     return
  42. end
  43. parallel.waitForAny(record,function() carryOn(unpack(tArg) or {"rom/programs/shell"}) end)
Add Comment
Please, Sign In to add comment