[MOD] HUD

Discussion in 'OTClient' started by gugu15, May 18, 2016.

  1. gugu15

    gugu15 Member

    Joined:
    Dec 15, 2014
    Messages:
    50
    Likes Received:
    24
    Best Answers:
    0
    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 (Text):
    1. hud.addText(text, id, color)
    2. hud.addItem(itemId, count)
    3. hud.clear()
    hud.lua
    Code (Text):
    1. hud = {}
    2. hud.widgets = {}
    3.  
    4. -- incremento = 202/286
    5. local map = modules.game_interface.getMapPanel()
    6.  
    7. function hud.updatePosition(old, new)
    8.     for k,v in pairs(hud.widgets) do
    9.         v:setX(((583 - new.height)*(202/286)) + 200)
    10.     end
    11. end
    12. function hud.online()
    13.     map.onGeometryChange = hud.updatePosition
    14.     g_ui.loadUI("hud")
    15. end
    16.  
    17. function hud.offline()
    18.     hud.clear()
    19. end
    20.  
    21. function hud.addText(text, id, color)
    22.     label = g_ui.createWidget("HUDLabel", map)
    23.     if id then
    24.         label:setId(id)
    25.     else
    26.         label:setId(#hud.widgets)
    27.     end
    28.     if color then
    29.         if color == "red" then label:setColor("#FF0000") end
    30.         if color == "green" then label:setColor("#00FF00") end
    31.         if color == "blue" then label:setColor("#0000FF")end
    32.         if color == "blue1" then label:setColor("#00BFFF") end
    33.         if color == "yellow" then label:setColor("#FFFF00") end
    34.     end
    35.     label:setText(text)
    36.     label:setX(((583 - map:getSize().height)*(202/286)) + 200)
    37.     if #hud.widgets > 0 then
    38.         label:addAnchor(AnchorTop, "prev", AnchorBottom)
    39.     end
    40.     label:hide()
    41.     label:show()
    42.     table.insert(hud.widgets, label)
    43.     return label
    44. end
    45.  
    46. function hud.addItem(id, count)
    47.     if not id then
    48.         return
    49.     end
    50.     local item = g_ui.createWidget("HUDItem", map)
    51.     item:setItemId(id)
    52.     item:setX(((583 - map:getSize().height)*(202/286)) + 200)
    53.     if count then
    54.         item:setText(tostring(count))
    55.     end
    56.     if #hud.widgets > 0 then
    57.         item:addAnchor(AnchorTop, "prev", AnchorBottom)
    58.     end
    59.     item:hide()
    60.     item:show()
    61.     table.insert(hud.widgets, item)
    62.     return item
    63. end
    64. function hud.clear()
    65.     for k,v in pairs(hud.widgets) do
    66.         v:destroy()
    67.     end
    68.     hud.widgets = {}
    69. end
    70.  

    hud.otmod
    Code (Text):
    1. Module
    2.   name: hud_mod
    3.   description: HUD
    4.   author: Karin Uzumaki
    5.   website: forum.tibiarpgbrasil.com
    6.   version: 1.1
    7.   autoload: true
    8.   scripts: [hud]
    9.   @onLoad: hud.online()
    10.   @onUnload: hud.offline()

    hud.otui
    Code (Text):
    1. HUDLabel < UILabel
    2.   font: verdana-11px-rounded
    3.   width: 300
    4. HUDItem < UIItem
    5.   size: 45 45
    6.   padding: 1
    7.   font: verdana-11px-rounded
    8.   text-align: bottom
    9.   border-color: white
    10.   color: white
    11.  
    12.   $disabled:
    13.     color: #646464
    14.  
    Image:[​IMG]
     
    Last edited: May 18, 2016
  2. ianelli

    ianelli Member

    Joined:
    Mar 18, 2010
    Messages:
    101
    Likes Received:
    20
    Best Answers:
    0
    Good job! =D
     
    gugu15 likes this.
  3. otavio101

    otavio101 Member

    Joined:
    Dec 14, 2010
    Messages:
    42
    Likes Received:
    2
    Best Answers:
    0
    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: Mar 20, 2017
    gugu15 likes this.

Share This Page

Loading...