ascott18 / TellMeWhen

TellMeWhen is a combat tracking AddOn for World of Warcraft Retail and Classic
https://wow.curseforge.com/projects/tellmewhen
GNU General Public License v3.0
86 stars 11 forks source link

[CF 959] Event Handler Causing Error on Login #980

Closed tmw-issue-import closed 10 years ago

tmw-issue-import commented 10 years ago

I am building my first in depth setup of TMW for a windwalker monk.  I must also note I have for the first time even looked at LUA code 2 days ago.  I built a snippet to calculate the health loss threshold required before Expel Harm becomes better than Jab.  Now I get an error on login.  Running the script after login works as expected.  I have had this issue before with a variable being nil but The error I get is

[string "TMW Snippet: GetSpellDamage"] line 63:
   attempt to call global 'AddEventListener' (a nil value)

I hope it is OK to post this question here.  I don't understand how things are loaded when wow is starting.

What steps will reproduce the problem?
1. Load up the profile and the two global snippets
2. Run the snippets and everything works fine.
3. Log out and back in and an error occurs due to an event being nil (whatever that means)

What do you expect to happen? What happens instead?

What version of TellMeWhen are you using? ("The latest" is not a version)
TMW v7.0.0

Do you have an error log of what happened?
Date: 2014-06-22 00:00:19
ID: 1
Error occured in: Global
Count: 1
Message: [string "TMW Snippet: GetSpellDamage"] line 63:
   attempt to call global 'AddEventListener' (a nil value)
Debug:
   [string "TMW Snippet: GetSpellDamage"]:63: func()
   ...Ons\TellMeWhen\Components\Core\Snippets\Snippets.lua:67: RunSnippet()
   ...Ons\TellMeWhen\Components\Core\Snippets\Snippets.lua:52:
      ...Ons\TellMeWhen\Components\Core\Snippets\Snippets.lua:38
   (tail call): ?
   [C]: ?
   [string "safecall Dispatcher[1]"]:9:
      [string "safecall Dispatcher[1]"]:5
   (tail call): ?
   TellMeWhen\TellMeWhen.lua:1575: Fire()
   TellMeWhen\TellMeWhen.lua:1794: Initialize()
   TellMeWhen\TellMeWhen.lua:3121: UpdateNormally()
   TellMeWhen\TellMeWhen.lua:3304: Update()
   TellMeWhen\TellMeWhen.lua:1877: ?()
   ...ibDataBroker\CallbackHandler\CallbackHandler-1.0.lua:147:
      ...ibDataBroker\CallbackHandler\CallbackHandler-1.0.lua:147
   [string "safecall Dispatcher[1]"]:4:
      [string "safecall Dispatcher[1]"]:4
   [C]: ?
   [string "safecall Dispatcher[1]"]:13: ?()
   ...ibDataBroker\CallbackHandler\CallbackHandler-1.0.lua:92: Fire()
   ...AddOns\AutoVendor\libs\AceEvent-3.0\AceEvent-3.0.lua:120:
      ...AddOns\AutoVendor\libs\AceEvent-3.0\AceEvent-3.0.lua:119
