Quantcast Event not being called? - ESOUI
Thread Tools Display Modes
12/11/18, 01:37 PM   #1
TheCrzyDoctor
Join Date: Dec 2018
Posts: 5
Event not being called?

I've been playing ESO on and off for a while. I've finally got around to looking into making my own addons. So I fillowed the Writing your first addon tutorial. Though Instead of doing incombat, i'm using zone change. I believe I have it set up correctly but when I change zones the label in the UI won't update nor will the new location be added to the chat.

my lua file
Code:
-- First, we create a namespace for our addon by declaring a top-level table that will hold everything else.
    TCDInfoPanel = {}

-- This isn't strictly necessary, but we'll use this string later when registering events.
-- Better to define it in a single place rather than retyping the same string.
    TCDInfoPanel.name = "TCDInfoPanel"

function TCDInfoPanel:RestorePosition()
    local left = self.savedVariables.left
    local top = self.savedVariables.top
    
    TCDInfoPanelUI:ClearAnchors()
    TCDInfoPanelUI:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, left, top)
end

-- Then we create an event handler function which will be called when the "addon loaded" event
-- occurs. We'll use this to initialize our addon after all of its resources are fully loaded.
function TCDInfoPanel.OnAddOnLoaded(event, addonName)
    -- The event fires each time *any* addon loads - but we only care about when our own addon loads.
    if addonName == TCDInfoPanel.name then
        TCDInfoPanel:Initialize()
    end
end

function TCDInfoPanel.OnIndicatorMoveStop()
    TCDInfoPanel.savedVariables.left = TCDInfoPanelUI:GetLeft()
    TCDInfoPanel.savedVariables.top = TCDInfoPanelUI:GetTop()
end

function TCDInfoPanel.ZoneChanged(eventCode, zoneName, subZoneName, newSubzone, zoneId, subZoneID)
    local zoneText
    -- Get the location of player
    zoneText=zoneName
    -- Debug testing post in chat.    
    d("zone changed to: " )
    d(zoneText)
    -- Update the label of the location.
    TCDInfoPanelUILocationLabel:SetText("Location Updated")
end

-- Initialize the addon
    function TCDInfoPanel:Initialize()
        -- Create saved variables.
        self.savedVariables = ZO_SavedVars:New("TCDInfoPanelAddonSavedVariables", 1, nil, {})
    
        -- Set up event changes to update location on info bar.
        EVENT_MANAGER:RegisterForEvent(self.name, EVENT_ZONE_CHANGED, self.ZoneChanged)
    
        -- Restore the previous location of the Addon.
        self:RestorePosition()
    end

-- Finally, we'll register our event handler function to be called when the proper event occurs.
EVENT_MANAGER:RegisterForEvent(TCDInfoPanel.name, EVENT_ADD_ON_LOADED, TCDInfoPanel.OnAddOnLoaded)
my xml file
Code:
<GuiXml>
    <Controls>
        <TopLevelControl name="TCDInfoPanelUI" mouseEnabled="true" movable="true" clampedToScreen="true">
            <Dimensions x="500" y="35" />
            <Anchor point="BOTTOM" relativeTo="GuiRoot" relativePoint="CENTER" />

            <OnMoveStop>
                TCDInfoPanel.OnIndicatorMoveStop()
            </OnMoveStop>

            <Controls>
                <Backdrop name="$(parent)BG" inherits="ZO_DefaultBackdrop" excludeFromResizeToFitExtents="true">
                    <AnchorFill />
                </Backdrop>
                <Control name="$(parent)Location">
                    <Dimensions x="80" y="35" />
                    <Anchor point="RIGHT" relativeTo="$(parent)" relativePoint="CENTER" />
                    <Controls>
                        <Label name="$(parent)LocationLabel" font="ZoFontGameMedium" inheritAlpha="true" color="ffffff"
                        wrapMode="TRUNCATE" verticalAlignment="CENTER" horizontalAlignment="CENTER" text="Location:">
                            <AnchorFill />
                        </Label>
                    </Controls>
                </Control>                
            </Controls>
        </TopLevelControl>
    </Controls>
