Thread Tools Display Modes
03/12/17, 02:46 PM   #1
stypsy
Join Date: Aug 2014
Posts: 2
Looking for help with my first addon

Hello,

I'm looking for help with completing my first addon. The part I'm having difficulty with is writing the code to display the information I requested. The following is the addon I'm creating and as you can see in the Update Functions section ... I'm at a loss. Below the lua lines I have posted the xml code that I'm hoping will display rank points.

The reason I'm writing this is because I prefer to see rank points earned / rank points required to next level. Both are available on the PvP window but it takes a few clicks to get too and you have to stare at a large window that blocks the action. This way, with the addon, I should have a small moveable window that displays rank points earned / rank points needed.

Any help would be greatly appreciated,

Sty

----------------------------------------------------------------------------
LUA:
----------------------------------------------------------------------------
RankPoints = {}
*
-- Initialize Variables --

RankPoints.name = "RankPoints"
RankPoints.version = 1.0.0
*
-- OnAddOnLoaded --

function RankPoints.OnAddOnLoaded(event, addonName)
if addonName ~= RankPoints.name then return end
*
RankPoints:Initialize()
end
*
-- Initialize Function --

function RankPoints:Initialize()
local rpoints = GetUnitAvARankPoints(string unitTag)
local rneeded = GetNumPointsNeededForAvARank(number rank)
*
EVENT_MANAGER:UnregisterForEvent(RankPoints.name, EVENT_ADD_ON_LOADED)
end

*-- Update Functions --

function RankPoints.Update()
local

-- Register Events --

EVENT_MANAGER:RegisterForEvent(RankPoints.name, EVENT_ADD_ON_LOADED, RankPoints.OnAddOnLoaded)


XML:
<GuiXml>
<Controls>
<TopLevelControl name="RankPointsWindow" clampedToScreen="true" mouseenabled="true" movable="true" hidden="False">
<Dimensions x="200" y="50" />
<Anchor point="CENTER" />

<OnUpdate>
RankPointsUpdate()
</OnUpdate>

<OnInitialized>
RankPointsInitialized()
</OnInitialized>

<Controls>
<Backdrop name="$(parent)BG" inherits="ZO_ThinBackdrop" />
<Label name="$(parent)Counter" font="ZoFontWindowTitle" colo"CFDCBD" wrapMode="ELLISIS" verticalAlignment="CENTER" text="Counter: ">
<AnchorFill />
</Label>
</Controls>
</TopLevelControl>
</Controls>
</GuiXml>
  Reply With Quote
03/12/17, 03:11 PM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
In your XML it should be:
RankPoints.Update()

The XML be loaded after your Lua file, because otherwise the function may not defined the first time been called.
And I don't see a Initialized() function?!?
RankPoints:Initialize() will be called from RankPoints.OnAddOnLoaded already.
  Reply With Quote
03/12/17, 07:20 PM   #3
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 408
Have you tried littering it with d()? I usually find that helps a lot, as then you can narrow down what's getting run/not getting run. I'd also suggest adding an optional dependency on pChat, for stuff that loads before d() is active.
  Reply With Quote
03/13/17, 04:05 PM   #4
stypsy
Join Date: Aug 2014
Posts: 2
Thank you for the tips

Votan,

I have fixed the missing period in the RankPoints.Update().
-Thank you for that catch

As for the not having an Initialized() function, I thought I had it but I'll look through the guides again to see what I'm missing.

Dolgubon,

Thank you for the tip in using d() to narrowing down the problem.

And thank you both for taking the time to help me with my addon!

Sty
  Reply With Quote
03/13/17, 04:14 PM   #5
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
This part

Code:
<OnInitialized>
RankPointsInitialized()
</OnInitialized>
Shouldn't be necessary since

Code:
EVENT_MANAGER:RegisterForEvent(RankPoints.name, EVENT_ADD_ON_LOADED, RankPoints.OnAddOnLoaded)
already did it. And you also don't appear to actually HAVE a function named "RankPointsInitialized" in the first place?
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Looking for help with my first addon

Thread Tools
Display Modes

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