m
Move page script moved page UI best practices to WoW:UI best practices without leaving a redirect
(rant on order of operations) |
m (Move page script moved page UI best practices to WoW:UI best practices without leaving a redirect) |
||
| (3 intermediate revisions by 3 users not shown) | |||
| Line 1: | Line 1: | ||
{{ | {{uitech}} | ||
With the low barrier to entry, writing mods has become very popular. While this has greatly benefited the WoW community, it does have a dark side. There are idiosyncrasies in both the [[Lua|Lua language]] and the [[World of Warcraft API]] that many authors overlook. This can lead to poorly written programs as measured by performance, memory usage, interference with other addons and the default UI, etc. The techniques gathering on this page will help help addon authors, experienced and otherwise, make the most out of WoW's environment safely and efficiently. | With the low barrier to entry, writing mods has become very popular. While this has greatly benefited the WoW community, it does have a dark side. There are idiosyncrasies in both the [[Lua|Lua language]] and the [[World of Warcraft API]] that many authors overlook. This can lead to poorly written programs as measured by performance, memory usage, interference with other addons and the default UI, etc. The techniques gathering on this page will help help addon authors, experienced and otherwise, make the most out of WoW's environment safely and efficiently. | ||
| Line 85: | Line 85: | ||
==== Order of Operations ==== | ==== Order of Operations ==== | ||
Lua, like | Lua, like many other programming languages, executes expressions from left to right starting from the innermost parenthesis to the outermost. This allows for un-nesting of IF blocks. | ||
-- This: | -- This: | ||
| Line 100: | Line 100: | ||
end | end | ||
: | Note: There are several programming languages that do not read left to right (eg. Joy, Factor, J and K, etc.). Others - like Haskell - can be used both ways. There are even languages that are multi-dimensional. While many of these are mainly academic, they are not esoteric languages made to be weird, but rather based on recent theories and ideas in computer science. | ||
==== Lazy Coding ==== | ==== Lazy Coding ==== | ||
| Line 162: | Line 162: | ||
MyEventHandler() | MyEventHandler() | ||
</OnEvent> | </OnEvent> | ||
Old Lua | Old Lua | ||
function MyEventHandler() | function MyEventHandler() | ||
| Line 176: | Line 175: | ||
MyEventHandler(self, event, ...) | MyEventHandler(self, event, ...) | ||
</OnEvent> | </OnEvent> | ||
New Lua | New Lua | ||
function MyEventHandler(frame, event, firstArg, secondArg) | function MyEventHandler(frame, event, firstArg, secondArg) | ||
| Line 186: | Line 184: | ||
end | end | ||
Even Newer XML | |||
<OnEvent function="MyEventHandler" /> | |||
This has the advantage of resulting in a reference call, without an anonymous code block calling a global function. | |||
==== Lua only ==== | ==== Lua only ==== | ||