</GuiXml>
Im a Python developer who is new to Lua. I'm sure I'm just over looking something very simple. Any points in the right direction would be awesome. This is all a base for a WoW UI mod I really enjoyed back when I played wow and havent found something similiar in ESO yet. SO I figured I'd bring it over.
  Reply With Quote
12/11/18, 02:06 PM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,252
Welcome to ESOUI!
Your code looks good at first glance. Aside from the label always being set to "Location Updated" instead of the zoneName, but that's probably something you changed to debug your code? Does the label show up in the UI, or is that missing too?

Here are a few things you could try:
  • Use /zgoo to see if the TCDInfoPanel exists.
  • If not, check that your manifest contains the correct file names and try to put an error("Hello World") in the first line of the Lua file to see if it is executed.
  • Per default the debug output is only shown on the first chat tab, so make sure you have that one selected.
  • Disable any other addons that may interfere with your code (just for testing).
__________________
Like what I do? Support me on Patreon!
>siri.exe MyAddon
Does your addon work? [y/n] n
There is a typo in there.
  Reply With Quote
12/11/18, 02:31 PM   #3
TheCrzyDoctor
Join Date: Dec 2018
Posts: 5
@sirinsidiator

The label does show up. Though it has the text that is inside the xml file at all times. See attachment underneath the compass.

You are correct in stating the label will always say Location Updated for debugging. I just used a 2 hour xp scroll. So I'm going to do some leveling and then come back to this and post my results on disabling all othe addons along with adding in error("Hello World").

As far as the chat tabs I only have one tab. This is to help me debug as I currently playing solo.

Update:
Added in error("Hello World") I do get an error window popping up.
I have disabled all other plugins to help debug this. Still no change.
Used /zgoo and not sure what that should show but nothing.
I added in error("Zone Chnaged") into my zone changed function and that doesn't execute. The event is not registered or something? I am using the correct event for the zoned changed correct? Along with the correct arguments that are passed in???

Update 2:
Addon is working now. I had to completely close out of ESO to have it start working. Not sure why as the tutorial is doesn't mention having to completely closing ESO.
Attached Thumbnails
Click image for larger version

Name:	20181211132613_1.jpg
Views:	33
Size:	713.3 KB
ID:	1067  

Last edited by TheCrzyDoctor : 12/11/18 at 09:08 PM. Reason: Got it to work.
  Reply With Quote
12/12/18, 02:34 AM   #4
Sordrak
 
Sordrak's Avatar
AddOn Author - Click to view addons
Join Date: May 2017
Posts: 35
Originally Posted by TheCrzyDoctor View Post
@sirinsidiator

The label does show up. Though it has the text that is inside the xml file at all times. See attachment underneath the compass.

You are correct in stating the label will always say Location Updated for debugging. I just used a 2 hour xp scroll. So I'm going to do some leveling and then come back to this and post my results on disabling all othe addons along with adding in error("Hello World").

As far as the chat tabs I only have one tab. This is to help me debug as I currently playing solo.

Update:
Added in error("Hello World") I do get an error window popping up.
I have disabled all other plugins to help debug this. Still no change.
Used /zgoo and not sure what that should show but nothing.
I added in error("Zone Chnaged") into my zone changed function and that doesn't execute. The event is not registered or something? I am using the correct event for the zoned changed correct? Along with the correct arguments that are passed in???

Update 2:
Addon is working now. I had to completely close out of ESO to have it start working. Not sure why as the tutorial is doesn't mention having to completely closing ESO.
Regarding Update 2:
Restarting the game is rarely required. I only experience this when adding new textures as they won't load when reloading the UI respectively switching chars.
Did you try a /reloadui after code changes? And that didn't work?
  Reply With Quote
12/12/18, 09:25 AM   #5
TheCrzyDoctor
Join Date: Dec 2018
Posts: 5
Originally Posted by Sordrak View Post
Regarding Update 2:
Restarting the game is rarely required. I only experience this when adding new textures as they won't load when reloading the UI respectively switching chars.
Did you try a /reloadui after code changes? And that didn't work?

Yes. After any change to the xml and lua files I use /reloadui. Not sure why but restarting the entire game helped it. Now the next mission is to get the label pushed to the left of the bar and get it to resize correctly.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Event not being called?

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