View Single Post
04-18-09, 12:32 AM   #17
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Azul View Post
Edit: fixed it by moving it over the OnUpdate.. and now it says it's trying to concatenate foo as a GLOBAL, and that it's NIL. Just like in my example.
Oh duh, it's a logic issue. Ok,here's the lowdown on what's happening in your example (still tired, bear with me ).

1) check for global foo
Code:
if not foo then...
2) if global foo doesn't exist, create a local foo
Code:
local foo = "foo"
3) after declaring the end of the if statement, local foo is destroyed. Translated as per the compiler:
Code:
foo = NIL
4) attempt to create text
Code:
text = foo..bar
5) ERROR - a global foo still hasn't been created. And since the local was destroyed in stage 3, foo still remains as NIL

Also, I realize after looking back that the function would have to go before the scripts (which is always a good practice to maintain, for the record), but you posted the fix already.