Advertisement
Guest User

Power!

a guest
Oct 18th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. powerD = peripheral.wrap("draconic_rf_storage_0")
  2. mon = peripheral.wrap("monitor_2")
  3.  
  4. local CurD = 0
  5. local MaxD = 0
  6. local PerD = 0
  7.  
  8. monX,monY = mon.getSize()
  9.  
  10.  
  11. function WerteD()
  12.     CurD = powerD.getEnergyStored()
  13.     MaxD = powerD.getMaxEnergyStored()
  14.     PerD = math.ceil(CurD/MaxD)
  15. end
  16.  
  17. function writeMonD()
  18.     mon.setBackgroundColor(colors.black)
  19.     mon.clear()
  20.     mon.setBackgroundColor(colors.purple)
  21.     mon.setTextColor(colors.white)
  22.     mon.setCursorPos(2,1)
  23.  mon.write(" Draconic:" .. math.ceil((powerD.getEnergyStored()/powerD.getMaxEnergyStored())*100) .. "% Voll")
  24. end
  25.  
  26.  
  27. function drawBarD()
  28.     barD = math.ceil(((CurD/MaxD)*monX)-2)
  29.    
  30.     mon.setCursorPos(2,monY-22)
  31.     mon.setBackgroundColor(colors.red)
  32.     mon.write(string.rep(" ", monX-2))
  33.     mon.setCursorPos(2,monY-23)
  34.     mon.setBackgroundColor(colors.red)
  35.     mon.write(string.rep(" ", monX-2))
  36.    
  37.     mon.setCursorPos(2,monY-22)
  38.     mon.setBackgroundColor(colors.green)
  39.     mon.write(string.rep(" ", barD))
  40.     mon.setCursorPos(2,monY-23)
  41.     mon.setBackgroundColor(colors.green)
  42.     mon.write(string.rep(" ", barD))
  43. end
  44.  
  45. function InputD()
  46.  PowerDra = powerD.getTransferPerTick()
  47.     mon.setCursorPos(2,monY-20)
  48.     mon.setBackgroundColor(colors.black)
  49.     mon.setTextColor(colors.white)
  50.     mon.write("Input:")
  51.     if PowerDra > 0 then
  52.     mon.setTextColor(colors.green)
  53.     mon.write("+" .. PowerDra .. "RF/T")
  54.     else
  55.     mon.setTextColor(colors.red)
  56.     mon.write(PowerDra .. "RF/T")
  57.     end
  58. end
  59.  
  60. function InputCalcD()
  61.    
  62.     InkRFD = CurD/1000
  63.     InMRFD = math.ceil(InkRFD)/1000
  64.     InGRFD = math.ceil(InMRFD)/1000
  65.     InTRFD = math.ceil(InGRFD)/1000
  66.  
  67.     mon.setCursorPos(20,monY-20)
  68.     mon.setTextColor(colors.white)
  69.  
  70.     if CurD > 1000 and CurD < 1000000 then
  71.     mon.write("Stored:" .. InkRFD .. "kRF")
  72.    
  73.     elseif CurD > 1000000 and CurD < 1000000000 then
  74.     mon.write("Stored:" .. InMRFD .. "MRF")
  75.  
  76.     elseif CurD > 1000000000 and CurD < 1000000000000 then
  77.     mon.write("Stored:" .. InGRFD .. "GRF")
  78.  
  79.     elseif CurD > 1000000000000 and CurD < 1000000000000000 then
  80.     mon.write("Stored:" .. InTRFD .. "TRF")
  81.     end
  82. end
  83.  
  84. while true do
  85.  
  86.     print("running")
  87.     WerteD()
  88.  writeMonD()
  89.     drawBarD()
  90.     InputD()
  91.     InputCalcD()
  92.     sleep(1)
  93. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement