augustclear

managerlib

Nov 20th, 2020 (edited)
904
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.78 KB | None | 0 0
  1. --Manager Library
  2.  
  3. local _x, _y, _z
  4. local workerlist = {}
  5.  
  6. local function open()
  7.     rednet.host("boss","boss")
  8.     rednet.open("top")
  9. end
  10.  
  11. local function close()
  12.  
  13. end
  14.  
  15. local function init()
  16.     open()
  17.     _x, _y, _z = gps.locate(5)
  18.     if _x == nil then
  19.         do return -1 end
  20.     end
  21.     return 0
  22. end
  23.  
  24. local function send(workername, s)
  25.     local id = rednet.lookup("workers",workername)
  26.     return rednet.send(id,s,"workers")
  27. end
  28.  
  29. local function get_heartbeats()
  30.     local id, msg = rednet.receive("heartbeat")
  31.     term.write("[" .. id .. "]" .. msg)
  32. end
  33.  
  34. local function get_workers()
  35.     workerlist = rednet.lookup("workers")
  36. end
  37.  
  38. return {open = open, close = close, init = init, send = send, get_heartbeats = get_heartbeats, get_workers = get_workers}
Advertisement
Add Comment
Please, Sign In to add comment