Thread Tools Display Modes
06/25/21, 01:58 PM   #1
Styxius
Join Date: Jun 2021
Posts: 4
I'm missing something and I'm not quiet sure what.

Thanks to those in my prior post about some issues I was having in my script turned out to just be a typo creating the event error. I do get an error when I move my icon using the XML <OnMoveStop>
Error is the following:
STTrackerPanel_MoveStop:3: attempt to index a nil value
stack traceback:
STTrackerPanel_MoveStop:3: in function '(main chunk)'
|caaaaaa<Locals> self = ud </Locals>|r
I tried to add it as a function in the lua script that I saw some had suggested but haven't had much luck in that region either. Below I've linked the XML with the Lua below that. I'm fairly new to Lua and XML code so I apologize if these are common or amateur mistakes. Some lines were commented out as I was testing these resolutions in particular lines 55-56 in the lua (second block)

Lua Code:
  1. <GuiXml>
  2.     <Controls>
  3.         <TopLevelControl name="STTrackerPanel" resizeToFitDescendents="true" mouseEnabled="true" movable="true" clampedToScreen="true">
  4.             <Dimensions x="100" y="100" />
  5.             <Anchor point="CENTER" relativeTo="GuiRoot" relativePoint="CENTER" offsetX="0" offsetY="0" />
  6.             <OnMoveStop>
  7.                 STTracker.Move()
  8.             </OnMoveStop>
  9.             <Controls>
  10.                 <Label name="$(parent)_Proc" width="50" height="50" font="$(MEDIUM_FONT)|$(KB_32)|soft-shadow-thick" inheritAlpha="true" color="00e32a" wrapmode="TRUNCATE" verticalAlignment="CENTER" text="0" hidden="false">
  11.                     <Anchor points="TOP" relativeTo="$(parent)" relativePoint="TOP" />
  12.                 </Label>
  13.             </Controls>
  14.         </TopLevelControl>
  15.     </Controls>
  16. </GuiXml>

