Log in

View Full Version : Alternative to XenoBot HUD



eldera
02-06-2016, 05:15 PM
I was bored as fuck so I decited to make this lib which gives possibily to create colorfull HUD's.

http://i.imgur.com/niS0Mh4.png


1. How to use?
- First of all you need to download this (https://bitbucket.org/elderapo/betterxenobothud/downloads/BetterHUD.lua) library and put it in Scripts folder.
- Then include it by adding require("BetterHUD") on the top of your script.
require("BetterHUD")
-- your code there

- And use it like:
require("BetterHUD")

BetterHUD.New(100, 150, {
{"This ", {111, 222, 213}},
{"is ", color.red},
{"example ", color.default},
{"HUD ", color.green},
{"that ", color.blue},
{"can ", color.blue},
{"be ", color.green},
{"made ", color.red},
{"with ", color.yellow},
{"this ", {111, 222, 213}},
{"lib ", randomColor()},
{"heuheuheuheuehue ", color.black},
})

Module.New("a", function() end) -- just to keep script alive

Result:
http://i.imgur.com/Y4kdyYc.png


Another examples:

1. Some MLG shit (might crash your tibia XD).

require("BetterHUD")

function randomColor()
return {math.random(0, 255), math.random(0, 255), math.random(0, 255)}
end

local mlg = {}

local dims = HUD.GetMainWindowDimensions()
local w = dims.gamewindowx + dims.gamewindoww
local h = dims.gamewindowy + dims.gamewindowh

for i = 0, 100 do
mlg[i] = BetterHUD.New(math.random(0, w), math.random(0, h), {
{"", color.default},
})
end


while true do
for i, v in pairs(mlg) do
mlg[i]:Update({
{"This ", randomColor()},
{"is ", randomColor()},
{"fucking ", randomColor()},
{"MLG ", randomColor()},
{"Kappa", randomColor()},
})


mlg[i]:SetPosition(math.random(0, w), math.random(0, h))
end
end


Result: test it by yourself :rolleyes:

2. Recent loot with highlights:
require("BetterHUD")

local displayTitle = true
local displayBodies = 6 -- display how many last bodies
local highlightAboveValue = 1000 -- Highlight items worth than x in gp. Ex. if you want to highlight boots of haste use 30000.
local highlightItems = { -- Highlight listed items
["meat"] = true,
["morning star"] = true,
["mace"] = true,
["sword"] = true
}

local maxWidth = 550 -- max length in pixels
local dims = HUD.GetMainWindowDimensions()
local hudX = dims.gamewindowx + dims.gamewindowx + dims.gamewindoww -maxWidth
local hudY = dims.gamewindowy + dims.gamewindowh - (displayBodies+1) * 12

function getY(index) return hudY + index * 12 end

function init()
if (displayTitle) then
BetterHUD.New(hudX, hudY, {
{"Recent ", color.default},
{"loot ", color.black},
{"hud ", color.default},
{"by ", color.white},
{"Elderapo ", color.yellow},
})
end

local HUDData = {}

for index = 1, displayBodies do
HUDData[index] = BetterHUD.New(hudX, getY(index), {{"hehe " .. index, color.default}}, maxWidth)
end

function lootCb(proxy, message)
local lootOfMonsterString = string.match(message, "(.+):") .. ":"
local lootString = string.match(message, ": (.+)")
local oldLoot = lootString:gsub(", " ,","):gsub("%.", ""):split(",")
local loot = lootString:gsub(", " ,","):gsub("an ", ""):gsub("a ", ""):gsub("%.", ""):split(",")

for i, v in pairs(loot) do
local itemCount = v:match("%d+") or 1
local itemName = v:gsub(itemCount .. " ", "")
local itemId = Item.GetID(itemName) ~= 0 and Item.GetID(itemName) or Item.GetID(itemName:sub(1, #itemName-1))
loot[i] = {id = itemId, count = itemCount, name = itemName}
end

local hudLine = {
{lootOfMonsterString, color.green} -- Add begining of loot message "Loot of a xxx:"
}

for i, v in pairs(loot) do -- Add and optionally highlight items.
local item = v.id
local count = tonumber(v.count)
local selectedColor = (Item.GetValue(item) * count > highlightAboveValue or highlightItems[Item.GetItemNameFromDualInput(item)]) and color.red or color.green
table.insert(hudLine, {" " .. oldLoot[i], selectedColor})
table.insert(hudLine, {i == #loot and "." or "," , color.green})
end

for index = 1, #HUDData-1 do -- Scroll list on update.
HUDData[index]:Update(HUDData[index+1].values)
end

HUDData[displayBodies]:Update(hudLine)
end

LootMessageProxy.OnReceive("lootProxy", lootCb)
end

init()


Result:
http://i.imgur.com/niS0Mh4.png

Link to official repository.https://bitbucket.org/elderapo/betterxenobothud

kamilqq
02-06-2016, 05:41 PM
Great job :)

shadowart
02-06-2016, 06:33 PM
Nice work!

If you want the example HUD to stick to a corner regardless of resolution you can use HUD.GetMainWindowDimensions(). For example, for the lower left corner you would do:

-- Reorder the code so that this comes after displayBodies is defined
local dims = HUD.GetMainWindowDimensions()
local hudX = dims.gamewindowx
local hudY = dims.gamewindowy + dims.gamewindowh - (displayBodies+1) * 12

dean015
02-06-2016, 10:36 PM
looks nice man

will i have to add all the items i want to be in red myself?

Jetta
02-06-2016, 10:48 PM
Looking good but cant execute it, get this error

23:57 XenoScript Error:
Script: [Support] Recent Loot.lua
Line #: 72
Chunk: C:?Users?Aaaa?DOCUME?1?XenoBot?Scripts??_SC9C8?1.L UA
Error: '<eof>' expected near 'end'
This is an error with user-input and should not be reported as a bug with XenoBot.

kamilqq
02-06-2016, 10:51 PM
looks nice man

will i have to add all the items i want to be in red myself?
Yes you do.

dean015
02-06-2016, 11:04 PM
Yes you do.

i have a speedlooter i downloaded from somebody else (cant remember who) it lists items like this


[668] = {"fiery headchopper", 6000},
[669] = {"fiery war axe", 12000},
[672] = {"fiery cranial basher", 30000},
[673] = {"fiery orcish maul", 6000},
[674] = {"fiery war hammer", 1200},


would i be able to just copy this into it?

i dont think i can be bothered to add all the items myself manually :(

shadowart
02-06-2016, 11:15 PM
i have a speedlooter i downloaded from somebody else (cant remember who) it lists items like this


[668] = {"fiery headchopper", 6000},
[669] = {"fiery war axe", 12000},
[672] = {"fiery cranial basher", 30000},
[673] = {"fiery orcish maul", 6000},
[674] = {"fiery war hammer", 1200},


would i be able to just copy this into it?

i dont think i can be bothered to add all the items myself manually :(
Change this:

local highlightAboveValue = 1000

The item list is only for items that can't be sold to npcs or that are sold for very little.