WoW:API and scripting quirks: Difference between revisions
Jump to navigation
Jump to search
More details on Variables and a link to Talk
(→World of Warcraft Scripting Quirks: Unlink Output. Link SavedVariables instead.) |
(More details on Variables and a link to Talk) |
||
| Line 13: | Line 13: | ||
** OnUpdate handlers are only called when the frame is visible. | ** OnUpdate handlers are only called when the frame is visible. | ||
** OnUpdate handles are called ''every'' frame. Use with care. | ** OnUpdate handles are called ''every'' frame. Use with care. | ||
** When nesting frames, you can access the parent frame name in XML names with with $parent, this is a textual substitution and cannot be used in LUA code. | ** When nesting frames, you can access the parent frame name in XML names with with $parent, this is a textual substitution and cannot be used in LUA code. The LUA equivalent to $parent is the GetParent() method of the frame (e.g. getglobal(Frame:GetParent():GetName().."Button") is the same as $parentButton). | ||
** All [[Frames]] have a GetID() function which will obtain the ID specified in the XML. ID's must be positive integers enclosed in quotes: ie. id="1" or id="20" | ** All [[Frames]] have a GetID() function which will obtain the ID specified in the XML. ID's must be positive integers enclosed in quotes: ie. id="1" or id="20" | ||
** If you don't specify parent="UIParent" in your top-level frames, your frames won't be scaled according to the currently active UI scale. This can lead to some hair-pulling as you try to figure out why your fonts are so huge. (But, in some cases, not having that scaling might be desirable.) | ** If you don't specify parent="UIParent" in your top-level frames, your frames won't be scaled according to the currently active UI scale. This can lead to some hair-pulling as you try to figure out why your fonts are so huge. (But, in some cases, not having that scaling might be desirable.) | ||
| Line 31: | Line 31: | ||
**** "|r" causes the disconnect, | **** "|r" causes the disconnect, | ||
**** "|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 | |||
** If you declare a variable inside an IF block, any attempt to compare the value will fail. | |||
*** 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. | |||
-- Example 1 | |||
local someVar = true; | |||
if someVar then | |||
local someOtherVar = true; -- someOtherVar declared inside an IF block. | |||
end | |||
-- someOtherVar *is* set to true at this point, but for some reason the following IF statement ignores it. | |||
Print(tostring(someOtherVar)); -- "true" is printed. | |||
if someOtherVar then | |||
Print("Something"); -- This never gets executed. | |||
end | |||
-- Example 2 | |||
local someVar = true; | |||
local someOtherVar; -- someOtherVar declared before an IF block. | |||
if someVar then | |||
someOtherVar = true; | |||
end | |||
if someOtherVar then | |||
Print("Something"); -- This executes as expected. | |||
end | |||
== Also See == | == Also See == | ||