Locals:
None
AddOns:
  Swatter, v5.19.5445 (QuiescentQuoll)
  AucAdvanced, v5.19.5445 (QuiescentQuoll)
  AucFilterBasic, v5.19.5445 (QuiescentQuoll)
  AucFilterOutlier, v5.19.5445.5437(5.19/embedded)
  AucMatchUndercut, v5.19.5445.5364(5.19/embedded)
  AucStatHistogram, v5.19.5445 (QuiescentQuoll)
  AucStatiLevel, v5.19.5445 (QuiescentQuoll)
  AucStatPurchased, v5.19.5445 (QuiescentQuoll)
  AucStatSales, v5.19.5445.5376(5.19/embedded)
  AucStatSimple, v5.19.5445 (QuiescentQuoll)
  AucStatStdDev, v5.19.5445 (QuiescentQuoll)
  AucStatWOWEcon, v5.19.5445.5323(5.19/embedded)
  AucUtilAHWindowControl, v5.19.5445.5347(5.19/embedded)
  AucUtilAppraiser, v5.19.5445.5438(5.19/embedded)
  AucUtilAskPrice, v5.19.5445.5347(5.19/embedded)
  AucUtilAutoMagic, v5.19.5445.5443(5.19/embedded)
  AucUtilCompactUI, v5.19.5445.5444(5.19/embedded)
  AucUtilEasyBuyout, v5.19.5445.5427(5.19/embedded)
  AucUtilFixAH, v5.19.5445 (QuiescentQuoll)
  AucUtilItemSuggest, v5.19.5445.5417(5.19/embedded)
  AucUtilPriceLevel, v5.19.5445.5444(5.19/embedded)
  AucUtilScanButton, v5.19.5445.5403(5.19/embedded)
  AucUtilScanFinish, v5.19.5445.5347(5.19/embedded)
  AucUtilScanProgress, v5.19.5445.4979(5.19/embedded)
  AucUtilScanStart, v5.19.5445.5347(5.19/embedded)
  AucUtilSearchUI, v5.19.5445.5373(5.19/embedded)
  AucUtilSimpleAuction, v5.19.5445.5415(5.19/embedded)
  AucUtilVendMarkup, v5.19.5445.4828(5.19/embedded)
  AutoVendor, v0.23
  Babylonian, v5.1.DEV.332(/embedded)
  BagBrother, v
  Bagnon, v5.4.15
  BeanCounter, v5.19.5445 (QuiescentQuoll)
  Configator, v5.1.DEV.359(/embedded)
  DBMCore, v
  DBMDefaultSkin, v
  DBMStatusBarTimers, v
  DebugLib, v5.1.DEV.337(/embedded)
  EasyMail, v
  ElvUI, v6.9997
  Enchantrix, v5.19.5445 (QuiescentQuoll)
  EnchantrixBarker, v5.19.5445 (QuiescentQuoll)
  GoGoMount, v5.4.12
  hack, vrelease_v1.4.4
  Informant, v5.19.5445 (QuiescentQuoll)
  LibExtraTip, v5.12.DEV.355(/embedded)
  Recount, v
  SlideBar, v5.19.5445 (QuiescentQuoll)
  Spy, v3.1.4
  Stubby, v5.19.5445 (QuiescentQuoll)
  TellMeWhen, v7.0.0
  TipHelper, v5.12.DEV.351(/embedded)
  TomTom, vv50400-1.0.0
  BlizRuntimeLib_enUS v5.4.8.50400 <us>
  (ck=84d)

Please provide any additional information below (including any export strings if applicable; see above.)
Here is the export string for the profile.
^1^T^SNumGroups^N6 ^SGroups^T ^N1^T ^SPoint^T ^Sy^F-7147680456757209 ^f-46^Sx ^F-4920265753688819^f-45 ^Spoint^STOPRIGHT ^SrelativePoint^STOPRIGHT ^t^SScale^F4766319018770432 ^f-51^SIcons ^T^N1^T ^SUnit^Splayer;~`raid~`1-40;~`party~`1-4 ^SType^Sbuffcheck ^SUnitConditions^T ^N1^T ^SType^SBUFFDUR ^SName^SMark~`of~`the~`Wild ^t^N2^T ^SType^SBUFFDUR ^SName^SBlessing~`of~`Kings ^t^Sn^N2 ^t^SName^SIncreasedStats ^SHideIfNoUnits^B ^SCustomTex^S115921 ^SEnabled^B ^t^t^SGUID^STMW:group:1JerILm=WSqs ^SName^SBuffs ^SConditions^T ^N1^T ^SType^SMOUNTED ^SLevel^N1 ^t^N2^T ^SType^SINPETBATTLE ^SLevel^N1 ^t^Sn^N2 ^t^t^N2^T ^SView^Sbar ^SPoint^T ^Sy^F6438736060809314 ^f-46^Sx ^F-5875764637794921^f-45 ^Spoint^SRIGHT ^SrelativePoint^SRIGHT ^t^SRows^N4 ^SIcons^T ^N3^T ^SShowTimer^B ^SBuffOrDebuff^SHARMFUL ^SUnit^Starget ^SType^Sbuff ^SUnAlpha^N0.75 ^SBarDisplay_EnableColors^B ^SName^SIncapacitated ^SBarDisplay_CompleteColor^T ^Sr^N1 ^Sg^N0 ^t^SOnlyMine^B ^SEvents^T ^N1^T ^SType^SAnimations ^SEvent^SOnShow ^t^Sn^N1 ^t^SEnabled^B ^SBarDisplay_StartColor^T ^Sr^N0 ^Sg^N1 ^t^t^N4^T ^SBarDisplay_StartColor^T ^Sr^N0 ^Sg^N1 ^Sb^F7912206404164635 ^f-58^t ^SOnlyMine^B ^SType^Sbuffcheck ^SBarDisplay_BarGCD^B ^SName^STiger~`Power ^SBarDisplay_CompleteColor^T ^Sr^N1 ^Sg^F7347048803867161 ^f-57^t ^SConditions^T ^N1^T ^SType^SCOMBAT ^SAndOr^SOR ^t^Sn^N1 ^t^SBarDisplay_EnableColors^B ^SUnAlpha^N0.75 ^SEvents^T ^N1^T ^SPassingCndt^B ^SType^SAnimations ^SCndtJustPassed^B ^SDuration^N8 ^SValue^N3 ^SAnimation^SICONFLASH ^SEvent^SOnDuration ^t^N2^T ^SType^SAnimations ^SAnimation^SICONFADE ^SEvent^SOnAlphaInc ^t^N3^T ^SType^SAnimations ^SAnimation^SICONFADE ^SEvent^SOnAlphaDec ^t^Sn^N3 ^t^SSettingsPerView^T ^Sbar^T ^STextLayout^Sbar1 ^t^t^SShowWhen^N3 ^SEnabled^B ^t^t^SGUID^STMW:group:1JerILm=d23R ^SName^SBuff~`Timers ^SColumns^N1 ^t^N3^T ^SPoint^T ^Sy^F4968655025236317 ^f-45^Sx ^F-6886617435894768^f-45 ^t^SScale^F6154996559804284 ^f-52^SRows ^N2^SIcons ^T^N1^T ^SOnlyEquipped^B ^SType^Sitem ^SOnlyInBags^B ^SName^S62966 ^SEnabled^B ^t^N2^T ^SOnlyEquipped^B ^SType^Sitem ^SConditions^T ^N1^T ^SType^SCOMBAT ^t^Sn^N1 ^t^SOnlyInBags^B ^SName^S63245 ^SEnabled^B ^t^t^SColumns^N1 ^SGUID^STMW:group:1JerILm=uwoq ^SName^STrinkets ^SConditions^T ^N1^T ^SType^SCOMBAT ^t^N2^T ^SType^SMOUNTED ^SLevel^N1 ^t^Sn^N2 ^t^t^N4^T ^SGUID^STMW:group:1JerMVo0K7ok ^SPoint^T ^Sy^F-6273824845211316 ^f-50^Sx ^F-4683559703426544^f-46 ^Spoint^SBOTTOM ^SrelativePoint^SBOTTOM ^t^SScale^F8890436810702847 ^f-52^SRows ^N9^SRole ^N1^SColumns ^N1^SOnlyInCombat ^B^SIcons ^T^N1^T ^SType^Smeta ^SIcons^T ^N1^STMW:icon:1Jes5qELhmX8 ^N2^STMW:icon:1Jev0TcMXhOH ^N3^STMW:icon:1Jev0OeXwolw ^N4^STMW:icon:1Jes5qEJIQlc ^N5^STMW:icon:1Jes5qEO0Ubg ^N6^STMW:icon:1Jex3swtIFod ^N7^STMW:icon:1Jes5qE0id0P ^N8^STMW:icon:1Jes5qE9xFWT ^t^SEnabled^B ^t^N2^T ^SType^Scooldown ^SConditions^T ^N1^T ^SType^SBUFFDUR ^SOperator^S< ^SName^STiger~`Power ^SLevel^N3 ^t^N2^T ^SType^SCHI ^SOperator^S>= ^SLevel^N1 ^t^Sn^N2 ^t^SName^STiger~`Palm ^SGUID^STMW:icon:1Jes5qELhmX8 ^SUnAlpha^N0 ^SCustomTex^S100787 ^SManaCheck^B ^SFakeHidden^B ^SOverlay_BarGCD^B ^SEnabled^B ^t^N3^T ^SType^Scooldown ^SName^SRising~`Sun~`Kick ^SManaCheck^B ^SConditions^T ^N1^T ^SType^SCHI ^SOperator^S>= ^SLevel^N2 ^t^Sn^N1 ^t^SEnabled^B ^SGUID^STMW:icon:1Jev0TcMXhOH ^SFakeHidden^B ^t^N4^T ^SType^Sbuff ^SName^SCombo~`Breaker:~`Blackout~`Kick ^SClockGCD^B ^SCustomTex^S100784 ^SEnabled^B ^SGUID^STMW:icon:1Jev0OeXwolw ^SFakeHidden^B ^SOverlay_BarGCD^B ^t^N5^T ^SType^Sbuff ^SName^SCombo~`Breaker:~`Tiger~`Palm ^SShowTimerTextnoOCC^B ^SClockGCD^B ^SCustomTex^S100787 ^SEnabled^B ^SGUID^STMW:icon:1Jes5qEJIQlc ^SFakeHidden^B ^SOverlay_BarGCD^B ^t^N6^T ^SType^Scooldown ^SName^SBlackout~`Kick ^SGUID^STMW:icon:1Jes5qEO0Ubg ^SConditions^T ^N1^T ^SType^SCHI ^SOperator^S>= ^SLevel^N2 ^t^Sn^N1 ^t^SFakeHidden^B ^SEnabled^B ^SManaCheck^B ^SOverlay_BarGCD^B ^t^N7^T ^SShowTimer^B ^SType^Scooldown ^SName^SExpel~`Harm ^SManaCheck^B ^SClockGCD^B ^SConditions^T ^N1^T ^SType^SCHI ^SOperator^S< ^SLevel^N3 ^t^N2^T ^SType^SLUA ^SName^S(UnitHealthMax("player")~`-~`UnitHealth("player"))>ExpelHarmThreshold ^t^Sn^N2 ^t^SEnabled^B ^SGUID^STMW:icon:1Jes5qE0id0P ^SFakeHidden^B ^t^N8^T ^SShowTimer^B ^SType^Scooldown ^SName^SJab ^SClockGCD^B ^SConditions^T ^N1^T ^SType^SCHI ^SOperator^S< ^SLevel^N3 ^t^Sn^N1 ^t^SCustomTex^S115695 ^SEnabled^B ^SGUID^STMW:icon:1Jes5qE9xFWT ^SFakeHidden^B ^t^N9^T ^SType^Scooldown ^SName^SChi~`Wave ^SShowTimerTextnoOCC^B ^SUnAlpha^N0 ^SShowWhen^N3 ^SEnabled^B ^SGUID^STMW:icon:1Jex3swtIFod ^SFakeHidden^B ^SConditions^T ^N1^T ^SType^SENERGY ^SOperator^S< ^SLevel^N75 ^t^Sn^N1 ^t^t^t^STree2^b ^STree1^b ^SName^SPrimary~`DPS~`Rotation ^t^N5^T ^SGUID^STMW:group:1JerSnSp4hsg ^SPoint^T ^Sy^F7081434334659946 ^f-47^Sx ^F8444320707905785^f-47 ^t^SScale^F8894614740140030 ^f-52^SRole ^N1^SIcons ^T^N1^T ^SCLEUEvents^T ^SSPELL_CAST_FAILED^B ^SSPELL_CAST_SUCCESS^B ^SSPELL_INTERRUPT^B ^SSPELL_CAST_START^B ^SSPELL_INTERRUPT_SPELL^B ^t^SType^Scleu ^SSourceUnit^Starget ^SConditions^T ^N1^T ^SType^SSPELLCD ^SName^SSpear~`Hand~`Strike ^t^N2^T ^SType^SLUA ^SName^Sselect(8,~`UnitChannelInfo("target"))~`~`==~`false ^SPrtsBefore^N1 ^t^N3^T ^SType^SLUA ^SPrtsAfter^N1 ^SName^Sselect(9,~`UnitCastingInfo("target"))~`==~`false ^SAndOr^SOR ^t^Sn^N3 ^t^SEvents^T ^N1^T ^SType^SAnimations ^SAnimation^SICONSHAKE ^SEvent^SOnShow ^t^N2^T ^SType^SSound ^SSound^STMW~`-~`Pling~`1 ^SEvent^SOnShow ^t^N3^T ^SType^SAnimations ^SAnimation^SACTVTNGLOW ^SEvent^SOnShow ^SInfinite^B ^t^N4^T ^SType^SAnimations ^SAnimation^SICONCLEAR ^SEvent^SOnHide ^t^Sn^N4 ^t^SSettingsPerView^T ^Sicon^T ^STexts^T ^N1^S[CastEndDuration(unit="target")] ^N2^S[Stacks:Hide(0)] ^t^t^t^SCustomTex^S116705 ^SEnabled^B ^SUnAlpha^N0.1 ^SSourceFlags^N2147454920 ^t^N2^T ^SType^Smeta ^SIcons^T ^N1^STMW:icon:1JfB9rI902sa ^N2^STMW:icon:1JfB9rI4VgCH ^t^SEnabled^B ^t^N3^T ^SCLEUEvents^T ^SSPELL_AURA_APPLIED_DOSE^B ^SSPELL_AURA_REMOVED_DOSE^B ^SSPELL_STOLEN^B ^SSPELL_AURA_REMOVED^B ^SSPELL_AURA_BROKEN_SPELL^B ^SSPELL_DISPEL_FAILED^B ^SSPELL_AURA_APPLIED^B ^SSPELL_DISPEL^B ^SSPELL_AURA_BROKEN^B ^SSPELL_AURA_REFRESH^B ^t^SType^Scleu ^SConditions^T ^N1^T ^SType^SLUA ^SName^SUnitDebuffTypeCheck("player","Poison") ^SPrtsBefore^N1 ^t^N2^T ^SType^SLUA ^SPrtsAfter^N1 ^SName^SUnitDebuffTypeCheck("player","Disease") ^SAndOr^SOR ^t^N3^T ^SType^SSPELLCD ^SName^SDetox ^t^Sn^N3 ^t^SUnAlpha^N0.1 ^SEvents^T ^N1^T ^SType^SAnimations ^SAnimation^SICONSHAKE ^SEvent^SOnShow ^t^N2^T ^SType^SSound ^SSound^STMW~`-~`Ding~`9 ^SEvent^SOnShow ^t^N3^T ^SType^SAnimations ^SAnimation^SACTVTNGLOW ^SEvent^SOnShow ^SInfinite^B ^t^N4^T ^SType^SAnimations ^SAnimation^SICONCLEAR ^SEvent^SOnHide ^t^Sn^N4 ^t^SSettingsPerView^T ^Sicon^T ^STexts^T ^N2^S[Stacks:Hide(0)] ^t^t^t^SCustomTex^S115450 ^SEnabled^B ^t^N4^T ^SShowTimer^B ^SBuffOrDebuff^SHARMFUL ^SType^Sbuff ^SUnAlpha^N0.1 ^SName^SFeared;~`Rooted;~`Stunned ^SEvents^T ^N1^T ^SType^SAnimations ^SAnimation^SICONSHAKE ^SEvent^SOnShow ^t^N2^T ^SType^SAnimations ^SAnimation^SACTVTNGLOW ^SEvent^SOnShow ^SInfinite^B ^t^N3^T ^SType^SAnimations ^SAnimation^SICONCLEAR ^SEvent^SOnHide ^t^Sn^N3 ^t^SCustomTex^S137562 ^SEnabled^B ^t^N5^T ^SType^Sbuff ^SConditions^T ^N1^T ^SType^SBUFFSTACKS ^SOperator^S>= ^SName^S125195 ^SLevel^N10 ^t^Sn^N1 ^t^SName^S116740 ^SEvents^T ^N1^T ^SType^SAnimations ^SAnimation^SICONSHAKE ^SEvent^SOnShow ^t^N2^T ^SType^SSound ^SSound^STMW~`-~`Pling~`4 ^SEvent^SOnShow ^t^N3^T ^SType^SAnimations ^SAnimation^SACTVTNGLOW ^SEvent^SOnShow ^SInfinite^B ^t^N4^T ^SType^SAnimations ^SAnimation^SICONCLEAR ^SEvent^SOnHide ^t^Sn^N4 ^t^SEnabled^B ^t^N6^T ^SType^Scooldown ^SName^STouch~`of~`Death ^SConditions^T ^N1^T ^SType^SLUA ^SName^S(UnitHealth("player")~`or~`0)~`>~`(UnitHealth("target")~`or~`0) ^t^N2^T ^SType^SISPLAYER ^SUnit^Starget ^SLevel^N1 ^t^N3^T ^SType^SCHI ^SOperator^S< ^SLevel^N3 ^t^Sn^N3 ^t^SUnAlpha^N0.1 ^SEvents^T ^N1^T ^SType^SAnimations ^Sa_anim^N0.61 ^SImage^S115080 ^SAnimation^SICONOVERLAYIMG ^SEvent^SOnShow ^SInfinite^B ^t^N2^T ^SType^SAnimations ^Sa_anim^N0 ^SAnimation^SICONALPHAFLASH ^SEvent^SOnHide ^t^Sn^N2 ^t^SCustomTex^S115399 ^SEnabled^B ^SGUID^STMW:icon:1JfB9rI4VgCH ^SFakeHidden^B ^t^N7^T ^SShowTimer^B ^SType^Scooldown ^SUnAlpha^N0.1 ^SShowTimerText^B ^SName^STouch~`of~`Death ^SConditions^T ^N1^T ^SType^SLUA ^SName^S(UnitHealth("player")~`or~`0)~`>~`(UnitHealth("target")~`or~`0) ^t^N2^T ^SType^SISPLAYER ^SUnit^Starget ^SLevel^N1 ^t^N3^T ^SType^SCHI ^SOperator^S>= ^SLevel^N3 ^t^N4^T ^SType^SALIVE ^SUnit^Starget ^t^Sn^N4 ^t^SEvents^T ^N1^T ^SType^SAnimations ^SAnimation^SICONSHAKE ^SEvent^SOnShow ^t^N2^T ^SType^SSound ^SSound^SShort~`Circuit ^SEvent^SOnShow ^t^N3^T ^SType^SAnimations ^SAnimation^SACTVTNGLOW ^SEvent^SOnShow ^SInfinite^B ^t^N4^T ^SType^SAnimations ^SAnimation^SICONCLEAR ^SEvent^SOnHide ^t^Sn^N4 ^t^SEnabled^B ^SGUID^STMW:icon:1JfB9rI902sa ^SFakeHidden^B ^t^t^SOnlyInCombat^B ^STree2^b ^SColumns^N7 ^STree1^b ^SName^SReactionary~`DPS ^t^N6^T ^SPoint^T ^Sy^F-5664693718023954 ^f-46^Sx ^F4925793560166848^f-48 ^Spoint^STOP ^SrelativePoint^STOP ^t^SIcons^T ^N1^T ^SShowTimer^B ^SConditionAlpha^N0.5 ^SType^Scooldown ^SName^SEnergizing~`Brew ^SShowTimerTextnoOCC^B ^SConditions^T ^N1^T ^SType^SCHI ^SOperator^S< ^SLevel^N2 ^t^N2^T ^SType^SENERGY ^SOperator^S< ^SLevel^N40 ^t^Sn^N2 ^t^SUnAlpha^N0.1 ^SShowWhen^N3 ^SEnabled^B ^t^N2^T ^SShowTimer^B ^SConditionAlpha^N0.5 ^SType^Scooldown ^SName^SChi~`Brew ^SShowTimerTextnoOCC^B ^SConditions^T ^N1^T ^SType^SCHI ^SOperator^S<= ^SLevel^N2 ^t^Sn^N1 ^t^SUnAlpha^N0.1 ^SShowWhen^N3 ^SEnabled^B ^t^N3^T ^SType^Sbuff ^SName^SFeared;~`Rooted;~`Stunned ^SConditions^T ^N1^T ^SType^SBUFFDUR ^SName^SFeared ^t^Sn^N1 ^t^SCooldownCheck^B ^SCustomTex^S137562 ^SEnabled^B ^SUseActvtnOverlay^B ^t^N4^T ^SShowTimer^B ^SConditionAlpha^N0.5 ^SType^Scooldown ^SName^SFists~`of~`Fury ^SShowTimerTextnoOCC^B ^SConditions^T ^N1^T ^SType^SENERGY ^SOperator^S<= ^SLevel^N31 ^t^Sn^N1 ^t^SUnAlpha^N0.1 ^SShowWhen^N3 ^SEnabled^B ^t^t^SColumns^N6 ^SGUID^STMW:group:1JevLpYJlxmp ^SName^SCooldown~`DPS ^SConditions^T ^N1^T ^SType^SCOMBAT ^t^Sn^N1 ^t^t^t^SVersion^N70090 ^t^N70090^S~`~| ^Sprofile^SBilmonk~`-~`Aerie~`Peak ^^

Here is the export string for one required working lua snippet and the 2nd one is the one throwing an error on login.
UnitDebuffTypeCheck (working just fine but needed for Detox)

^1^T^SName^SUnitDebuffTypeCheck ^SCode^Sfunction~`UnitDebuffTypeCheck(unit,~`type)~J ~`~`~`~`for~`i=1,40~`do~`~J ~`~`~`~`_,_,_,_,debuffType~`=~`UnitDebuff(unit,i);~`~J ~`~`~`~`~`~`~`~`if~`debuffType~`then~`~J ~`~`~`~`~`~`~`~`~`~`~`~`if~`debuffType~`==~`type~`then~J ~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`return~`true;~J ~`~`~`~`~`~`~`~`~`~`~`~`end~J ~`~`~`~`~`~`~`~`end~`~J ~`~`~`~`end~J end ^t^N70090^S~`~| ^Scodesnippet^^

GetSpellDamage (poorly named but it is supposed to set a global variable for the expel harm condition to determine if that spell is useful yet).  The event handler bound to PLAYER_LEVEL_UP throws an error on login.

^1^T^SOrder^N2 ^SName^SGetSpellDamage ^SCode^Slocal~`gsub~`=~`string.gsub;~J local~`GetSpellVarsTooltip~`=~`CreateFrame("GameTooltip",~`"GetSpellVarsTooltip",~`UIParent,~`"GameTooltipTemplate");~J local~`switchCaseTable~`=~`{~J ~`~`~`[115072]~`=~`function(spellDescription,~`pattern)~`~`~`~`~`~`~`~`--~`Expel~`Harm~J ~`~`~`~`~`~`pattern~`=~`~J ~`~`~`~`~`~`gsub(~J ~`~`~`~`~`~`~`~`~`gsub(~J ~`~`~`~`~`~`~`~`~`~`~`~`gsub(~J ~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`gsub(~J ~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`gsub(pattern,~`"%${7%*$<low>}",~`"(.+)")~J ~`~`~`~`~`~`~`~`~`~`~`~`~`~`~`,~`'%${7%*$<high>}',~`"(.+)")~J ~`~`~`~`~`~`~`~`~`~`~`~`,'%$115129s2%%',~`"(.+)")~J ~`~`~`~`~`~`~`~`~`,'%$115129A1',~`"(.+)")~J ~`~`~`~`~`~`,'%$m2','(.+)')~J ~`~`~`~`~`~`local~`healthDeficit~`=~`UnitHealthMax("player")~`-~`UnitHealth("player")~J ~`~`~`~`~`~`~J ~`~`~`~`~`~`local~`_,~`_,~`minHeal,~`maxHeal~`=~`string.find(spellDescription,~`pattern)~J ~`~`~`~`~`~`minHeal~`=~`tonumber(gsub(minHeal~`or~`'0',',',''),10)~`--~`Remove~`Commas~J ~`~`~`~`~`~`maxHeal~`=~`tonumber(gsub(maxHeal~`or~`'0',',',''),10)~`--~`Remove~`Commas~J ~`~`~`~`~`~`--~`if(healthDeficit~`<~`minHeal)~`then~J ~`~`~`~`~`~`--~`~`~`~`maxHeal~`=~`healthDeficit~J ~`~`~`~`~`~`--~`~`~`minHeal~`=~`healthDeficit~J ~`~`~`~`~`~`--~`elseif(healthDeficit~`<~`maxHeal)~`then~J ~`~`~`~`~`~`--~`~`~`maxHeal~`=~`healthDeficit~J ~`~`~`~`~`~`--~`end~J ~`~`~`~`~`~`local~`minDmg~`=~`minHeal~`/2~J ~`~`~`~`~`~`local~`maxDmg~`=~`maxHeal~`/2~J ~`~`~`~`~`~`return~`pattern,~`minDmg,~`maxDmg~J ~`~`~`end,~J ~`~`~`[100780]~`=~`function(spellDescription,~`pattern)~`~`~`~`~`~`~`~`--~`Jab~J ~`~`~`~`~`~`pattern~`=~`~J ~`~`~`~`~`~`gsub(~J ~`~`~`~`~`~`~`~`~`gsub(~J ~`~`~`~`~`~`~`~`~`~`~`~`gsub(pattern,~`"%${1.5%*%$<low>}",~`"(.+)")~J ~`~`~`~`~`~`~`~`~`,~`"%${1.5%*%$<high>}",~`"(.+)")~J ~`~`~`~`~`~`,~`"%$s2",~`"(.+)")~J ~`~`~`~`~`~`local~`_,~`_,~`minDmg,~`maxDmg~`=~`string.find(spellDescription,~`pattern)~J ~`~`~`~`~`~`return~`pattern,~`minDmg,~`maxDmg~J ~`~`~`end~J }~J ~J function~`GetSpellVars(spellId,~`calc)~J ~`~`~`GetSpellVarsTooltip:SetOwner(UIParent,~`"ANCHOR_NONE")~J ~`~`~`GetSpellVarsTooltip:SetSpellByID(spellId);~J ~`~`~`local~`spellDescription~`=~`GetSpellVarsTooltipTextLeft4:GetText();~J ~`~`~`local~`spellDescriptionPattern~`=~`GetSpellDescription(spellId)~J ~`~`~`local~`minDmg,~`maxDmg~`=~`0,~`0~J ~`~`~`~J ~`~`~`if~`(switchCaseTable[spellId]~`and~`spellDescription~`and~`spellDescriptionPattern)~`then~J ~`~`~`~`~`~`~J ~`~`~`~`~`~`pattern,~`minDmg,~`maxDmg~`=~`switchCaseTable[spellId](spellDescription,~`spellDescriptionPattern)~J ~`~`~`~`~`~`if~`(calc~`==~`'avg')~`then~J ~`~`~`~`~`~`~`~`~`return~`(minDmg+maxDmg)/2~J ~`~`~`~`~`~`else~J ~`~`~`~`~`~`~`~`~`return~`minDmg,maxDmg~J ~`~`~`~`~`~`end~J ~`~`~`else~`~J ~`~`~`~`~`~`return~`0~J ~`~`~`end~J end~J --ExpelHarmThreshold~`=~`GetSpellVars(100780,~`'avg')~J ~`ExpelHarmThreshold~`=~`GetSpellVars(100780,'avg')~`*~`2~J AddEventListener('PLAYER_LEVEL_UP',~`~J ~`~`~`function()~J ~`~`~`~`~`~`~`ExpelHarmThreshold~`=~`GetSpellVars(100780,'avg')~`*~`2~J ~`~`~`end~J )~`~`~`~`~J --print(GetSpellVars(115072,'avg'))~J --print(ExpelHarmThreshold)~J ~J  ^t^N70090^S~`~| ^Scodesnippet^^


Posted by CurseForge user matthttam | Imported from CurseForge issue #959 | Raw

tmw-issue-import commented 10 years ago

AddEventListener is not a Blizzard function. Some other addon that you are using is providing it. When you run the snippet after login, whatever addon that provides this function is loaded, so it works fine. When the snippet auto runs at login, whatever addon that is providing this function doesn't exist, so you'll get an error.

Replace that line with this:

``` GetSpellVarsTooltip:RegisterEvent("PLAYER_LEVEL_UP") GetSpellVarsTooltip:SetScript("OnEvent", function() ExpelHarmThreshold = GetSpellVars(100780, 'avg') *2 end) ```


Posted by CurseForge user Cybeloras

tmw-issue-import commented 10 years ago

Thank you for the prompt reply! That fixed it! I had installed an addon called Hack so I could edit and test LUA code in wow (since I am learning it on the fly here). Hack apparently has its own library of premade functions one can use and that is where I got that syntax.

Thanks again! Bil


> Posted by CurseForge user matthttam