-
Posted by p03p on Thu, 10 Jun 2010 16:50:14
Hey all, im new to add-on programming and im trying to make an add-on to help me and my arena partner. The currently problem i have is, i want to use
UNIT_SPELLCAST_SUCCEEDEDevent which can have 3 arguments:Signature: ("unitID", "spell", "rank")
Arguments: unitID - The unit that's casting. (string) spell - The name of the spell that's being casted. (string) rank - The rank of the spell that's being casted. (string)
I tried this as a test which works for every completed cast:
function Frame1_OnLoad() this:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED"); end function Frame1_OnEvent() if(event == "UNIT_SPELLCAST_SUCCEEDED") then print("Hello world!"); end endBut now i want to use the arguments to pick the correct spell, how could i implement this?
-
Posted by jnwhiteh on Thu, 10 Jun 2010 19:33:24
Hey all, im new to add-on programming and im trying to make an add-on to help me and my arena partner. The currently problem i have is, i want to use
UNIT_SPELLCAST_SUCCEEDEDevent which can have 3 arguments:Signature: ("unitID", "spell", "rank")
Arguments: unitID - The unit that's casting. (string) spell - The name of the spell that's being casted. (string) rank - The rank of the spell that's being casted. (string)
I tried this as a test which works for every completed cast:
function Frame1_OnLoad() this:RegisterEvent("UNIT_SPELLCAST_SUCCEEDED"); end function Frame1_OnEvent() if(event == "UNIT_SPELLCAST_SUCCEEDED") then print("Hello world!"); end endBut now i want to use the arguments to pick the correct spell, how could i implement this?
This is all covered quite heavily in the book, and there is a lot going on here that is just wrong for the way we write addons today.
- You shouldn't be using
this. It was deprecated years ago and may have even been removed since. You should instead be using the first argument to your OnLoad function, which will be the frame being loaded. - Your OnEvent function, similarly needs to take the frame, the event, and a list of arguments.
Then you'd be able to examine everything and I see no other issues with the code.
- You shouldn't be using