Advertisement
Guest User

general hud

a guest
Jun 18th, 2014
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.14 KB | None | 0 0
  1. HUD = {
  2.  
  3.     TITLE = "General Info by Pink Panther",
  4.  
  5.     CONFIG = {
  6.         ORIENTATION = "Right",
  7.         START_POSITION = {15, 25},
  8.         MAX_TEXT_LENGTH = 15,
  9.         TEXT_DISTANCE = 115,
  10.         LINE_DISTANCE = 15,
  11.     },
  12.  
  13.     --[[ Just edit below if you know what you're doing --]]
  14.  
  15.     COLORS = {
  16.         SHADOW = rgbcolor(10, 10, 10),
  17.         TITLE = rgbcolor(255, 165, 0),
  18.         TEXT1 = rgbcolor(205, 200, 177),
  19.         TEXT2 = rgbcolor(255, 255, 255),
  20.         SUBTITLE = rgbcolor(30, 144, 255),
  21.         ENABLED = rgbcolor(107, 142, 35),
  22.         DISABLED = rgbcolor(178, 34, 34),
  23.     },
  24.    
  25.     INFO = {
  26.         {NAME = "Level:", VALUE = levelValue, ENABLED = true},
  27.         {NAME = "Hunt Time:", VALUE = timehunt, ENABLED = true},
  28.         {NAME = "Exp Per Hour:", VALUE = exphourValue, ENABLED = true},
  29.         {NAME = "Exp Gained:", VALUE = expgainedValue, ENABLED = true},
  30.         {NAME = "Exp to Level:", VALUE = exptolevelValue, ENABLED = true},
  31.         {NAME = "Time to Level:", VALUE = ttlValue, ENABLED = true},
  32.         {NAME = "Stamina:", VALUE = stamValue, ENABLED = true},
  33.         {NAME = "Balance:", VALUE = balanceValue, ENABLED = true},
  34.         {NAME = "Cavebot:", VALUE = isCavebot, ENABLED = true},
  35.         {NAME = "Looting:", VALUE = isLooting, ENABLED = true},
  36.         {NAME = "Targeting:", VALUE = isTargeting, ENABLED = true},
  37.         {NAME = "Pos X:", VALUE = posxValue, ENABLED = true},
  38.         {NAME = "Pos Y:", VALUE = posyValue, ENABLED = true},
  39.         {NAME = "Pos Z:", VALUE = poszValue, ENABLED = true},
  40.         {NAME = "Mouse Item ID:", VALUE = cursoridValue, ENABLED = true},
  41.     },
  42.    
  43.     KILLCOUNTER = {
  44.         ENABLED = true,
  45.  
  46.         MONSTERS = {
  47.             {NAME = "frost dragon", VALUE = 0},
  48.             {NAME = "frost dragon hatchling", VALUE = 0},
  49.         },
  50.        
  51.         TOTALKILLED = 0,
  52.         HIGHESTHIT = 0,
  53.     }
  54.    
  55.    
  56. }
  57.  
  58. --[[ DONT EDIT NOTHING BELOW THIS LINE --]]
  59.  
  60. function comma_value(amount)
  61.   local formatted = amount
  62.   while true do  
  63.     formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2')
  64.     if (k==0) then
  65.       break
  66.     end
  67.   end
  68.   return formatted
  69. end
  70.  
  71. function round(val, decimal)
  72.   if (decimal) then
  73.     return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
  74.   else
  75.     return math.floor(val+0.5)
  76.   end
  77. end
  78.  
  79. function format_num(amount, decimal, prefix, neg_prefix)
  80.   local str_amount,  formatted, famount, remain
  81.  
  82.   decimal = decimal or 2  -- default 2 decimal places
  83.   neg_prefix = neg_prefix or "-" -- default negative sign
  84.  
  85.   famount = math.abs(round(amount,decimal))
  86.   famount = math.floor(famount)
  87.  
  88.   remain = round(math.abs(amount) - famount, decimal)
  89.  
  90.         -- comma to separate the thousands
  91.   formatted = comma_value(famount)
  92.  
  93.         -- attach the decimal portion
  94.   if (decimal > 0) then
  95.     remain = string.sub(tostring(remain),3)
  96.     formatted = formatted .. "." .. remain ..
  97.                 string.rep("0", decimal - string.len(remain))
  98.   end
  99.  
  100.   return formatted
  101. end
  102.  
  103. levelValue = level
  104. exphourValue = comma_value(exphour)
  105. expgainedValue = comma_value(expgained)
  106. exptolevelValue = comma_value(exptolevel())
  107. ttlValue = format_num((exptolevel()/exphour)).." Hours"
  108. stamValue = format_num((math.floor(stamina/60))).." Hours"
  109. balanceValue = comma_value(balance)
  110. posxValue = comma_value(posx)
  111. posyValue = comma_value(posy)
  112. poszValue = posz
  113. cursoridValue = comma_value(cursorinfo().id)
  114. isCavebot = getsettings("Settings\\CaveBot\\Enabled")
  115. isLooting = getsettings("Settings\\Looting\\Enabled")
  116. isTargeting = getsettings("Settings\\Targeting\\Enabled")
  117.    
  118.  
  119.  
  120.    
  121.  
  122. local X, Y = (HUD.CONFIG.ORIENTATION:lower() == "right" and worldwin.right + 10 or clientwin.left + 10) + HUD.CONFIG.START_POSITION[1], worldwin.top + 10 + HUD.CONFIG.START_POSITION[2]
  123.  
  124. setfontcolor(HUD.COLORS.TITLE)
  125. addtextstroke(HUD.TITLE, X, Y)
  126.  
  127. local Y = Y + HUD.CONFIG.LINE_DISTANCE + 2
  128.  
  129. setfontcolor(HUD.COLORS.SUBTITLE)
  130. addtextstroke("GENERAL INFO", X, Y)
  131.  
  132. local Y = Y + HUD.CONFIG.LINE_DISTANCE
  133.  
  134. for i = 1,#HUD.INFO do
  135.     if HUD.INFO[i].ENABLED then
  136.         setfontcolor(HUD.COLORS.TEXT1)
  137.         addtextstroke(HUD.INFO[i].NAME, X, Y)
  138.        
  139.         if HUD.INFO[i].VALUE == "yes" then
  140.             setfontcolor(HUD.COLORS.ENABLED)
  141.         elseif HUD.INFO[i].VALUE == "no" then
  142.             setfontcolor(HUD.COLORS.DISABLED)
  143.         else
  144.             setfontcolor(HUD.COLORS.TEXT2)
  145.         end
  146.         addtextstroke(HUD.INFO[i].VALUE, X + HUD.CONFIG.TEXT_DISTANCE, Y)
  147.         Y = Y + HUD.CONFIG.LINE_DISTANCE
  148.     end
  149. end
  150.  
  151. local getMessages = getmessages("Server Log")
  152. local countMessages = getMessages.count - 1
  153. for i = 0, countMessages do
  154.     if (getMessages[countMessages - i].text:find("Loot of a") and getMessages[countMessages - i].type == 20) then
  155.         for _, MONSTER in ipairs(HUD.KILLCOUNTER.MONSTERS) do
  156.             if (getMessages[countMessages - i].text:find("Loot of a ".. MONSTER.NAME:lower() ..":")) or (getMessages[countMessages - i].text:find("Loot of an ".. MONSTER.NAME:lower() ..":")) then
  157.                 MONSTER.VALUE = MONSTER.VALUE + 1
  158.                 HUD.KILLCOUNTER.TOTALKILLED = HUD.KILLCOUNTER.TOTALKILLED + 1
  159.             end
  160.         end
  161.     elseif getMessages[countMessages - i].text:find(" hitpoints due to your attack.") then
  162.         for h in string.gmatch(getMessages[countMessages - i].text, "(%d+)( hitpoints due to your attack.)$") do
  163.             if tonumber(h) > tonumber(HIGHESTHIT) then
  164.                 HIGHESTHIT = tonumber(h)
  165.             end
  166.         end
  167.     end
  168. end
  169.  
  170.  
  171. if HUD.KILLCOUNTER.ENABLED then
  172.     Y = Y + 25
  173.      
  174.     setfontcolor(HUD.COLORS.SUBTITLE)
  175.     addtextstroke("KILL COUNTER:", X, Y)
  176.     for _, m in ipairs(HUD.KILLCOUNTER.MONSTERS) do
  177.         if m.VALUE > 0 then
  178.             Y = Y + HUD.CONFIG.LINE_DISTANCE
  179.            
  180.             setfontcolor(HUD.COLORS.TEXT1)
  181.             addtextstroke((#m.NAME < HUD.CONFIG.MAX_TEXT_LENGTH and m.NAME or m.NAME:sub(1, HUD.CONFIG.MAX_TEXT_LENGTH) .. "..."):gsub("(%a)([%w_']*)", function(s1, s2) return s1:upper() .. s2:lower() end), X, Y)
  182.                
  183.             setfontcolor(HUD.COLORS.TEXT2)
  184.             addtextstroke(m.VALUE, X + HUD.CONFIG.TEXT_DISTANCE, Y)
  185.         end
  186.     end
  187.     if HUD.KILLCOUNTER.TOTALKILLED > 0 then
  188.         Y = Y + HUD.CONFIG.LINE_DISTANCE + 2
  189.          
  190.         setfontcolor(HUD.COLORS.TEXT2)
  191.         addtextstroke("Kills Total: ", X, Y)
  192.          
  193.         setfontcolor(HUD.COLORS.TITLE)
  194.         addtextstroke(HUD.KILLCOUNTER.TOTALKILLED, X + HUD.CONFIG.TEXT_DISTANCE, Y)
  195.  
  196.         Y = Y + HUD.CONFIG.LINE_DISTANCE + 2
  197.          
  198.         setfontcolor(HUD.COLORS.TEXT2)
  199.         addtextstroke("Kills Per Hour: ", X, Y)
  200.          
  201.         setfontcolor(HUD.COLORS.TITLE)
  202.         addtextstroke(math.floor(HUD.KILLCOUNTER.TOTALKILLED/(tosec(timehunt)/60/60)), X + HUD.CONFIG.TEXT_DISTANCE, Y)
  203.     end
  204.         Y = Y + HUD.CONFIG.LINE_DISTANCE + 2
  205.          
  206.         setfontcolor(HUD.COLORS.TEXT2)
  207.         addtextstroke("Highest Damage: ", X, Y)
  208.          
  209.         setfontcolor(HUD.COLORS.TITLE)
  210.         addtextstroke(HIGHESTHIT, X + HUD.CONFIG.TEXT_DISTANCE, Y)
  211.    
  212. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement