View Single Post
04-18-09, 12:35 AM   #18
Azul
Banned
 
Azul's Avatar
Join Date: Apr 2009
Posts: 19
Originally Posted by ChaosInc View Post
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.
How do I check for a local foo instead? And be defined in the function scope instead of the if statement? If this is impossible then defining them inside the update definitely isn't an alternative and I need a way around the 60 upvalue limit like I asked for in the first post.