Guest User

NuclearControl/CC

a guest
Feb 6th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. a = peripheral.wrap("top")
  2. b = peripheral.wrap("right")
  3. c = peripheral.wrap("bottom")
  4. rednet.open("left")
  5. local mEnergy = 0
  6. local nEnergy = 0
  7. local pEnergy = 0
  8. local nLit = 0
  9. local rOutput = 0
  10. local nLamps = 7
  11. local excess = 0
  12.  
  13. while true do
  14. idA,stateA,titleA,dataA = a.get(1)
  15. idB,stateB,titleB,dataB = b.get(1)
  16. idC,stateC,titleC,dataC = c.get(1)
  17.  
  18. mEnergy = tonumber(dataA["maxStorageL"]) + tonumber(dataB["maxStorageL"]) + tonumber(dataC["maxStorageL"])
  19. nEnergy = tonumber(dataA["energyL"]) + tonumber(dataB["energyL"]) + tonumber(dataC["energyL"])
  20. pEnergy = (nEnergy / mEnergy) * 100
  21. pEnergy = math.floor(pEnergy)
  22.  
  23. if nEnergy > mEnergy then
  24. excess = nEnergy - mEnergy
  25. nEnergy = nEnergy - excess
  26. end
  27.  
  28. nLit = math.floor((nEnergy / mEnergy) * nLamps)
  29. rOutput = (2 ^ nLit) - 1
  30. redstone.setBundledOutput("back",rOutput)
  31.  
  32. term.clear()
  33. term.setCursorPos(1,1)
  34. term.write(nEnergy.."eu of "..mEnergy.."eu")
  35. term.setCursorPos(1,2)
  36. term.write((pEnergy).."%")
  37. term.setCursorPos(1,3)
  38. term.write(nLit.." leds lit")
  39.  
  40. info = {nEnergy, mEnergy, pEnergy, nLit}
  41. euData = textutils.serialize(info)
  42. rednet.send(11, euData)
  43. sleep(0.5)
  44. end
Advertisement
Add Comment
Please, Sign In to add comment