ksbd

Readers (REC)

Jan 26th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local server = 27
  2. local monitor = 26
  3. local m = peripheral.wrap("front")
  4. local data
  5. local canStore
  6. local max
  7. local compID
  8.  
  9. function closeNet()
  10.   rednet.close("top")
  11. end
  12.  
  13. function openNet()
  14.   closeNet()
  15.   rednet.open("top")
  16. end
  17.  
  18. function getData()
  19.   data = m.get()
  20.   canStore = data["Can Store Energy"]
  21.   max = data["Full Energy"]
  22.   compID = os.getComputerID()
  23. end
  24.  
  25. function detect()
  26.   getData()
  27.   openNet()
  28.    if canStore then
  29.      print("Energy Cell is not yet charged.")
  30.      rednet.send(server,"Charging")
  31.      rednet.send(monitor,"Charging")
  32.      sleep(5)
  33.    elseif max then
  34.      print("Energy Cell is fully charged.")
  35.      rednet.send(server,"Full")
  36.      rednet.send(monitor, "Full")
  37.      sleep(10)
  38.    else
  39.      print("There is no Energy Cell to read.")
  40.      rednet.send(server,"Absent")
  41.      rednet.send(monitor,"Absent")
  42.      sleep(5)
  43.    end
  44. end
  45.  
  46. while true do
  47.   detect()
  48. end
Advertisement
Add Comment
Please, Sign In to add comment