1ng0

CC - Reactor Controler Capacitor Relay - by lezchap

Dec 2nd, 2015
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.30 KB | None | 0 0
  1. capacitors = peripheral.wrap("right")  --Capacitor Side
  2. rednet.open("left")  --modem side
  3.  
  4. --Change number below to total capacitors in the multiblock below the computer
  5. local totalCapacitors = 9
  6. --Change side below to input for redstone signal from Power Monitor
  7. local powerMonitorInput = "back"
  8.  
  9. local table = {}
  10. table.monitor = rs.getInput(powerMonitorInput)
  11. table.currPower = capacitors.getEnergyStored() * totalCapacitors
  12. table.maxPower = capacitors.getMaxEnergyStored() * totalCapacitors
  13. local lastPower = table.currPower
  14. table.powerChange = table.currPower - lastPower
  15. table.powerDelta = math.ceil(table.powerChange/10)
  16. local loop = 0
  17. rednet.broadcast(textutils.serialize(table))
  18. print(textutils.serialize(table))
  19.  
  20. os.startTimer(.5)
  21.  
  22. while true do
  23.   event = os.pullEvent()
  24.   if event == "timer" then
  25.     os.startTimer(.5)
  26.     table.currPower = capacitors.getEnergyStored() * totalCapacitors
  27.     table.monitor = rs.getInput(powerMonitorInput)
  28.     table.powerChange = table.currPower - lastPower
  29.     table.powerDelta = math.ceil(table.powerChange/10)
  30.     lastPower = table.currPower
  31.     rednet.broadcast(textutils.serialize(table))
  32.     loop = loop + 1
  33.     if loop == 10 then --print table to screen evert 5 seconds
  34.       print(textutils.serialize(table))
  35.       loop = 0
  36.     end
  37.   end
  38. end
Add Comment
Please, Sign In to add comment