Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- init start
- -- Hultin's Hud v2.0.0
- -- Last update: 8th April 2014
- -- Script author - This is where you put your name.
- -- The rest of the script info is entered into Cavebot->Edit useroptions.
- local ScriptAuthor = "Hultin"
- -- Set to true if you are developing a script. Remember to set to false when you release/sell it.
- local Development = false
- -- Configuration for width/height
- local FieldConfig = {
- Height = 22, -- Optimized for 22px. Sizes lower than 20 looks weird and narrow, keep that in mind if you set the height lower.
- Width = 260, -- Total width of the HUD. Value/Field widths are automatically calculated.
- }
- -- You can add more color points to create a gradient. The current implementation is just a flat gradient.
- -- First value is graident point, color(r, g, b, a)
- -- Alpha is 0-100, 0 is non-transparent 100 is fully see through (no color!)
- local Colors = {
- HeaderColor = {1, color(41, 79, 109, 10)},
- HeaderInnerBorder = color(58, 106, 140, 10),
- FieldColor = {1, color(40, 40, 40, 10)},
- FieldInnerBorder = color(74, 74, 74, 10),
- ValueNeutral = {1, color(158, 104, 0, 10)},
- NeutralInnerBorder = color(166, 124, 44, 10),
- ValuePositive = {1, color(67, 99, 13, 10)},
- PositiveInnerBorder = color(94, 119, 53, 10),
- ValueNegative = {1, color(139, 37, 13, 10)},
- NegativeInnerBorder = color(150, 72, 54, 10),
- Transparent = {1, color(0, 0, 0, 100)},
- NoInnerBorder = color(0, 0, 0, 100)
- }
- -- This value configures the width of the valuefield.
- FieldConfig.ValueWidth = FieldConfig.Width/2.2
- -- This variables controlls the "Toggle all on/off" button & it's text
- local AllOn = true
- -- Enginestates are treated and created diffrently than other elements are.
- local Engines = {
- {Name = 'Cavebot', Element = 0},
- {Name = 'Looting', Element = 0},
- {Name = 'Targeting', Element = 0},
- {Name = 'Spell Healer', Element = 0},
- {Name = 'Potion Healer', Element = 0},
- {Name = 'Condition Healer', Element = 0}
- }
- -- Toggles all state on/off.
- function togglestates(state)
- for _, e in ipairs(Engines) do
- setsetting(e.Name:gsub(' ', '') .. '/Enabled', state)
- end
- end
- -- Input events.
- -- Keys, Mouseclicks, Mousemoves, Stealfocus
- filterinput(false, true, false, false)
- -- Allows interaction with hud, aswell as adds the ability to move the HUD.
- function inputevents(e)
- if e.type == IEVENT_LMOUSEUP then
- for _, v in ipairs(Engines) do
- print(v)
- print(e.elementid)
- if e.elementid == v.Element then
- toggle(v.Name:gsub(' ', '') .. '/Enabled')
- return
- end
- end
- if(e.elementid == Toggleall) then
- if(AllOn) then
- togglestates("no")
- AllOn = false
- else
- togglestates("yes")
- AllOn = true
- end
- end
- end
- end
- local Elements = {}
- init end
- --[[ Functions ]]--
- -- Returns a formated textstring for your vip and such.
- function viptext()
- local total = 0
- local online = 0
- foreach vipentry v do
- total = total +1
- if(v.isonline) then
- online = online + 1
- end
- end
- return total..' ('..online..')'
- end
- -- Works like PHPs ucfirst()
- -- http://www.php.net/manual/en/function.ucfirst.php
- function firstToUpper(str)
- return (str:gsub("^%l", string.upper))
- end
- -- Credit to SIRMATE
- function WeaponSkill()
- local SkillTypes = {
- ['axe'] = {type = 'axe', skill = $axe, skillpc = $axepc},
- ['club'] = {type = 'club', skill = $club, skillpc = $clubpc},
- ['sword'] = {type = 'sword', skill = $sword, skillpc = $swordpc},
- ['bow'] = {type = 'distance', skill = $distance, skillpc = $distancepc},
- ['distance weapon'] = {type = 'distance', skill = $distance, skillpc = $distancepc},
- ['no weapon'] = {type = 'fist', skill = $fist, skillpc = $fistpc},
- ['rod'] = {type = 'magic', skill = $mlevel, skillpc = $mlevelpc},
- ['wand'] = {type = 'magic', skill = $mlevel, skillpc = $mlevelpc},
- }
- return SkillTypes[findweapontype()]
- end
- -- String used for Weaponskill/Magiclevel section of the HUD.
- local TypeSkill = WeaponSkill() or {type = 'magic', skill = $mlevel, skillpc = $mlevelpc}
- -- Default values to not leave any field/values blank.
- local ScriptName = getuseroption('scriptname')
- local ScriptVersion = getuseroption('scriptversion')
- if(string.len(ScriptName) == 0) then
- ScriptName = 'Script name'
- end
- if(string.len(ScriptVersion) == 0) then
- ScriptVersion = "1.0.0"
- end
- -- Sections, you can add/remove elements as you please.
- local Sections = {
- {
- Name = ScriptName,
- Display = true,
- Items = {
- {"Created by", ScriptAuthor},
- {"Version", ScriptVersion}
- }
- },
- {
- Name = "Engine states",
- Display = true,
- Items = { -- This category is special, uses Engines table for Items.
- }
- },
- {
- Name = "Character stats",
- Display = true,
- Items = {
- {"Experience", num($exp)..' exp'},
- {"Experience/hour", num($exphour)},
- {"Experience left", num(exptolevel())..' exp'},
- {"Experience gained", num($expgained)..' exp'},
- {"Time online", time(math.floor($timems / 1000))},
- {"Time to level", time(timetolevel())},
- {"Ping", $ping .. ' (avg: ' .. $pingaverage .. ')'},
- }
- },
- {
- Name = "Botting stats",
- Display = true,
- Items = {
- {"Level", $level .. ' (' .. 100 - math.floor(($exp - expatlvl($level)) * 100 / (expatlvl($level + 1) - expatlvl($level))) .. '%)'},
- {firstToUpper(TypeSkill.type)..' level', TypeSkill.skill .. ' (' .. 100 - TypeSkill.skillpc .. '%)'},
- {"Balance", num($balance)},
- {"Stamina", time($stamina)},
- {"Softboots duration", 0},
- {"Vip (Online)", viptext()}
- }
- },
- {
- Name = "Development toolkit",
- Display = Development,
- Items = {
- {"Position", $posx..'/'..$posy..'/'..$posz},
- {"Mouseover item", $cursorinfo.id},
- {"Mouse position", $cursorinfo.x..'/'..$cursorinfo.y..'/'..$cursorinfo.z}
- }
- }
- }
- --[[ Functions ]]--
- function y(v)
- return v + (FieldConfig.Height + 5)
- end
- -- Weapon skills
- function WeaponSkill()
- local SkillTypes = {
- ['axe'] = {type = 'axe', skill = $axe, skillpc = $axepc},
- ['club'] = {type = 'club', skill = $club, skillpc = $clubpc},
- ['sword'] = {type = 'sword', skill = $sword, skillpc = $swordpc},
- ['bow'] = {type = 'distance', skill = $distance, skillpc = $distancepc},
- ['distance weapon'] = {type = 'distance', skill = $distance, skillpc = $distancepc},
- ['no weapon'] = {type = 'fist', skill = $fist, skillpc = $fistpc},
- ['rod'] = {type = 'magic', skill = $mlevel, skillpc = $mlevelpc},
- ['wand'] = {type = 'magic', skill = $mlevel, skillpc = $mlevelpc},
- }
- return SkillTypes[findweapontype()]
- end
- -- Creates a header
- function DrawHeader(posx, posy)
- addgradcolors(table.unpack(Colors.Transparent))
- setbordercolor(color(0, 0, 0, 10))
- drawrect(posx, posy, FieldConfig.Width+2, FieldConfig.Height+2)
- addgradcolors(table.unpack(Colors.HeaderColor))
- setbordercolor(Colors.HeaderInnerBorder)
- drawrect(posx+1, posy+1, FieldConfig.Width, FieldConfig.Height)
- end
- -- Creates a field
- function DrawField(posx, posy)
- posx = posx
- addgradcolors(table.unpack(Colors.Transparent))
- setbordercolor(color(0, 0, 0, 10))
- drawrect(posx, posy, (FieldConfig.Width-FieldConfig.ValueWidth)-1, FieldConfig.Height+2)
- addgradcolors(table.unpack(Colors.FieldColor))
- setbordercolor(Colors.FieldInnerBorder)
- drawrect(posx+1, posy+1, FieldConfig.Width-FieldConfig.ValueWidth-3, FieldConfig.Height)
- end
- -- Creates a value
- function DrawValue(posx, posy, valueType)
- if(valueType == "positive") then
- Border = Colors.PositiveInnerBorder
- Background = Colors.ValuePositive
- elseif(valueType == "negative") then
- Border = Colors.NegativeInnerBorder
- Background = Colors.ValueNegative
- else
- Border = Colors.NeutralInnerBorder
- Background = Colors.ValueNeutral
- end
- addgradcolors(table.unpack(Colors.Transparent)) -- This will not show, anyways.
- setbordercolor(color(0, 0, 0, 10))
- drawrect(FieldConfig.Width-FieldConfig.ValueWidth+posx, posy, FieldConfig.ValueWidth+2, FieldConfig.Height+2)
- addgradcolors(table.unpack(Background))
- setbordercolor(Border)
- return drawrect((FieldConfig.Width-FieldConfig.ValueWidth)+1+posx, posy+1, FieldConfig.ValueWidth, FieldConfig.Height)
- end
- -- Draws special buttons - used for toggle all & show/hide
- function DrawButton(posx, posy, valueType, Width)
- local Width = Width or FieldConfig.ValueWidth
- if(valueType == "positive") then
- Border = Colors.PositiveInnerBorder
- Background = Colors.ValuePositive
- elseif(valueType == "negative") then
- Border = Colors.NegativeInnerBorder
- Background = Colors.ValueNegative
- else
- Border = Colors.NeutralInnerBorder
- Background = Colors.ValueNeutral
- end
- addgradcolors(table.unpack(Colors.Transparent)) -- This will not show, anyways.
- setbordercolor(color(0, 0, 0, 10))
- drawrect(FieldConfig.Width-FieldConfig.ValueWidth+posx, posy, Width, FieldConfig.Height+2)
- addgradcolors(table.unpack(Background))
- setbordercolor(Border)
- return drawrect((FieldConfig.Width-FieldConfig.ValueWidth)+1+posx, posy+1, Width, FieldConfig.Height)
- end
- -- Draws text
- function DrawText(text, x, y, fieldtype)
- -- Field type is shorthand functionality to place it over the VALUE elements.
- if(fieldtype == "value") then
- x = ((FieldConfig.Width-FieldConfig.ValueWidth)+x)
- end
- addtext(text, x+6, y+6)
- end
- -- Hud definitions
- setposition($clientwin.left + 5, $worldwin.top+2)
- setfontstyle('Tahoma', 8, 75, 0xcfebfd, 1, 0x000000)
- setfillstyle('gradient', 'linear', 2, 0, 0, 0, 21)
- setantialiasing(true)
- --
- local yPos = 0
- local isEnabled = nil
- -- Loop fields/values
- for _, s in ipairs(Sections) do
- if(s.Display) then
- DrawHeader(0, yPos)
- DrawText(s.Name, 0, yPos)
- if(s.Name == 'Engine states') then
- -- Toggle all
- local ToggleallState = tern(AllOn, "negative", "positive")
- local ToggleallText = tern(AllOn, "TOGGLE ALL OFF", "TOGGLE ALL ON")
- Toggleall = DrawButton(0, yPos, ToggleallState)
- DrawText(ToggleallText, 0+10, yPos, "value")
- --yPos = y(yPos)
- for i, engine in ipairs(Engines) do
- yPos = y(yPos)
- local F, V = engine.Name
- isEnabled = get(F:gsub(' ', '') .. '/Enabled') == 'yes'
- fieldColor = tern(isEnabled, "positive", "negative")
- Value = tern(isEnabled, "ON", "OFF")
- xOffset = tern(isEnabled, (FieldConfig.ValueWidth/2)-12, (FieldConfig.ValueWidth/2)-14)
- DrawField(0, yPos)
- Engines[i].Element = DrawValue(0, yPos, fieldColor)
- DrawText(F, 0 ,yPos)
- DrawText(Value, 0+xOffset, yPos, "value")
- end
- else
- for k, v in ipairs(s.Items) do
- local Field, Value = v[1], v[2]
- local fieldColor = nil
- local xOffset = 0
- yPos = y(yPos) -- Increment yPos
- if(Field == "Stamina") then
- if($stamina > 40*60) then
- fieldColor = "positive"
- end
- DrawValue(0, yPos, fieldColor)
- else
- DrawValue(0, yPos)
- end
- DrawField(0, yPos)
- DrawText(Field, 0 ,yPos)
- DrawText(Value, 0+xOffset, yPos, "value")
- end
- end
- yPos = y(yPos)
- end
- end
- -- Footer should NEVER be edited or changed. It's theft if you do so without permission!
- DrawHeader(0, yPos)
- DrawText("Hultin's HUD", 0, yPos)
- DrawText("v2.0.0", FieldConfig.Width-45, yPos)
- -- Thank you for using Hultin's Hud V2.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement