Thread Tools Display Modes
03/30/14, 05:19 PM   #1
jokerfwb
Join Date: Mar 2014
Posts: 8
Requesting status bar tutorial.

This is based off the tutorial on this site. I was wondering if someone would please make a quick tutorial with explanations of creating a status bar like the HP and Stamina bars in EOS. I am trying to make a simple Exp bar that is visible on screen at al times. I have a very good basic understanding of programming in general but just need some help. On how to do some very basic things. Thanks for your help in advance.

My Lua

Code:
function MyFirstAddOnUpdate()
    playerExp = GetUnitXP("player")
    playerMaxExp = GetUnitXPMax('player')
    MyFirstAddonExperience:SetText(string.format("Experience: %d / %d ", playerExp, playerMaxExp))
    
end
My Xml

Code:
<GuiXml>
    <Controls>
        <TopLevelControl name="MyFirstAddon" mouseEnabled="true" movable = "true">
            <Dimensions x="200" y="20" />
            <Anchor point="CENTER" />
 
            <OnUpdate>
                MyFirstAddOnUpdate()
            </OnUpdate>
            
            <Controls>
                <Backdrop name="$(parent)BG"/>
                <Label name="$(parent)Experience" font="ZoFontAnnounceSmall" color="CFDCBD" wrapMode="ELLIPSIS" verticalAlignment="CENTER" text="Experience: ">
                    <AnchorFill />
                </Label>
            </Controls>
        </TopLevelControl>
    </Controls>
</GuiXml>
  Reply With Quote
03/30/14, 07:46 PM   #2
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
In the XML there, instead of creating a Label object, create a StatusBar object. You'll want to also give it a texture.

Then register for the XP events and change the value of the statusbar in the OnEvent handler.


I hope that's enough to get you started! Try it out and come back if you have more questions.
  Reply With Quote
03/31/14, 05:07 AM   #3
jokerfwb
Join Date: Mar 2014
Posts: 8
Seerah. Thank you for your response. I don't mean to sound like a complete noob but, I am. Could you give me a little more in depth explanation, not the code just expand a little bit. I have a very ruff idea what you mean by the OnEvent handler, and register for the xp events. I think I get the idea but not completely sure how to implement it. This is my first foray into programming beyond procedural code displayed in a console.
  Reply With Quote
03/31/14, 06:20 AM   #4
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
What you want is for changes to happen when your character gains xp. UI elements get modified based on these events (for example EVENT_EXPERIENCE_GAIN). You set up your addon with these 'hooks' that fire when the event happens.

The wiki has a nice intro to using event hooks in your addon. http://wiki.esoui.com/AddOn_Quick_Qu...events_work.3F
  Reply With Quote
03/31/14, 02:45 PM   #5
jokerfwb
Join Date: Mar 2014
Posts: 8
Code:
function MyAddOn_OnInitialized(self)
    --Register on the top level control...
    self:RegisterForEvent(EVENT_GROUP_INVITE_RECEIVED, OnGroupInviteReceived)
 
    --OR, register with a string unique to your add-on
    EVENT_MANAGER:RegisterForEvent("MyAddOn", EVENT_GROUP_INVITE_RECEIVED, OnGroupInviteReceived)
end
Let me see if I understand this. Basically you register for your app to listen for an event in my case it would be something like a change in exp. When my addon notices the event I'm looking for happen it calls the function you list in the arguments of the RegisterForEvent?
  Reply With Quote
03/31/14, 03:20 PM   #6
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
Originally Posted by jokerfwb View Post
Let me see if I understand this. Basically you register for your app to listen for an event in my case it would be something like a change in exp. When my addon notices the event I'm looking for happen it calls the function you list in the arguments of the RegisterForEvent?
Exactly. You can use the EVENT listings on the wiki to tell you what parameters are passed with the called function too.
  Reply With Quote
03/31/14, 03:59 PM   #7
jokerfwb
Join Date: Mar 2014
Posts: 8
Originally Posted by skyraker View Post
Exactly. You can use the EVENT listings on the wiki to tell you what parameters are passed with the called function too.
Can you explain this a little more. An example would be awesome.
  Reply With Quote
03/31/14, 04:10 PM   #8
skyraker
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 154
From my addon, the hook that uses EVENT_EXPERIENCE_UPDATE is:

EVENT_MANAGER:RegisterForEvent("MS", EVENT_EXPERIENCE_UPDATE, MS.updateEXP)

Code:
function MS.updateEXP(unit, xp, max, reason)
   -- my code
end
From the wiki:
EVENT_EXPERIENCE_UPDATE (string unitTag, integer currentExp, integer maxExp, integer reason)

So, your function called in RegisterForEvent has to handle these four parameters.
  Reply With Quote
03/31/14, 09:30 PM   #9
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 648
The first argument returned through the event handler is the event that occurred.
  Reply With Quote
04/09/14, 04:58 PM   #10
jokerfwb
Join Date: Mar 2014
Posts: 8
Originally Posted by Seerah View Post
The first argument returned through the event handler is the event that occurred.
Do you mean that it should be (reason, currentXP, maxXp, unitTag) or does it matter.
  Reply With Quote
04/10/14, 02:39 AM   #11
Kith
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 49
Originally Posted by jokerfwb View Post
Do you mean that it should be (reason, currentXP, maxXp, unitTag) or does it matter.
Not quite. The first return for (all?) events is a code that identifies the event itself which, I think for the most part, can be ignored. So for your experience event handler you'd want the following arguments:
Lua Code:
  1. function ExperienceEventHandler(eventCode, unitTag, currentExp, maxExp, reason)

The reason argument is presumably an identifier as to where you got that exp from, ie chest, mob, zone exploration etc.
  Reply With Quote
05/27/14, 03:01 PM   #12
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Here you go

Heres a beginners tutorial. It starts with addon/file structure and goes all the way through creating a working stamina bar.

http://wiki.esoui.com/Circonians_Stamina_Bar_Tutorial

glhfdgb
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Requesting status bar tutorial.


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off