Advertisement
RLPGhost

Gestion Celule d'Energie

Nov 13th, 2015
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.75 KB | None | 0 0
  1. local capacitor = peripheral.wrap("top")
  2. local wifi = peripheral.wrap("back")
  3. local nbSlot = 740
  4.  
  5. redstone.setOutput("bottom", false )
  6.  
  7. while true do
  8. capacitorEnergy = capacitor.getEnergyStored() * nbSlot
  9. capacitorEnergyMax = capacitor.getMaxEnergyStored() * nbSlot
  10. percentcelule = math.floor(100 * capacitorEnergy / capacitorEnergyMax )
  11.  
  12. term.clear()
  13. term.setCursorPos(1,1)
  14. print("Remplissage: "..percentcelule.."%")
  15.  
  16. if percentcelule < 30 then
  17. redstone.setOutput("bottom",true)
  18. end
  19.  
  20. if percentcelule > 60 then
  21. redstone.setOutput("bottom",false)
  22. end
  23.  
  24. local tableau = { energy = capacitorEnergy, energyMax = capacitorEnergyMax , celpercent = percentcelule }
  25. local sendmsg = textutils.serialize(tableau)
  26. wifi.transmit(2,0,sendmsg)
  27.  
  28. sleep(2)
  29. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement