Hello ive added yesterday a script it was poor and were only showing last item looted.
Now its showing as much as you wish.
It sorts your looted items by price that u can set.
This code is still poor cause im not best at it ( as i said before ).
You can modify it for your needs, i think i won't add new features in next week.
Here's the code:
Special thanks to @shadowart.
lua code:
--[[
ITEMS ARRAY
]]
local items = {
{['name'] = 'elven scouting glass', ['price'] = 50000},
{['name'] = 'arrow', ['price'] = 200},
{['name'] = 'melon', ['price'] = 500},
{['name'] = 'scroll', ['price'] = 2333},
{['name'] = 'bread', ['price'] = 400},
{['name'] = 'gold coin', ['price'] = 40}
}
local lootDuration = 10 -- how much item lasts in hud ( counted in monsters with worthy loot ), change to 9999 to get items count from whole session.
local dropColor = {r = 60, g = 200, b = 15} -- if you like, change the color of items.
--[[
8 888888888o. ,o888888o. b. 8 8888888 8888888888
8 8888 `^888. . 8888 `88. 888o. 8 8 8888
8 8888 `88. ,8 8888 `8b Y88888o. 8 8 8888
8 8888 `88 88 8888 `8b .`Y888888o. 8 8 8888
8 8888 88 88 8888 88 8o. `Y888888o. 8 8 8888
8 8888 88 88 8888 88 8`Y8o. `Y88888o8 8 8888
8 8888 ,88 88 8888 ,8P 8 `Y8o. `Y8888 8 8888
8 8888 ,88' `8 8888 ,8P 8 `Y8o. `Y8 8 8888
8 8888 ,o88P' ` 8888 ,88' 8 `Y8o.` 8 8888
8 888888888P' `8888888P' 8 `Yo 8 8888
8 8888888888 8 888888888o. 8 8888 8888888 8888888888
8 8888 8 8888 `^888. 8 8888 8 8888
8 8888 8 8888 `88. 8 8888 8 8888
8 8888 8 8888 `88 8 8888 8 8888
8 888888888888 8 8888 88 8 8888 8 8888
8 8888 8 8888 88 8 8888 8 8888
8 8888 8 8888 ,88 8 8888 8 8888
8 8888 8 8888 ,88' 8 8888 8 8888
8 8888 8 8888 ,o88P' 8 8888 8 8888
8 888888888888 8 888888888P' 8 8888 8 8888
8 888888888o 8 8888888888 8 8888 ,o888888o. `8.`888b ,8'
8 8888 `88. 8 8888 8 8888 . 8888 `88. `8.`888b ,8'
8 8888 `88 8 8888 8 8888 ,8 8888 `8b `8.`888b ,8'
8 8888 ,88 8 8888 8 8888 88 8888 `8b `8.`888b .b ,8'
8 8888. ,88' 8 888888888888 8 8888 88 8888 88 `8.`888b 88b ,8'
8 8888888888 8 8888 8 8888 88 8888 88 `8.`888b .`888b,8'
8 8888 `88. 8 8888 8 8888 88 8888 ,8P `8.`888b8.`8888'
8 8888 88 8 8888 8 8888 `8 8888 ,8P `8.`888`8.`88'
8 8888 ,88' 8 8888 8 8888 ` 8888 ,88' `8.`8' `8,`'
8 888888888P 8 888888888888 8 888888888888 `8888888P' `8.` `8'
]]
--[[
VARIABLES
]]
local looted = {} -- Array which handle whole worth item looted.
local tmpLooted = {} -- Array with items looted recently.
local counter = 0 -- my way to do it.
local lastCounter = 0
local defaultColor = {r = 255, g = 200, b = 50} -- total random numbers
local hudx, hudY = 50, 30
local lootHUDs = {}
local duration = 0
--[[
INCREMENTATION
]]
-- here is [MENTION=56468]shadowart[/MENTION] 's function, its just increments difference beetwen lines. First its positioning hud on last spot then increment value for the next one if argument is true.
local hudy = function(add)
local last = hudY
if add then
hudY = hudY + 25
end
return last
end
HUD.New(hudx, hudy(true), "Recently Looted: ", defaultColor.r, defaultColor.g, defaultColor.b) -- Making header HUD.
--[[
TABLE FIND
]]
local tableFind = function(table, item)
for index, value in pairs(table) do
if value.itemek == item then
return true
end
end
end
--[[
ADDITEM FUNCTION
]]
local addItem = function(index)
local hud = lootHUDs[index]
if hud then
if tmpLooted[index].count >= 1 then
hud.name:SetText(tmpLooted[index].count .. "x " .. tmpLooted[index].itemek)
hud.img:SetItemID(Item.GetID(tmpLooted[index].itemek))
end
else
local hud = {}
hud.posy = hudy(false) + (index * 20)
hud.img = HUD.New(hudx - 30, hud.posy, Item.GetID(tmpLooted[index].itemek), dropColor.r, dropColor.g, dropColor.b)
hud.img:SetItemSize(10)
hud.name = HUD.New(hudx, hud.posy, tmpLooted[index].count .. "x " .. tmpLooted[index].itemek, dropColor.r, dropColor.g, dropColor.b)
lootHUDs[index] = hud
end
end
--[[
CLEARING HUD
]]
local clearHUDs = function()
for index = 1, #lootHUDs do
local hud = lootHUDs[index]
if hud then
hud.name:SetText('')
hud.img:SetItemID(296)
end
end
end
--[[
TALBE SORTER
]]
local tableSort = function(a, b)
return a.price > b.price
end
--[[
DURATION INCREMENTATION
]]
local refreshTable = function()
for index, item in pairs(tmpLooted) do
if item.dur >= lootDuration then
item.count = item.count - 1
end
end
end
--[[
LOOT PROXY
]]
local lootProxy = function(_, message)
-- tmpLooted = {}
refreshTable()
lastCounter = counter
counter = 0
clearHUDs()
local monster, loot = message:match('%a+%s%a+%s%a+%s(.+):%s(.+).')
for _, item in ipairs(items) do
if loot:find(item['name']) then
if not tableFind(tmpLooted, item['name'])then
table.insert(tmpLooted, {itemek = item['name'], dur = 1, price = item['price'], count = 1})
else
for index, itemm in pairs(tmpLooted) do
if itemm.itemek == item['name'] then
itemm.count = itemm.count + 1
end
end
end
table.insert(looted, item['name'])
counter = counter + 1
end
end
table.sort(tmpLooted, tableSort)
for index, item in pairs(tmpLooted) do
addItem(index)
end
if loot then
for index, item in pairs(tmpLooted) do
item.dur = item.dur + 1
end
end
end
LootMessageProxy.OnReceive("_", lootProxy)
Edit: now You can see the items are stacked.
New screenshot.
hud.png
Edit: Dont know why that highlight makes it commented. When you put this on your text editor its normal.