You need to define the function before you set it as an OnUpdate
Also, if thats what you do, having global variables like this with generic names is really bad.
Also, if thats what you do, having global variables like this with generic names is really bad.
Only while i'm testing with WoWLua. Normally I almost exclusively use locals, but in this case I use globals for debugging. The generic name is a good point, but I wouldn't use that outside of testing.
Only while i'm testing with WoWLua. Normally I almost exclusively use locals, but in this case I use globals for debugging. The generic name is a good point, but I wouldn't use that outside of testing.
I usually use my name as a global when I'm debugging.
It may help to (mentally) rewrite the syntactic sugar that Lua permits when defining functions. Instead of
frame:SetScript("OnWhatever", foo)
function foo (......) <body> end
replace it with what's really happening (this syntax is the generic "true" form, but is ugly to use all the time):
frame:SetScript("OnWhatever", foo)
foo = function (......) <body> end
You're assigning a function pointer, essentially, to the result of evaluating the "function ....... end" expression. Using that pointer before it's pointing to the right place just gives you a nil value, and frame:SetScript("OnWhatever",nil) removes the script handler.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Also, if thats what you do, having global variables like this with generic names is really bad.
Excellent, I wasn't aware of that.
Thanks.
Only while i'm testing with WoWLua. Normally I almost exclusively use locals, but in this case I use globals for debugging. The generic name is a good point, but I wouldn't use that outside of testing.
I usually use my name as a global when I'm debugging.
Seconded. If I need to get something out to a global to /dump it, I just use TEK = blah at the spot I'm trying to debug.
It may help to (mentally) rewrite the syntactic sugar that Lua permits when defining functions. Instead of
replace it with what's really happening (this syntax is the generic "true" form, but is ugly to use all the time):
You're assigning a function pointer, essentially, to the result of evaluating the "function ....... end" expression. Using that pointer before it's pointing to the right place just gives you a nil value, and frame:SetScript("OnWhatever",nil) removes the script handler.