Hexbugman213

Untitled

Jan 5th, 2021 (edited)
321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.11 KB | None | 0 0
  1. local monitorSide = "back"
  2.  
  3. if peripheral.isPresent(monitorSide) and peripheral.getType(monitorSide) == "monitor" then
  4.     term.redirect(peripheral.wrap(monitorSide))
  5.     peripheral.wrap(monitorSide).setTextScale(1)
  6. else
  7.     print("No monitor found")
  8.     return
  9. end
  10.  
  11. function explode(inSplitPattern, str)
  12.     str = str .. ""
  13.     local outResults = {}
  14.     local theStart = 1
  15.     local theSplitStart, theSplitEnd = string.find(str, inSplitPattern, theStart)
  16.     while theSplitStart do
  17.         local sub = string.sub(str, theStart, theSplitStart - 1)
  18.         table.insert(outResults, sub)
  19.         theStart = theSplitEnd + 1
  20.         theSplitStart, theSplitEnd = string.find(str, inSplitPattern, theStart)
  21.     end
  22.     table.insert(outResults, string.sub(str, theStart))
  23.     return outResults
  24. end
  25.  
  26. function printColouredBars(str, first)
  27.     parts = explode("|", str)
  28.     local l = #parts
  29.     for k = 1, l do
  30.         if first then
  31.             term.setTextColor(colors.blue)
  32.         end
  33.         io.write(parts[k])
  34.         if first then
  35.             term.setTextColor(colors.white)
  36.         end
  37.         if k ~= l then
  38.             term.setTextColor(colors.red)
  39.             io.write("|")
  40.             term.setTextColor(colors.white)
  41.         end
  42.     end
  43. end
  44.  
  45. function profile()
  46.     term.setCursorPos(1, 1)
  47.     local success, output = commands.exec("tickprofilertps")
  48.     --local text = table.concat(output, "\n")
  49.  
  50.     term.clear()
  51.     for i, line in ipairs(output) do
  52.         if i == 1 then
  53.             term.setTextColor(colors.blue)
  54.         else
  55.             if i == 2 then
  56.                 term.setTextColor(colors.white)
  57.             else
  58.                 if i == #output then
  59.                     term.setTextColor(colors.lime)
  60.                 else
  61.                     if i == #output - 1 then
  62.                         term.setTextColor(colors.orange)
  63.                     else
  64.                         term.setTextColor(colors.lightGray)
  65.                     end
  66.                 end
  67.             end
  68.         end
  69.         print(line)
  70.     end
  71. end
  72.  
  73. while true do
  74.     profile()
  75.     sleep(0.5)
  76. end
  77.  
  78. term.restore()
Add Comment
Please, Sign In to add comment