SteamPunk_Devil

BarAPI

Mar 1st, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.06 KB | None | 0 0
  1. --bar API
  2. --BgColor = bar unused
  3. --BColor = Bar Color
  4. --Percent = Percentage that needs to be filled
  5. --CX, Cursor X pos
  6. --CY, Cursor Y pos
  7. --
  8. -- Made By SteamPunk_Devil -- CCfourm Name Makeme -- Ingame Name SteamPunk_Angel
  9.  
  10. function Percentage(current,total) --returns One number as a percentage of the second one --TBD Round to a Decimal place
  11.  
  12. local No1 = current
  13. local No2 = total
  14. local Percent = (No1 / No2) * 100
  15.  
  16. return Percent
  17. end
  18.  
  19. function Round(num, idp)
  20.   local mult = 10^(idp or 0)
  21.   return math.floor(num * mult + 0.5) / mult
  22. end
  23.  
  24. function PercentBar(CursorX, CursorY, InActiveColor, ActiveColor, TextColor, n, Mon)
  25. local n10 = n/10
  26. local BarCursX = CursorX
  27. local BarCursY = CursorY
  28. local FormdN =  Round(n10, 0)
  29. local i = 0
  30. local Paste = Mon or term
  31. Paste.setCursorPos(CursorX, CursorY)
  32. Paste.setBackgroundColor(InActiveColor)
  33. Paste.write("          ")
  34. Paste.setCursorPos(CursorX, CursorY)
  35. Paste.setBackgroundColor(ActiveColor)
  36. Paste.setTextColor(TextColor)
  37. Paste.write(string.rep("/",formdN))
  38. BarCursX = BarCursX + FormdN
  39. end
Advertisement
Add Comment
Please, Sign In to add comment