WoW:API and scripting quirks: Difference between revisions

Changed my "quirk"
mNo edit summary
(Changed my "quirk")
Line 32: Line 32:
**** "|c" doesn't have the same problem, but will cause the text after it not to show.
**** "|c" doesn't have the same problem, but will cause the text after it not to show.


* Variables
* Variables (not really a "quirk", more like a "need to know").
** If you declare a variable inside an IF block, any attempt to compare the value will fail.
** If you declare a local variable inside an IF block, it is only available inside that IF block.
*** In Example 1, "Something" will never print. While in Example 2, "Something" does print.
*** In Example 1, "Something" will never print. While in Example 2, "Something" does print.
*** See [[Talk:API_and_scripting_quirks#Variables|Talk]] for more details.
*** See [[Talk:API_and_scripting_quirks#Variables|Talk]] for more details.
Line 41: Line 41:
         local someOtherVar = true; -- someOtherVar declared inside an IF block.
         local someOtherVar = true; -- someOtherVar declared inside an IF block.
     end
     end
     Print(tostring(someOtherVar));
     Print(tostring(someOtherVar)); -- Prints "nil" because the variable does not exist.
     if someOtherVar then
     if someOtherVar then
         Print("Something"); -- This never gets executed.
         Print("Something"); -- This never gets executed.
Line 48: Line 48:
     -- Example 2
     -- Example 2
     local someVar = true;
     local someVar = true;
     local someOtherVar; -- someOtherVar declared before an IF block.
     local someOtherVar; -- someOtherVar declared before (outside) an IF block.
     if someVar then
     if someVar then
         someOtherVar = true;
         someOtherVar = true;
Anonymous user