I am trying to set it up so that the addon checks to see if this character has installed this addon before. If the character did not install the addon then it brings up an installation frame. I know I'm probably missing something super easy, but I would appreciate the help... I've tried ready through World of Warcraft Programming, have spent 3 days reading forums and working on this... figured it was time to ask for help lol. I thought I would try looking at other addons to see how they did and used some of their code, but it isn't working right.

Note: Reworking the code, will get back to you.

Last edited by WhiteWolf87 : 05-11-14 at 08:45 PM.
Reason: Reworking the code

It appears that the signature for your OnEvent function should be (self, event, ...) instead of (event). What you are probably doing is comparing "ADDON_LOADED" to self instead of event.

Alos, in processing ADDON_LOADED you also want to check ... because the first parameter passed there will be the name of an addon. If it is not your addon name you should ignore it and not do any work. Basically your addon will be able to see other addons get loaded and it will be sent ADDON_LOADED for each. You are not guaranteed a specific order of those addon loads either.

So, you might want to change your code to:

function lf:OnEvent(self, event, ...)
if "ADDON_LOADED" == event then
if "LCI" == ... then
CheckNewChar()
end
end
end

It appears that the signature for your OnEvent function should be (self, event, ...) instead of (event). What you are probably doing is comparing "ADDON_LOADED" to self instead of event.

Alos, in processing ADDON_LOADED you also want to check ... because the first parameter passed there will be the name of an addon. If it is not your addon name you should ignore it and not do any work. Basically your addon will be able to see other addons get loaded and it will be sent ADDON_LOADED for each. You are not guaranteed a specific order of those addon loads either.

So, you might want to change your code to:

function lf:OnEvent(self, event, ...)
if "ADDON_LOADED" == event then
if "LCI" == ... then
CheckNewChar()
end
end
end

Thank you for responding. Gave it a try and nothing loaded when i tested it

It appears that the signature for your OnEvent function should be (self, event, ...) instead of (event). What you are probably doing is comparing "ADDON_LOADED" to self instead of event.

Alos, in processing ADDON_LOADED you also want to check ... because the first parameter passed there will be the name of an addon. If it is not your addon name you should ignore it and not do any work. Basically your addon will be able to see other addons get loaded and it will be sent ADDON_LOADED for each. You are not guaranteed a specific order of those addon loads either.

So, you might want to change your code to:

function lf:OnEvent(self, event, ...)
if "ADDON_LOADED" == event then
if "LCI" == ... then
CheckNewChar()
end
end
end

Originally Posted by WhiteWolf87

Thank you for responding. Gave it a try and nothing loaded when i tested it

Not that it relates to the OP's issue, but that isn't true Cokedrivers. There is no syntax requirement for either string to come first. Keep in mind that event is just a string passed to the function (at least in this example). You can check for equality between the two in any order.

Not that it relates to the OP's issue, but that isn't true Cokedrivers. There is no syntax requirement for either string to come first. Keep in mind that event is just a string passed to the function (at least in this example). You can check for equality between the two in any order.

Not that it relates to the OP's issue, but that isn't true Cokedrivers. There is no syntax requirement for either string to come first. Keep in mind that event is just a string passed to the function (at least in this example). You can check for equality between the two in any order.

Setting the variable compare on the left side of the if statement does make more sense however as the corresponding pseudocode would be gramatically correct. It just reads better.

__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

Make sure you enable Lua errors, but also your OnEvent signature was correct since colon syntax is used. You'll still want to make sure that it was your addon that loaded, though.

Code:

function lf:OnEvent(event, ...)
if (event == "ADDON_LOADED") then
if (... == "LCI") then -- needs to be same as your addon folder and ToC file name
CheckNewChar()
end
end
end

print is your best friend in troubleshooting. Add it in functions that are meant to be executed to see where execution goes wrong and, if necessary, whether relevant variables have the expected values.

I found your issue... the event handler you set up is wrong. it is supposed to be passed SELF, EVENT, ... you are, it seems, passing it nothing. no self, no event, and no ...

if you want to use any of the data from the event you must pass it to your function explicitly if you want to use the EVENT data you must pass SELF, and EVENT like in my example. You should also pass "..." as in my example so you can check to see if it is your addon being called or someone elses. Your addon can crash if it tries to init before wow inits it first, or force the setup to run 1- #addonLoaded + wow addons loading (OK not quite that many times but you can/will have problems)

I found your issue... the event handler you set up is wrong. it is supposed to be passed SELF, EVENT, ... you are, it seems, passing it nothing. no self, no event, and no ...

You're at least the second person to post that, and like the others before you, you're wrong. He is passing the self in -- that's what method notation (colon) does.

However, I've been avoiding this thread because OP's code is obviously borrowing from some old and really badly written examples that I'd really rather swallow live spiders than work with, but since OP didn't post the entire addon and the file they posted makes multiple references to functions and other things that are (I assume) in other files, I can't just rewrite it for them.

that is not the self I meant... I know that he is specifically passing his frame by calling his function via a colon, what I meant is that when the "ADDON_LOADED" event fires it gives you 3 arguments, self, event, addon_name

with the way he is calling his handler would his function prototype/declaration not need an extra variable like the following:

This is perfectly fine. The function lf:OnEvent makes OnEvent a method of the frame lf. When you assign lf.OnEvent to the event handler, self and event get passed through automatically. Using lf:OnEvent means that lf *is* self, so only event is needed in the parentheses.

Now.... He does still need to check if it was his addon that loaded.

__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh