ksbd

Energy Cell checker

Feb 28th, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. --Variables
  2.  
  3. local data
  4. local m = peripheral.wrap("back")
  5. local canStore
  6.  
  7. --Functions
  8.  
  9. function getData()
  10.     data = m.get()
  11.     canStore = data["Can Store Energy"]
  12. end
  13.  
  14. function printData()
  15.     getData()
  16.     for i , j in pairs(data) do
  17.         print(i..":"..tostring(j))
  18.     end
  19. end
  20.  
  21. function clear()
  22.     term.clear()
  23.     term.setCursorPos(1,1)
  24. end
  25.  
  26. function check()
  27.     getData()
  28.     if canStore then
  29.         turnOn()
  30.         clear()
  31.         print("Can store energy...")
  32.     elseif data["Full Energy"] then
  33.         turnOff()
  34.         clear()
  35.         print("Energy Full")
  36.     else
  37.         clear()
  38.         print("Error!")
  39.     end
  40. end
  41.  
  42. function turnOn()
  43.     redstone.setOutput("top", true)
  44. end
  45.  
  46. function turnOff()
  47.     redstone.setOutput("top", false)
  48. end
  49.  
  50. --Main Program
  51.  
  52. while true do
  53.     getData()
  54.     printData()
  55.     check()
  56.     sleep(10)
  57. end
Advertisement
Add Comment
Please, Sign In to add comment