Thread Tools Display Modes
06/24/21, 06:01 PM   #1
Styxius
Join Date: Jun 2021
Posts: 4
Stumped on an error.

The error I'm getting:
Checking type on argument callback failed in ScriptEventManagerRegisterForUpdateLua
stack traceback:
[C]: in function 'RegisterForUpdate'
user:/AddOns/StoneTracker/StoneTracker.lua:45: in function 'STT.Proc'
|caaaaaa<Locals> eventCode = 131107, result = 2240, isError = F, abilityName = "Stone-Talker's Prayer", abilityGraphic = 48187, abilityActionSlotType = 0, sourceName = "kitplarty^Mx", sourceType = 1, targetName = "Target Skeleton, Robust Argoni...", targetType = 4, hitValue = 1, powerType = -1, damageType = 1, log = T, sourceUnitId = 35568, targetUnitId = 35568, abilityId = 154783 </Locals>|r


Here's my script atm Goal is making a Stone-talker tracker.
Lua Code:
  1. StoneTracker = {
  2.     name = "StoneTracker",
  3.     version = "1.0",
  4.     uiLocked = true,
  5.     STSet = "|H0:item:174277:33:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0: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"] = 60,
  12.         ["procCDType"] = true,
  13.         ["procGroupTracker"] = false,
  14.         ["passiveHide"] = false,
  15.         ["gearCheck"] = true,
  16.         ["updateInterval"] = 100,
  17.         ["colors"] = {
  18.             ["active"] = {
  19.                 0.05, 1, 0.1, 1
  20.             },
  21.             ["cooldown"] = {
  22.                 1, 0, 0,
  23.             },
  24.         },
  25.     },
  26. }
  27.  
  28. local STT = StoneTracker
  29. local EM = EVENT_MANAGER
  30.  
  31. function STT.STTCheck() --Check if the player has 5 pieces of StoneTalker  
  32.     if STT.savedVars.gearCheck then
  33.         local ST = 0
  34.         _,_,_, ST = GetItemLinkSetInfo (STT.STSet, true)
  35.         if ST < 3 then return false end
  36.         if ST >=3 then return true end
  37.     end
  38.     return true
  39. end
  40. --Check proc on any target by you
  41. function STT.Proc(eventCode, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log, sourceUnitId, targetUnitId, abilityId)
  42.     if STT.STTCheck() then
  43.         STT.active = false
  44.         STT.downTime = GetGameTimeMilliseconds ()/1000 + 10
  45.         EM:RegisterForUpdate(STT.name.."Update", STT.savedVars.updateInterval, STT.Countdown)
  46.     end
  47. end
  48.  
  49. --Check proc on any target by group
  50. function STT.GlobalProc(eventCode, result, isError, abilityName, abilityGraphic, abilityActionSlotType, sourceName, sourceType, targetName, targetType, hitValue, powerType, damageType, log, sourceUnitId, abilityId)
  51.     if STT.STTCheck() then
  52.     STT.active = false
  53.     STT.debuffTime = GetGameTimeMilliseconds()/1000 + 10
  54.     EM:RegisterForUpdate(STT.name.."GlobalUpdate",  STT.savedVars.updateInterval, STT.GlobalCountdown)
  55.   end
  56. end
  57.  
  58. function STT.RestorePosition() --Load status panel position
  59.     local panelCenterX = STT.savedVars.panelCenterX
  60.     local panelCenterY = STT.savedVars.panelCenterY
  61.     if panelCenterX or panelCenterY then
  62.         STTrackerPanel:ClearAnchors()
  63.         STTrackerPanel:SetAnchor(CENTER, GuiRoot, TOPLEFT, panelCenterX, panelCenterY)
  64.     end
  65. end
  66.  
  67. function STT.CombatState() --Check player combat status
  68.     STT.HideOutOfCombat()
  69. end
  70.  
  71. function STT.HideOutOfCombat() --Allow panel to be hidden in combat.
  72.     if STT.STTCheck() then
  73.         if STT.savedVars.passiveHide then
  74.             STT.HidePanel (not IsUnitInCombat("player"))
  75.         end
  76.     end
  77. end
  78.  
  79. function STT.HideFrame() --Hide panel if opening menus.
  80.     if STT.STTCheck() then
  81.         STT.HidePanel(IsReticleHidden())
  82.     else
  83.         STT.HidePanel(true)
  84.     end
  85.     if not IsReticleHidden() then STT.HideOutOfCombat() end
  86. end
  87.  
  88. function STT.HidePanel(value)
  89.     STTrackerPanel:SetHidden(value)
  90.     end
  91.  
  92. function STT.HideGlobalProcPanel(value) --Hide global ST debuff timer
  93.     STTrackerPanel_GlobalProc:SetHidden(value)
  94. end
  95.  
  96. function STT.CountDown() -- Update proc timers
  97.     local procThreshold = 0
  98.     if STT.savedVars.procCooldownType then procThreshold = 0 else procThreshold = 10 end
  99.     if (STT.downTime - GetGameTimeMilliseconds()/1000 > procThreshold) then
  100.         STTrackerPanel_Proc:SetColor (unpack(STT.savedVars.colors.cooldown))
  101.     else
  102.         STTrackerPanel_Proc:SetColor(unpack(STT.savedVars.colors.active))
  103.     end
  104.     STTrackerPanel_Proc:SetText(string.format("%.1f", STT.Time(STT.downTime, 10)))
  105.     if (STT.downTime - GetGameTimeMilliseconds()/1000 <= 0) then
  106.         STTrackerPanel_Proc:SetText("0")
  107.         EM:UnregisterForUpdate(STT.name.."Update")
  108.     end
  109. end
  110.  
  111. function STT.GlobalCountdown() -- Updates global debuff timers
  112.     if (STT.debuffTime - GetGameTimeMilliseconds ()/1000 > 0) then
  113.         STTrackerPanel_GlobalProc:SetColor (unpack (STT.savedVars.colors.cooldownGlobal))
  114.         STTrackerPanel_GlobalProc:SetText (string.format("%.1f", STT.Time (STT.debuffTime, 10)))
  115.     else
  116.         STTrackerPanel_GlobalProc:SetColor(unpack(STT.savedVars.colors.activeGlobal))
  117.             STTrackerPanel_GlobalProc:SetText("0")
  118.             EM:UnregisterForupdate(STT.name.."GlobalUpdate")
  119.     end
  120. end
  121.  
  122. function STT.Time (nd, multiplier) --Rounds the timer down
  123.     return math.floor((nd - GetGameTimeMilliseconds()/1000) * multiplier + 0.5)/multiplier
  124. end
  125.  
  126. function STT.SetColors() --Set colors on update or loading
  127.         STTrackerPanel_Proc:SetColor(unpack(STT.savedVars.colors.active))
  128.     STTrackerPanel_GlobalProc:SetColor(unpack(STT.savedVars.colors.activeGlobal))
  129. end
  130.  
  131. function STT.SetFontSize() --Set Fonts for panel
  132.     STTrackerPanel_Proc:SetFont(string.format("%s|%d|%s", "$(CHAT_FONT)", STT.savedVars.procFontSize, "soft-shadow-thick"))
  133.     STTrackerPanel_GlobalProc:SetFont(string.format("%s|%d|%s", "$(CHAT_FONT)", STT.savedVars.globalProcFontSize, "soft-shadow-thick"))
  134. end
  135.  
  136. function STT.RegisterProcEventType()
  137.     EM:UnregisterForUpdate(STT.name.."Proc")
  138.     EM:UnregisterForUpdate(STT.name.."GlobalProc")
  139.     local procEvent = STT.name.."Proc"
  140.         EM:RegisterForEvent (procEvent, EVENT_COMBAT_EVENT, STT.Proc)
  141.         EM:AddFilterForEvent(procEvent, EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, 154783)
  142.         EM:AddFilterForEvent(procEvent, EVENT_COMBAT_EVENT, REGISTER_FILTER_COMBAT_RESULT, ACTION_RESULT_EFFECT_GAINED)
  143.     EM:AddFilterForEvent(procEvent, EVENT_COMBAT_EVENT, REGISTER_FILTER_SOURCE_COMBAT_UNIT_TYPE, COMBAT_UNIT_TYPE_PLAYER)
  144.         if STT.savedVars.procGroupTracker then
  145.             local globalProcEvent = STT.name.."GlobalProc"
  146.             EM:RegisterForEvent(globalProcEvent, EVENT_COMBAT_EVENT, STT.GlobalProc)
  147.             EM:AddFilterForEvent(globalProcEvent, EVENT_COMBAT_EVENT, REGISTER_FILTER_ABILITY_ID, 154783)
  148.             EM:AddFilterForEvent(globalProcEvent, EVENT_COMBAT_EVENT, REGISTER_FILTER_COMBAT_RESULT, ACTION_RESULT_EFFECT_GAINED)
  149.             STT.HideGlobalProcPanel(false)
  150.         else
  151.             STT.HideGlobalProcPanel(true)
  152.      end
  153. end
  154.  
  155. function STT.AddNewVariables()
  156.     if STT.savedVars.procGroupTracker == nil then STT.savedVars.procGroupTracker = false end
  157.     if STT.savedVars.colors.activeGlobal == nil then STT.savedVars.colors.activeGlobal = { } STT.savedVars.colors.activeGlobal = {0.05, 1, 0.11, 1} end
  158.     if STT.savedVars.colors.cooldownnGlobal == nil then STT.savedVars.colors.cooldownGlobal = { } STT.savedVars.colors.cooldownGlobal = {1, 0.824, 0.18, 1} end
  159.     if STT.savedVars.globalProcFontSize == nil then STT.savedVars.globalProcFontSize = 34 end
  160. end
  161.  
  162. function STT.Init(event, addon)
  163.     if addon ~= STT.name then return end
  164.     EM:UnregisterForEvent (STT.name.."Load", EVENT_ADD_ON_LOADED)
  165.     STT.savedVars = ZO_SavedVars:NewAccountWide("StoneSettings", StoneTracker.varVersion, nil, StoneTracker.defaults, GetWorldName())
  166.     STT.AddNewVariables()
  167.     STT.RegisterProcEventType()
  168.     STT.RestorePosition()
  169.     STTrackerPanel:SetHidden(IsReticleHidden())
  170.     STT.SetColors()
  171.     STT.SetFontSize()
  172.     STT.SetupMenu()
  173.     STT.HideOutOfCombat()
  174.     EM:RegisterForEvent(STT.name.."Hide", EVENT_RETICLE_HIDDEN_UPDATE, STT.HideFrame)
  175.     EM:RegisterForEvent(STT.name.."CombatState", EVENTER_PLAYER_COMBAT_STATE, STT.CombatState)
  176.     EM:RegisterForEvent(STT.name.."GearCheck", EVENT_INVENTORY_SINGLE_SLOT_UPDATE, STT.HideFrame)
  177. end
  178. function STT.SetupMenu()
  179.     local LAM2 = LibAddonMenu2
  180.  
  181.     local panelData = {
  182.         type = "panel",
  183.         name = STT.name,
  184.         displayName = "|cFF0000StoneTracker|",
  185.         version = ""..STT.version,
  186.     }
  187.    
  188.     LAM2:RegisterAddonPanel(STT.name.."Options", panelData)
  189.  
  190.     local options ={
  191.         {
  192.             type = "header",
  193.             name = "General Settings"
  194.         },
  195.     {
  196.         type = "checkbox",
  197.         name = "Lock UI",
  198.         tooltip = "Unlock to reposition timer to preferred location",
  199.         getFunc = function() return true end,
  200.         setFunc = function(value)
  201.             if not value then
  202.                 EVENT_MANAGER:UnregisterForEvent(STT.name.."Hide", EVENT_RETICLE_HIDDEN_UPDATE)
  203.                 STTrackerPanel:SetHidden(false)
  204.                 STTrackerPanel:SetMovable(true)
  205.                 STTrackerPanel:SetMouseEnabled(true)
  206.             else
  207.                 EVENT_MANAGER:RegisterForEvent(STT.name.."Hide", EVENT_RETICLE_HIDDEN_UPDATE, STT.HideFrame)
  208.                 STTrackerPanel:SetHidden(IsReticleHidden())
  209.                 STTrackerPanel:SetMovable(false)
  210.                 STTrackerPanel:SetMouseEnabled(false)
  211.             end
  212.         end
  213.         },
  214.     {
  215.             type = "checkbox",
  216.             name = "Gear Check",
  217.             tooltip = "Display status panel only if 3 or more pieces of StoneTalker's Oath are equipped",
  218.             getFunc = function() return STT.savedVars.gearCheck end,
  219.             setFunc = function(value)
  220.                 STT.savedVars.gearCheck = value
  221.                 STT.HideFrame()
  222.             end
  223.         },
  224.     {  
  225.             type = "checkbox",
  226.             name = "Display only when in Combat",
  227.             tooltip = "Rate that information about the cooldown is updated.",
  228.             getFunc = function() return STT.savedVars.passiveHide end,
  229.             setFunc = function(value)
  230.                 STT.savedVars.gearCheck = value
  231.                 STT.HideFrame()
  232.             end
  233.         },
  234.         {  
  235.             type = "slider",
  236.             name = "Update Intervals",
  237.             tooltip = "Rate that information about the cooldown is updated.",
  238.             getFunc = function() return STT.savedVars.updateInterval end,
  239.             setFunc = function(value) STT.savedVars.updateInterval = value end,
  240.             min = 100,
  241.             max = 1000,
  242.             step = 5,
  243.             default = 200,
  244.             width = "full",
  245.             },
  246.             {
  247.                 type = "header",
  248.                 name = "StoneTracker Proc Options"
  249.             },
  250.             {  
  251.                 type = "checkbox",
  252.                 name = "Change Stonetalker Color when available",
  253.                 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.",
  254.                 getFunc = function() return (STT.savedVars.colors.active) end,
  255.                 setFunc = function(value)
  256.                     STT.savedVars.procCooldownType = value
  257.                 end
  258.             },
  259.             {
  260.                 type = "colorpicker",
  261.                 name = "Cooldown Color",
  262.                 tooltip = "Color of the timer when Stonetalker is able to be used",
  263.                 getFunc = function() return unpack(STT.savedVars.colors.active) end,
  264.                 setFunc = function(r,g,b,a)
  265.                     STT.savedVars.colors.active = {r,g,b,a}
  266.                     STT.SetColor()
  267.                 end,
  268.             },
  269.             {
  270.                 type = "colorpicker",
  271.                 name = "Cooldown Color",
  272.                 tooltip = "Color of timer when Stonetalker is unable to be used",
  273.                 getFunc = function() return unpack(STT.savedVars.colors.cooldown) end,
  274.                 setFunc = function(r,g,b,a)
  275.                     STT.savedVars.colors.cooldown = {r,g,b,a}
  276.                     STT.SetColors()
  277.                 end,
  278.             },
  279.         {
  280.              type = "slider",
  281.              name = "StoneTracker Cooldown font size",
  282.              tooltip = "Size of Font for StoneTracker cooldown",
  283.              getFunc = function() return STT.savedVars.procFontSize end,
  284.              setFunc = function(value) STT.savedVars.procFontSize = value STT.SetFontSize() end,
  285.              min = 10,
  286.              max = 72,
  287.              step = 1,
  288.              default = 32,
  289.              width = "full",
  290.         },
  291.         {
  292.             type = "header",
  293.             name = "Stonetalker Global Debuff Settings"
  294.         },
  295.         {
  296.             type = "checkbox",
  297.             name = "Track Group StoneTalker Procs",
  298.             tooltip = "Track Stonetalker's procs by anyone. This adds another timer to the status panel so you can view when you can cast.",
  299.             getFunc = function() return STT.savedVars.procGroupTracker end,
  300.             setFunc = function(value)
  301.                 STT.savedVars.procGroupTracker = value
  302.             STT.RegisterProcEventType()
  303.             end
  304.         },
  305.         {
  306.             type = "colorpicker",
  307.             name = "Available Color",
  308.             tooltip = "Color of debuff timer when there is no Stonetalker debuff is present",
  309.             getFunc = function() return unpack(STT.savedVars.colors.activeGlobal) end,
  310.             setFunc = function(r,g,b,a)
  311.                 STT.savedVars.colors.activeGlobal = {r,g,b,a}
  312.                 STT.SetColors()
  313.             end,
  314.         },
  315.         {
  316.             type = "colorpicker",
  317.             name = "Cooldown color",
  318.             tooltip = "Color of the debuff timer when Stonetalker is active on any target.",
  319.             getFunc = function() return unpack(STT.savedVars.colors.cooldownGlobal) end,
  320.             setFunc = function(r,g,b,a)
  321.                 STT.savedVars.cooldownGlobal = {r,g,b,a}
  322.                 STT.SetColor()
  323.             end
  324.         },
  325.     }
  326.     LAM2:RegisterOptionControls(STT.name.."Options", options)
  327. end
  328. EM:RegisterForEvent(STT.name.."Load", EVENT_ADD_ON_LOADED, STT.Init)
  Reply With Quote
