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 |
ESOUI » Developer Discussions » Lua/XML Help » Event not being called? |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Switch to Linear Mode |
Switch to Hybrid Mode |
Threaded Mode |
|
|