WoW:UI best practices: Difference between revisions

m
no edit summary
(added OnEvent function="..." syntax)
mNo edit summary
Line 1: Line 1:
{{wowapi}}{{tocright}}
{{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 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 189: Line 187:
  <OnEvent function="MyEventHandler" />
  <OnEvent function="MyEventHandler" />
This has the advantage of resulting in a reference call, without an anonymous code block calling a global function.
This has the advantage of resulting in a reference call, without an anonymous code block calling a global function.
==== Lua only ====
==== Lua only ====