Guest User

BarAPI

a guest
Mar 3rd, 2014
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.33 KB | None | 0 0
  1. --[[BarAPI
  2. ActiveColor = Full BarColor
  3. InActiveColor = Empty Bar Color
  4. n = Percentage that needs to be filled
  5. CursorX = Bar start X pos
  6. CursorY = Bar Start Y pos
  7. TextColor = Color for stripes on bar set to same as ActiveColor if you dont want bars
  8. Mon = Monitor to display on
  9. Made By SteamPunk_Devil -- CCfourm Name Makeme -- Ingame Name SteamPunk_Angel
  10. ]]--
  11. function Percentage(current,total) --returns One number as a percentage of the second one --TBD Round to a Decimal place
  12.  
  13. local No1 = current
  14. local No2 = total
  15. local Percent = (No1 / No2) * 100
  16.  
  17. return Percent
  18. end
  19.  
  20. function Round(num, idp) --rounds num to idp decimals
  21.   local mult = 10^(idp or 0)
  22.   return math.floor(num * mult + 0.5) / mult
  23. end
  24.  
  25. function PercentBar(CursorX, CursorY, InActiveColor, ActiveColor, TextColor, n, Mon) --displays a bar
  26. local n10 = n/10
  27. local BarCursX = CursorX
  28. local BarCursY = CursorY
  29. local FormdN =  Round(n10, 0)
  30. local i = 0
  31. local Paste = Mon
  32. Paste.setCursorPos(CursorX, CursorY)
  33. Paste.setBackgroundColor(InActiveColor)
  34. Paste.write("          ")
  35. Paste.setCursorPos(CursorX, CursorY)
  36.  
  37. --for i, FormdN, 1 do
  38. while i <= FormdN do  
  39.     print(i)
  40.     print(FormdN)
  41.     Paste.setCursorPos(BarCursX,BarCursY)
  42.     Paste.setBackgroundColor(ActiveColor)
  43.     Paste.setTextColor(TextColor)
  44.     Paste.write("/")
  45.     BarCursX = BarCursX + 1
  46. end
  47. end
Advertisement
Add Comment
Please, Sign In to add comment