GrunclePug

Power Status Monitor: Transmitter

Jan 29th, 2022
1,441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. -- This program sends the data from these 2 power
  2. -- units and displays it in my base
  3. -- Author: moomoocat28
  4.  
  5. -- Pre Initialization
  6. modem = peripheral.wrap("back")
  7. modem.open(250)
  8.  
  9. -- Initialization
  10. local outputEU = ""
  11. local outputRF = ""
  12. local maxEU = 0
  13. local maxRF = 0
  14. local curEU = 0
  15. local curRF = 0
  16. local perEU = 0
  17. local perRF = 0
  18.  
  19. eu = peripheral.wrap("ic2:oldmfsu_12")
  20. rf = peripheral.wrap("thermalexpansion:storage_cell_23")
  21.  
  22. -- Program
  23. function checkPower()
  24.     maxEU = eu.getEUCapacity()
  25.     maxRF = rf.getRFCapacity()
  26.    
  27.     curEU = eu.getEUStored()
  28.     curRF = rf.getRFStored()
  29.    
  30.     perEU = math.floor(((curEU/maxEU)*100)+0.5)
  31.     perRF = math.floor(((curRF/maxRF)*100)+0.5)
  32. end
  33.  
  34. while true do
  35. checkPower()
  36. outputEU = curEU .. "/" .. maxEU .. " EU (" .. perEU .. "%)   "
  37. outputRF = curRF .. "/" .. maxRF .. " RF (" .. perRF .. "%)   "
  38.  
  39. modem.transmit(250, 250, {outputEU, outputRF})
  40. sleep(1)
  41. end
Advertisement
Add Comment
Please, Sign In to add comment