Shadows_Player

Matrix V3

Aug 19th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.71 KB | Gaming | 0 0
  1. power = peripheral.wrap("back")
  2. mon = peripheral.wrap("top")
  3.  
  4. local maxPower = 0
  5. local curPower = 0
  6. local perPower = 0
  7. local outPower = 0
  8. local inpPower = 0
  9. local capPower = 0
  10. local warning = 10
  11.  
  12.  
  13. monX,monY = mon.getSize()
  14.  
  15.    
  16. function getMaxEnergy(cube)
  17.     return cube.getMaxEnergy() * 0.4
  18. end
  19.  
  20. function getEnergy(cube)
  21.     return cube.getEnergy() * 0.4
  22. end
  23.  
  24. function getOutput(cube)
  25.     return cube.getOutput() * 0.4
  26. end
  27. function getInput(cube)
  28.     return cube.getInput() * 0.4
  29. end
  30.  
  31. function per()
  32.     mon.setBackgroundColor(colors.black)
  33.     perPower = math.floor(((getEnergy(power)/getMaxEnergy(power))*100+0.4))
  34.     mon.setCursorPos(1,2)
  35.     mon.write(" Power: " .. perPower .. "%")
  36. end
  37.  
  38. function shorthand(number)
  39.     assert(type(number) == "number", "Type number cannot be a "..type(number))
  40.     local letters = {'rf', 'Krf', 'Mrf', 'Grf', 'Trf', 'QDrf', 'QTrf'}
  41.     local log = math.max(math.log10(number), 0)
  42.     local pwr = math.floor(log / 3)
  43.     assert(pwr + 1 <= #letters, "Number too big - we don't have enough suffixes")
  44.     return ("%.3g%s"):format(number / 1000^pwr, letters[pwr + 1])
  45. end
  46.  
  47. function writeMon()
  48.   mon.setBackgroundColor(colors.black)
  49.   mon.clear()
  50.   mon.setCursorPos(1,3)
  51.   mon.write(" Currrent: ")
  52.   mon.write(shorthand(getEnergy(power)))
  53.   mon.setCursorPos(1,4)
  54.   mon.write(" Input: ")
  55.   mon.write(shorthand(getInput(power)))
  56.   mon.setCursorPos(1,5)
  57.   mon.write(" Output: ")
  58.   mon.write(shorthand(getOutput(power)))
  59. end
  60.  
  61.  
  62. function semess()
  63.    rednet.open("left")
  64.    teste = {cur = shorthand(getEnergy(power)), intpu = shorthand(getInput(power)), per = perPower, outpu = shorthand(getOutput(power))}  
  65.    rednet.broadcast(teste,"matrix")
  66.    rednet.close("left")
  67. end
  68.  
  69. function red()
  70.  if perPower > 90 then
  71.   term.clearLine()
  72.   redstone.setBundledOutput("right",0)
  73.   redstone.setBundledOutput("right", colors.blue)
  74.   mon.setCursorPos(1,6)
  75.   mon.setTextColor(colors.green)
  76.   mon.write(" Dischanging Energy")
  77.   mon.setTextColor(colors.white)
  78.  end
  79.  
  80.  if perPower < 20 then
  81.    term.clearLine()
  82.    redstone.setBundledOutput("right", colors.combine(colors.white, colors.orange))
  83.    mon.setCursorPos(1,6)
  84.    mon.setTextColor(colors.red)
  85.    mon.write(" Low Energy  ")
  86.    mon.setTextColor(colors.white)
  87.    x = 0
  88.  end
  89.  
  90.  if (perPower>20) and not (perPower > 90) then
  91.    term.clearLine()
  92.    redstone.setBundledOutput("right",0)
  93.    redstone.setBundledOutput("right", colors.white)
  94.    mon.setCursorPos(1,6)
  95.    mon.setTextColor(colors.yellow)
  96.    mon.write(" Charging Energy")
  97.    mon.setTextColor(colors.white)
  98.    x = 0
  99.  end
  100. end
  101.  
  102.  
  103. while true do
  104. writeMon()
  105. per()
  106. semess()
  107. red()
  108. print(shorthand(getEnergy(power)) .. "/" .. shorthand(getMaxEnergy(power)))
  109. sleep(0.5)
  110. end
  111.  
Add Comment
Please, Sign In to add comment