Thread Tools Display Modes
03-05-09, 04:37 AM   #1
Soeters
A Warpwood Thunder Caller
 
Soeters's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 97
Some code not working

I'm trying to make an addon that prints how many you need to be at the next reputation level and to be exalted.
I've written some code, using AceAddon, AceConsole, AceLocale and LibStub.

Here's my code

When I log in nothing seems to happen but the addon is marked as loaded when I print the addon list. The slash commands aren't working too.


I've tested many things but even the OnInitialize() doesn't seem to work.
If someone can help me with that problem that would be very kind.
__________________
  Reply With Quote
03-05-09, 04:46 AM   #2
Mera
Retired of WoW, In ESO :)
 
Mera's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 331
first error I see is

local Thesaurus =

Thesaurus should be global for Ace3 to access it

you could write it

Thesaurus =

or

local Thesaurus = ..;
Thesaurus = Thesaurus -- define global Thesaurus to be local Thesaurus
__________________
If you need to reach me I'm in ESO, @class101 or "Fathis Ules i"
addons: SpamBayes, BrokerCPU
projects: ThunderBayes
Mera[xeh]? - La CroisadeEcarlate (wow)
  Reply With Quote
03-05-09, 04:48 AM   #3
Soeters
A Warpwood Thunder Caller
 
Soeters's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 97
That's true but even when Thesaurus was a global that didn't worked.
__________________
  Reply With Quote
03-05-09, 04:53 AM   #4
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by Mera View Post
first error I see is

local Thesaurus =

Thesaurus should be global for Ace3 to access it

you could write it

Thesaurus =

or

local Thesaurus = ..;
Thesaurus = Thesaurus -- define global Thesaurus to be local Thesaurus
I don't think thats it, iirc Ace3 wont require it to be global, as it will keep a reference to your addon object, and it wouldn't make any sense for it to require a global reference.


Anyway, back to your problem. If you are using that code you posted, then you should be getting an error about all your :Print() calls missing a ")".
  Reply With Quote
03-05-09, 04:56 AM   #5
Soeters
A Warpwood Thunder Caller
 
Soeters's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 97
I use that coded (modified now) but I didn't get any error (maybe that a conflict with o****)
__________________
  Reply With Quote
03-05-09, 04:59 AM   #6
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by Soeters View Post
I use that coded (modified now) but I didn't get any error (maybe that a conflict with o****)
If you use OnEnable instead of OnInitialize you'll probably get the error report.

It'll be due to o**** being loaded before your mod.
  Reply With Quote
03-05-09, 05:08 AM   #7
Mera
Retired of WoW, In ESO :)
 
Mera's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 331
well if you look at most of Ace2/Ace3 codes they all declare the global variables that is not for cosmetics because without how Ace3 could guess your mod:OnInitialize if mod is local..
__________________
If you need to reach me I'm in ESO, @class101 or "Fathis Ules i"
addons: SpamBayes, BrokerCPU
projects: ThunderBayes
Mera[xeh]? - La CroisadeEcarlate (wow)

Last edited by Mera : 03-05-09 at 05:11 AM.
  Reply With Quote
03-05-09, 05:26 AM   #8
Slakah
A Molten Giant
 
Slakah's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2007
Posts: 863
Originally Posted by Mera View Post
well if you look at most of Ace2/Ace3 codes they all declare the global variables that is not for cosmetics because without how Ace3 could guess your mod:OnInitialize if mod is local..
Because it stores the addon object it supplys you with when you do ":NewAddon()" in "AceAddon.addons"
  Reply With Quote
03-05-09, 06:17 AM   #9
Torhal
A Pyroguard Emberseer
 
Torhal's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 1,196
Originally Posted by Mera View Post
well if you look at most of Ace2/Ace3 codes they all declare the global variables that is not for cosmetics because without how Ace3 could guess your mod:OnInitialize if mod is local..
I notice you said most, which invalidates what you say afterward - if it were true, all Ace-based addons would require it. In Revelation, I do this:

Code:
local Revelation = LibStub("AceAddon-3.0"):NewAddon(NAME, "AceHook-3.0")
...and never do anything like this:

Code:
_G["Revelation"] = Revelation
...though that certainly wouldn't really hurt anything, unless another addon has done it before I did and would break because of it.

The reason it doesn't need to be global is that the addon object is defined as an AceAddon object, with all of the OnInitialize()/OnEnable()/OnDisable()/etc and the handling those entail built-in.
__________________
Whenever someone says "pls" because it's shorter than "please", I say "no" because it's shorter than "yes".

Author of NPCScan and many other AddOns.
  Reply With Quote
03-05-09, 11:06 AM   #10
Soeters
A Warpwood Thunder Caller
 
Soeters's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 97
Now I've fixed almost everything but there is still one error.

Everytime I do /ths faction kirin (ou other faction name but kirin is the easiest) I got this error

Code:
Interface/AddOns/Thesaurus:core.lua:140: attempt to concatenate global 'current' (a nil value)
And I don't know why but maybe I should use string.format instead of AceConsole's Print(...)

Edit: The current code
__________________

Last edited by Soeters : 03-05-09 at 11:07 AM. Reason: Forgot the code link
  Reply With Quote
03-05-09, 11:13 AM   #11
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I had to look for the variable current because it's no longer on 140 - it's on 142.

Anyway, you have problems with variable scope. You're looking for the variable current, but when you try to call it there, it is undefined. This is because you defined it as a local variable, local only to the if block it originally is declared in. Put:
Code:
local current
at the top of your file and remove the local from before it at line 84. That way, it will still be a local variable (instead of a global), but it will be local to your entire lua file, not just a specific block.
__________________
"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

  Reply With Quote
03-05-09, 11:20 AM   #12
Soeters
A Warpwood Thunder Caller
 
Soeters's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 97
Thanks a lot that works well now
__________________
  Reply With Quote
03-05-09, 11:40 AM   #13
Mera
Retired of WoW, In ESO :)
 
Mera's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 331
indeed i tested global/local doesnt change so you can put back locla Thesaurus sorry, better to think local than global unless you need to call a Thesaurus:Function() from the chat command line for debugging purpose for example, when global is really needed
__________________
If you need to reach me I'm in ESO, @class101 or "Fathis Ules i"
addons: SpamBayes, BrokerCPU
projects: ThunderBayes
Mera[xeh]? - La CroisadeEcarlate (wow)

Last edited by Mera : 03-05-09 at 11:44 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Some code not working


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