Lua Code:
  1. StoneTracker = {
  2.     name = "StoneTracker",
  3.     version = "1.0",
  4.     uiLocked = true,
  5.     STSet = "|H0:item:174258:364:50:0:0:0:0:0:0:0:0:0:0:0:1:122:0:1:0:10000:0|h|h", -- Used to get ID and set bonuses.
  6.     downTime = 0, -- proc cooldown timer
  7.     debuffTime = 0, -- Globabl debuff timer
  8.     defaults = {
  9.         ["panelCenterY"] = 500,
  10.         ["panelCenterX"] = 500,
  11.         ["procFontSize"] = 35,
  12.         ["procCDType"] = true,
  13.         ["passiveHide"] = false,
  14.         ["gearCheck"] = true,
  15.         ["updateInterval"] = 100,
  16.         ["colors"] = {
  17.             ["active"] = {
  18.                 0.05, 1, 0.1, 1
  19.             },
  20.             ["cooldown"] = {
  21.                 1, 0, 0,
  22.             },
  23.         },
  24.     },
  25. }
  26.  
  27. local STT = StoneTracker
  28. local EM = EVENT_MANAGER
  29.  
  30. function STT.STTCheck() --Check if the player has 5 pieces of StoneTalker  
  31.     if STT.savedVars.gearCheck then
  32.         local ST = 0
  33.         _,_,_, ST = GetItemLinkSetInfo (STT.STSet, true)
  34.         if ST < 3 then return false end
  35.         if ST >=3 then return true end
  36.     end
  37.     return true
  38. end
  39. --Check proc on any target by you
  40. function STT.Proc(eventCode, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log, sourceUnitId, targetUnitId, abilityId)
  41.     if STT.STTCheck() then
  42.         STT.active = false
  43.         STT.downTime = GetGameTimeMilliseconds ()/1000 + 10
  44.         EM:RegisterForUpdate(STT.name.."Update", STT.savedVars.updateInterval, STT.CountDown)
  45.     end
  46. end
  47.  
  48. function STT.Move()
  49.     STT.savedVars.panelCenterX, MTT.savedVars.panelCenterY = STTrackerPanel:GetCenter()
  50.     STTrackerPanel:ClearAnchors()
  51.     STTrackerPanel:SetAnchor(CENTER, GuiRoot, TOPLEFT, STT.savedVars.panelCenterX, STT.savedVars.panelCenterY)
  52. end
  53.  
  54. function STT.RestorePosition() --Load status panel position
  55. --    local panelCenterX = STT.savedVars.panelCenterX
  56. --    local panelCenterY = STT.savedVars.panelCenterY
  57.     if panelCenterX or panelCenterY then
  58.         STTrackerPanel:ClearAnchors()
  59.         STTrackerPanel:SetAnchor(CENTER, GuiRoot, TOPLEFT, STT.savedVars.OffsetX, STT.savedVars.OffsetY)
  60.     end
  61. end
  62.  
  63. function STT.CombatState() --Check player combat status
  64.     STT.HideOutOfCombat()
  65. end
  66.  
  67. function STT.HideOutOfCombat() --Allow panel to be hidden in combat.
  68.     if STT.STTCheck() then
  69.         if STT.savedVars.passiveHide then
  70.             STT.HidePanel (not IsUnitInCombat("player"))
  71.         end
  72.     end
  73. end
  74.  
  75. function STT.HideFrame() --Hide panel if opening menus.
  76.     if STT.STTCheck() then
  77.         STT.HidePanel(IsReticleHidden())
  78.     else
  79.         STT.HidePanel(true)
  80.     end
  81.     if not IsReticleHidden() then STT.HideOutOfCombat() end
  82. end
  83.  
  84. function STT.HidePanel(value)
  85.     STTrackerPanel:SetHidden(value)
  86.     end
  87.  
  88. --function STT.HideGlobalProcPanel(value) --Hide global ST debuff timer
  89. --    STTrackerPanel_GlobalProc:SetHidden(value)
  90. --end
  91.  
  92. function STT.CountDown() -- Update proc timers
  93.     local procThreshold = 0
  94.     if STT.savedVars.procCooldownType then procThreshold = 0 else procThreshold = 10 end
  95.     if (STT.downTime - GetGameTimeMilliseconds()/1000 > procThreshold) then
  96.         STTrackerPanel_Proc:SetColor (unpack(STT.savedVars.colors.cooldown))
  97.     else
  98.         STTrackerPanel_Proc:SetColor(unpack(STT.savedVars.colors.active))
  99.     end
  100.     STTrackerPanel_Proc:SetText(string.format("%.1f", STT.Time(STT.downTime, 10)))
  101.     if (STT.downTime - GetGameTimeMilliseconds()/1000 <= 0) then
  102.         STTrackerPanel_Proc:SetText("0")
  103.         EM:UnregisterForUpdate(STT.name.."Update")
  104.     end
  105. end
  106.  
  107. function STT.Time (nd, multiplier) --Rounds the timer down
  108.     return math.floor((nd - GetGameTimeMilliseconds()/1000) * multiplier + 0.5)/multiplier
  109. end
  110.  
  111. function STT.SetColors() --Set colors on update or loading
  112.         STTrackerPanel_Proc:SetColor(unpack(STT.savedVars.colors.active))
  113. end
  114.  
  115. function STT.SetFontSize() --Set Fonts for panel
  116.     STTrackerPanel_Proc:SetFont(string.format("%s|%d|%s", "$(CHAT_FONT)", STT.savedVars.procFontSize, "soft-shadow-thick"))
  117. end
  118.  
  119. function STT.RegisterProcEventType()
  120.     EM:UnregisterForUpdate(STT.name.."Proc")
  121.     local procEvent = STT.name.."Proc"
  122.         EM:RegisterForEvent (procEvent, EVENT_COMBAT_EVENT, STT.Proc)
  123.         EM:AddFilterForEvent(procEvent, EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, 154783)
  124.         EM:AddFilterForEvent(procEvent, EVENT_COMBAT_EVENT, REGISTER_FILTER_COMBAT_RESULT, ACTION_RESULT_EFFECT_GAINED)
  125.     EM:AddFilterForEvent(procEvent, EVENT_COMBAT_EVENT, REGISTER_FILTER_SOURCE_COMBAT_UNIT_TYPE, COMBAT_UNIT_TYPE_PLAYER)
  126. end
  127.  
  128. --function STTracker.move()
  129. --    STT.savedVars.OffsetX = STTrackerPanel:GetLeft()
  130. --    STT.savedVars.OffsetY = SSTrackerPanel:GetTop()
  131. --end
  132. function STT.AddNewVariables()
  133.     if STT.savedVars.colors.active == nil then STT.savedVars.colors.active = { } STT.savedVars.colors.active = {0.05, 1, 0.11, 1} end
  134.     if STT.savedVars.ProcFontSize == nil then STT.savedVars.ProcFontSize = 34 end
  135. end
  136.  
  137. function STT.Init(event, addon)
  138.     if addon ~= STT.name then return end
  139.     EM:UnregisterForEvent (STT.name.."Load", EVENT_ADD_ON_LOADED)
  140.     STT.savedVars = ZO_SavedVars:NewAccountWide("StoneSettings", StoneTracker.varVersion, nil, StoneTracker.defaults, GetWorldName())
  141.     STT.AddNewVariables()
  142.     STT.RegisterProcEventType()
  143.     STT.RestorePosition()
  144.     STTrackerPanel:SetHidden(IsReticleHidden())
  145.     STT.SetColors()
  146.     STT.SetFontSize()
  147.     STT.SetupMenu()
  148.     STT.HideOutOfCombat()
  149.     EM:RegisterForEvent(STT.name.."Hide", EVENT_RETICLE_HIDDEN_UPDATE, STT.HideFrame)
  150.     EM:RegisterForEvent(STT.name.."CombatState", EVENTER_PLAYER_COMBAT_STATE, STT.CombatState)
  151.     EM:RegisterForEvent(STT.name.."GearCheck", EVENT_INVENTORY_SINGLE_SLOT_UPDATE, STT.HideFrame)
  152. end
  153. function STT.SetupMenu()
  154.     local LAM2 = LibAddonMenu2
  155.  
  156.     local panelData = {
  157.         type = "panel",
  158.         name = STT.name,
  159.         displayName = "|cFF0000StoneTracker|",
  160.         version = ""..STT.version,
  161.     }
  162.    
  163.     LAM2:RegisterAddonPanel(STT.name.."Options", panelData)
  164.  
  165.     local options ={
  166.         {
  167.             type = "header",
  168.             name = "General Settings"
  169.         },
  170.     {
  171.         type = "checkbox",
  172.         name = "Lock UI",
  173.         tooltip = "Unlock to reposition timer to preferred location",
  174.         getFunc = function() return true end,
  175.         setFunc = function(value)
  176.             if not value then
  177.                 EVENT_MANAGER:UnregisterForEvent(STT.name.."Hide", EVENT_RETICLE_HIDDEN_UPDATE)
  178.                 STTrackerPanel:SetHidden(false)
  179.                 STTrackerPanel:SetMovable(true)
  180.                 STTrackerPanel:SetMouseEnabled(true)
  181.             else
  182.                 EVENT_MANAGER:RegisterForEvent(STT.name.."Hide", EVENT_RETICLE_HIDDEN_UPDATE, STT.HideFrame)
  183.                 STTrackerPanel:SetHidden(IsReticleHidden())
  184.                 STTrackerPanel:SetMovable(false)
  185.                 STTrackerPanel:SetMouseEnabled(false)
  186.             end
  187.         end
  188.         },
  189.     {
  190.             type = "checkbox",
  191.             name = "Gear Check",
  192.             tooltip = "Display status panel only if 3 or more pieces of StoneTalker's Oath are equipped",
  193.             getFunc = function() return STT.savedVars.gearCheck end,
  194.             setFunc = function(value)
  195.                 STT.savedVars.gearCheck = value
  196.                 STT.HideFrame()
  197.             end
  198.         },
  199.     {  
  200.             type = "checkbox",
  201.             name = "Display only when in Combat",
  202.             tooltip = "Rate that information about the cooldown is updated.",
  203.             getFunc = function() return STT.savedVars.passiveHide end,
  204.             setFunc = function(value)
  205.                 STT.savedVars.gearCheck = value
  206.                 STT.HideFrame()
  207.             end
  208.         },
  209.         {  
  210.             type = "slider",
  211.             name = "Update Intervals",
  212.             tooltip = "Rate that information about the cooldown is updated.",
  213.             getFunc = function() return STT.savedVars.updateInterval end,
  214.             setFunc = function(value) STT.savedVars.updateInterval = value end,
  215.             min = 100,
  216.             max = 1000,
  217.             step = 5,
  218.             default = 200,
  219.             width = "full",
  220.             },
  221.             {
  222.                 type = "header",
  223.                 name = "StoneTracker Proc Options"
  224.             },
  225.             {  
  226.                 type = "checkbox",
  227.                 name = "Change Stonetalker Color when available",
  228.                 tooltip = "Change color of the proc cooldown for when StoneTalker can be proc again. If set to false, will set color when the debuff ends.",
  229.                 getFunc = function() return (STT.savedVars.colors.active) end,
  230.                 setFunc = function(value)
  231.                     STT.savedVars.procCooldownType = value
  232.                 end
  233.             },
  234.         {
  235.              type = "slider",
  236.              name = "StoneTracker Cooldown font size",
  237.              tooltip = "Size of Font for StoneTracker cooldown",
  238.              getFunc = function() return STT.savedVars.procFontSize end,
  239.              setFunc = function(value) STT.savedVars.procFontSize = value STT.SetFontSize() end,
  240.              min = 10,
  241.              max = 72,
  242.              step = 1,
  243.              default = 32,
  244.              width = "full",
  245.         },
  246.     }
  247.     LAM2:RegisterOptionControls(STT.name.."Options", options)
  248. end
  249. EM:RegisterForEvent(STT.name.."Load", EVENT_ADD_ON_LOADED, STT.Init)

Thank you in advance anyone who offers assistance in a reply.
  Reply With Quote
06/26/21, 02:14 AM   #2
andy.s
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 40
Your addon is called StoneTracker, not STTracker. Just pay more attention to names and error messages (nil value = something doesn't exist).
  Reply With Quote
06/26/21, 04:37 AM   #3
rp12439_3
AddOn Author - Click to view addons
Join Date: Jun 2021
Posts: 45
You should call

STT.Move()

in your xml
  Reply With Quote
06/26/21, 07:01 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
And check the load order of the lua and xml files in your txt. If your xml is loaded first and the related variables in your xml were not in nitialized via the lua Code already, they are nil.
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » I'm missing something and I'm not quiet sure what.

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