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
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