06/24/21, 06:17 PM   #2
AlbinoPython
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 24
You might try changing
Code:
EM:RegisterForUpdate(STT.name.."Update", STT.savedVars.updateInterval, STT.Countdown)
with this
Code:
EM:RegisterForUpdate(STT.name.."Update", STT.savedVars.updateInterval, function() STT.Countdown() end)
  Reply With Quote
06/24/21, 06:19 PM   #3
Styxius
Join Date: Jun 2021
Posts: 4
Originally Posted by AlbinoPython View Post
You might try changing
Code:
EM:RegisterForUpdate(STT.name.."Update", STT.savedVars.updateInterval, STT.Countdown)
with this
Code:
EM:RegisterForUpdate(STT.name.."Update", STT.savedVars.updateInterval, function() STT.Countdown() end)
Edit: Thanks by the way for how much progress you helped with. Minor changes but it did help. I'm curious about this error as I have recently started learning Lua and am trying to understand these errors.
That did correct part of it, but now it generates this error:
user:/AddOns/StoneTracker/StoneTracker.lua:45: function expected instead of nil
stack traceback:
user:/AddOns/StoneTracker/StoneTracker.lua:45: in function '(anonymous)'

Last edited by Styxius : 06/24/21 at 06:34 PM.
  Reply With Quote
06/24/21, 10:29 PM   #4
Shinni
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 167
You got a typo
STT.Countdown vs STT.CountDown
  Reply With Quote
06/25/21, 10:09 AM   #5
Styxius
Join Date: Jun 2021
Posts: 4
Originally Posted by Shinni View Post
You got a typo
STT.Countdown vs STT.CountDown
Yep, that was it I was looking through it I have that part working I just have an error with my color picker and it doesn't save my variables when you move it. Outside of that, it's working now thankfully.
  Reply With Quote
06/26/21, 06:55 AM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Did you add the ## SavedVariable: tag with your table name to your Manifest txt file?
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Stumped on an error.

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