Thread Tools Display Modes
05-07-14, 09:25 PM   #1
WhiteWolf87
A Deviate Faerie Dragon
 
WhiteWolf87's Avatar
AddOn Compiler - Click to view compilations
Join Date: Dec 2013
Posts: 16
Having trouble writing an addon

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
  Reply With Quote
05-07-14, 10:07 PM   #2
Nimhfree
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 267
Bear in mind that it is late and I am really tired.

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
  Reply With Quote
05-07-14, 11:01 PM   #3
WhiteWolf87
A Deviate Faerie Dragon
 
WhiteWolf87's Avatar
AddOn Compiler - Click to view compilations
Join Date: Dec 2013
Posts: 16
Originally Posted by Nimhfree View Post
Bear in mind that it is late and I am really tired.

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

Last edited by WhiteWolf87 : 05-07-14 at 11:32 PM.
  Reply With Quote
05-08-14, 01:16 AM   #4
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Nimhfree View Post
Bear in mind that it is late and I am really tired.

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 View Post
Thank you for responding. Gave it a try and nothing loaded when i tested it
Not to good at lua but I do know that it needs to be
Code:
if event == "ADDON_LOADED"
not the other way around.
  Reply With Quote
05-08-14, 01:40 AM   #5
Clamsoda
A Frostmaul Preserver
Join Date: Nov 2011
Posts: 269
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.
  Reply With Quote
05-08-14, 09:01 AM   #6
cokedrivers
A Rage Talon Dragon Guard
 
cokedrivers's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 325
Originally Posted by Clamsoda View Post
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.
Ok sorry about the reply, as I have stated before im no programmer.
  Reply With Quote
05-08-14, 09:52 AM   #7
ravagernl
Proceritate Corporis
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,176
Originally Posted by Clamsoda View Post
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.

Code:
 
if event is the same as "ADDON_LOADED" then 
    dosomething()
end
  Reply With Quote
05-11-14, 08:43 PM   #8
WhiteWolf87
A Deviate Faerie Dragon
 
WhiteWolf87's Avatar
AddOn Compiler - Click to view compilations
Join Date: Dec 2013
Posts: 16
Thanks for the help I'm going to try reworking it and then I'll re-post if I have further isssue..
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Having trouble writing an addon


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