Thread Tools Display Modes
02-28-18, 11:59 AM   #1
Luaerror
A Defias Bandit
Join Date: Jan 2018
Posts: 2
code is working just after a /reload

Hello,

I wrote a small spell announce, but this code just works after a /reload and I can't find any code error.
I tried to make a Initializing function with "PLAYER_LOGIN" event but it doesn't change anything.

Please, can anybody give me an idea why it's happening?

Code in the following link: spell_announce.lua
  Reply With Quote
02-28-18, 01:26 PM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I didn't go looking through to find the cause of your reported behaviour, but I did notice that line 11 has a potential conflict. CHAT is a global string already, yet you redefine it as "SAY" (also a global string). To fix this, change line 11 to read
Lua Code:
  1. local chat = "SAY"
For reference, here are the global strings: https://www.townlong-yak.com/framexm...balStrings.lua
  Reply With Quote
02-28-18, 02:39 PM   #3
MunkDev
A Scalebane Royal Guard
 
MunkDev's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2015
Posts: 431
https://github.com/PedroZC90/oUF_Lua...nounce.lua#L10
https://wow.gamepedia.com/API_UnitGUID

Notes
This function will not return any values before the PLAYER_LOGIN event on a fresh login. If you need to hold the player's GUID in a variable, you must delay populating that variable until the PLAYER_LOGIN event fires. If you populate your variable by calling UnitGUID in the main chunk, your addon will not work on a fresh login, only after reloading the UI.

Originally Posted by myrroddin View Post
I didn't go looking through to find the cause of your reported behaviour, but I did notice that line 11 has a potential conflict. CHAT is a global string already, yet you redefine it as "SAY" (also a global string).
This isn't really a problem because the global variable isn't used in the scope.
__________________

Last edited by MunkDev : 02-28-18 at 02:42 PM.
  Reply With Quote
03-01-18, 05:04 PM   #4
Luaerror
A Defias Bandit
Join Date: Jan 2018
Posts: 2
MunkDev and myrroddin, Thank you for answering my question.

The problem was solved after I created a event for PLAYER_LOGIN to get player GUID.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » code is working just after a /reload


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