Advertisement
9551

Untitled

Jul 2nd, 2021
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.71 KB | None | 0 0
  1. function terminal.bar(
  2.     pos1,
  3.     pos2,
  4.     length,
  5.     height,
  6.     ins,
  7.     max,
  8.     color1,
  9.     color2,
  10.     color3,
  11.     printval,
  12.     hor,
  13.     text,
  14.     format,
  15.     rect,
  16.     thicc)
  17.     if (ins == nil) or (ins < 0) then
  18.         ins = 0
  19.     end
  20.     if format == nil then
  21.         local format = false
  22.     end
  23.     if ins ~= nil then
  24.         oldcol = term.getBackgroundColor()
  25.         oldcol1 = term.getTextColor()
  26.         term.setTextColor(colors[color3])
  27.         local function reprint()
  28.             term.setBackgroundColor(colors[color1])
  29.             terminal.fill(pos1 - 1, pos2 - height, length, height * 2)
  30.             term.setBackgroundColor(oldcol)
  31.             xm = term.getBackgroundColor()
  32.             xb = term.getTextColor()
  33.             term.setTextColor(xm)
  34.             term.setBackgroundColor(xb)
  35.             term.setCursorPos(pos1 - 1, pos2 - height)
  36.             if thicc then
  37.                 term.setBackgroundColor(colors[color3])
  38.             end
  39.             if thicc then
  40.                 term.write(string.rep("\x83", length + 1)) --\143
  41.                 term.setTextColor(xb)
  42.                 term.setBackgroundColor(xm)
  43.             else
  44.                 term.write("\159" .. string.rep("\143", length - 1)) --\x83
  45.                 term.setTextColor(xb)
  46.                 term.setBackgroundColor(xm)
  47.                 term.write("\144")
  48.             end
  49.             if thicc then
  50.                 term.setBackgroundColor(colors[color3])
  51.             end
  52.             term.setCursorPos(pos1 - 1, pos2 + height)
  53.             if thicc then
  54.                 term.write(string.rep("\x8c", length + 1)) --\131
  55.             else
  56.                 term.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  57.             end
  58.             for i = 0, (height * 2) - 2 do
  59.                 if not thicc then
  60.                     term.setTextColor(xm)
  61.                     term.setBackgroundColor(xb)
  62.                 end
  63.                 term.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  64.                 if thicc then
  65.                     term.setBackgroundColor(colors[color3])
  66.                 end
  67.                 term.write("\x95")
  68.                 term.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  69.                 if not thicc then
  70.                     term.setTextColor(xb)
  71.                     term.setBackgroundColor(xm)
  72.                 end
  73.                 term.write("\x95")
  74.             end
  75.         end
  76.         if rect ~= false then
  77.             reprint()
  78.         else
  79.             terminal.fill(pos1 - 1, pos2 - height, length, height * 2)
  80.         end
  81.         local drawLength = ins / max * length
  82.         local drawHeights = ins / max * height
  83.         local drawHeight = math.ceil(drawHeights)
  84.         local moveval = (drawHeight * 2) - 2
  85.         local z = pos2 + height
  86.         term.setBackgroundColor(colors[color2])
  87.         if (hor == false) or (hor == nil) then
  88.             terminal.fill(pos1, (pos2 - height) + 1, drawLength - 1, (height * 2) - 1)
  89.         else
  90.             terminal.fill(pos1, (z - 1) - moveval, length - 1, moveval + 1)
  91.         end
  92.         if printval == true then
  93.             term.setCursorPos(pos1, pos2)
  94.             term.setTextColor(colors[color3])
  95.             if hor == true then
  96.                 if format then
  97.                     if ins >= max / 2 then
  98.                         term.setBackgroundColor(colors[color2])
  99.                     else
  100.                         term.setBackgroundColor(colors[color1])
  101.                     end
  102.                 else
  103.                     if ins >= (max / 2) - (max / height) then
  104.                         term.setBackgroundColor(colors[color2])
  105.                     else
  106.                         term.setBackgroundColor(colors[color1])
  107.                     end
  108.                 end
  109.             elseif hor == false then
  110.                 term.setCursorPos(pos1, pos2)
  111.                 term.setTextColor(colors[color3])
  112.                 if hor == true then
  113.                     if ins >= 1 then
  114.                         term.setBackgroundColor(colors[color2])
  115.                     else
  116.                         term.setBackgroundColor(colors[color1])
  117.                     end
  118.                 end
  119.             end
  120.             if format then
  121.                 term.write(ins .. "/" .. max)
  122.                 term.setCursorPos(pos1, pos2 + 1)
  123.                 term.write(text)
  124.             else
  125.                 term.write(ins .. "/" .. max .. " " .. text)
  126.             end
  127.             term.setBackgroundColor(oldcol)
  128.             term.setTextColor(oldcol1)
  129.         end
  130.         term.setTextColor(oldcol1)
  131.         term.setBackgroundColor(oldcol)
  132.     end
  133. end
  134.  
  135. function terminal.frame(pos1, pos2, length, height, color3, color1, thicc)
  136.     local oldcol = term.getBackgroundColor()
  137.     local oldcol1 = term.getTextColor()
  138.     term.setBackgroundColor(colors[color1])
  139.     terminal.fill(pos1 - 1, pos2 - height, length, height * 2)
  140.     term.setBackgroundColor(oldcol)
  141.     xm = term.getBackgroundColor()
  142.     xb = term.getTextColor()
  143.     term.setTextColor(xm)
  144.     term.setBackgroundColor(xb)
  145.     term.setCursorPos(pos1 - 1, pos2 - height)
  146.     if thicc then
  147.         term.setBackgroundColor(colors[color3])
  148.         term.setTextColor(oldcol)
  149.         term.write(string.rep("\x83", length + 1)) --\143
  150.         term.setTextColor(xb)
  151.         term.setBackgroundColor(xm)
  152.     else
  153.         term.setTextColor(oldcol)
  154.         term.setBackgroundColor(colors[color3])
  155.         term.write("\159" .. string.rep("\143", length - 1)) --\x83
  156.         term.setTextColor(colors[color3])
  157.         term.setBackgroundColor(oldcol)
  158.         term.write("\144")
  159.     end
  160.     term.setCursorPos(pos1 - 1, pos2 + height)
  161.     if thicc then
  162.         term.setBackgroundColor(oldcol)
  163.         term.setTextColor(colors[color3])
  164.         term.write(string.rep("\x8f", length + 1)) --\131
  165.         term.setBackgroundColor(colors[color1])
  166.         term.setTextColor(colors[color3])
  167.     else
  168.         term.write("\130" .. string.rep("\131", length - 1) .. "\129") --\x8c
  169.     end
  170.     for i = 0, (height * 2) - 2 do
  171.         if not thicc then
  172.             term.setTextColor(xm)
  173.             term.setBackgroundColor(xb)
  174.         end
  175.         term.setCursorPos(pos1 - 1, (pos2 + i) - (height) + 1)
  176.         if thicc then
  177.             term.setBackgroundColor(colors[color3])
  178.         end
  179.         term.setBackgroundColor(colors[color3])
  180.         term.write("\x95")
  181.         term.setCursorPos((pos1 - 2) + (length + 1), (pos2 + i) - (height) + 1)
  182.         if not thicc then
  183.             term.setTextColor(xb)
  184.             term.setBackgroundColor(xm)
  185.         end
  186.         term.setTextColor(colors[color3])
  187.         term.write("\x95")
  188.     end
  189.     term.setBackgroundColor(oldcol)
  190.     term.setTextColor(oldcol1)
  191. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement