• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[MOD] HUD

gugu15

Well-Known Member
Joined
Dec 15, 2014
Messages
99
Reaction score
63
Hello boys.
Today I created a MOD that print itens and texts in top left of your screen.
This mod can to be used for print the any informations that you want.
You can select the colors of texts: "red","green", "yellow", "blue", "blue1"
My english is sad , sorry.
The MOD have the three functions:
Code:
hud.addText(text, id, color)
hud.addItem(itemId, count)
hud.clear()

hud.lua
Code:
hud = {}
hud.widgets = {}

-- incremento = 202/286
local map = modules.game_interface.getMapPanel()

function hud.updatePosition(old, new)
    for k,v in pairs(hud.widgets) do
        v:setX(((583 - new.height)*(202/286)) + 200)
    end
end
function hud.online()
    map.onGeometryChange = hud.updatePosition
    g_ui.loadUI("hud")
end

function hud.offline()
    hud.clear()
end

function hud.addText(text, id, color)
    label = g_ui.createWidget("HUDLabel", map)
    if id then
        label:setId(id)
    else
        label:setId(#hud.widgets)
    end
    if color then
        if color == "red" then label:setColor("#FF0000") end
        if color == "green" then label:setColor("#00FF00") end
        if color == "blue" then label:setColor("#0000FF")end
        if color == "blue1" then label:setColor("#00BFFF") end
        if color == "yellow" then label:setColor("#FFFF00") end
    end
    label:setText(text)
    label:setX(((583 - map:getSize().height)*(202/286)) + 200)
    if #hud.widgets > 0 then
        label:addAnchor(AnchorTop, "prev", AnchorBottom)
    end
    label:hide()
    label:show()
    table.insert(hud.widgets, label)
    return label
end

function hud.addItem(id, count)
    if not id then
        return
    end
    local item = g_ui.createWidget("HUDItem", map)
    item:setItemId(id)
    item:setX(((583 - map:getSize().height)*(202/286)) + 200)
    if count then
        item:setText(tostring(count))
    end
    if #hud.widgets > 0 then
        item:addAnchor(AnchorTop, "prev", AnchorBottom)
    end
    item:hide()
    item:show()
    table.insert(hud.widgets, item)
    return item
end
function hud.clear()
    for k,v in pairs(hud.widgets) do
        v:destroy()
    end
    hud.widgets = {}
end

hud.otmod
Code:
Module
  name: hud_mod
  description: HUD
  author: Karin Uzumaki
  website: forum.tibiarpgbrasil.com
  version: 1.1
  autoload: true
  scripts: [hud]
  @onLoad: hud.online()
  @onUnload: hud.offline()

hud.otui
Code:
HUDLabel < UILabel
  font: verdana-11px-rounded
  width: 300
HUDItem < UIItem
  size: 45 45
  padding: 1
  font: verdana-11px-rounded
  text-align: bottom
  border-color: white
  color: white

  $disabled:
    color: #646464
Image:
fbkzg6.png
 
Last edited:
Thx, just remember the item id is the .Spr .Dat and not the item.xml.



Edit: Use getClientId() in servside to send item.xml id.
 
Last edited:
Back
Top