|
12/11/18, 01:37 PM | #1 | |
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) 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> |
|
TheCrzyDoctor |
View Public Profile |
Find More Posts by TheCrzyDoctor |
12/11/18, 02:06 PM | #2 |
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:
|
|
12/11/18, 02:31 PM | #3 | |
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. Last edited by TheCrzyDoctor : 12/11/18 at 09:08 PM. Reason: Got it to work. |
|
TheCrzyDoctor |
View Public Profile |
Find More Posts by TheCrzyDoctor |
12/12/18, 02:34 AM | #4 | |
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? |
||
12/12/18, 09:25 AM | #5 | ||
Join Date: Dec 2018
Posts: 5
|
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. |
||
TheCrzyDoctor |
View Public Profile |
Find More Posts by TheCrzyDoctor |
ESOUI » Developer Discussions » Lua/XML Help » Event not being called? |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Hybrid Mode |
Switch to Threaded Mode |
|
|