View Single Post
04/24/23, 11:41 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,000
Important hint:
IsUnit* and GetUnit* API functions need an unitTag which is a string by default so you need to use "player" and not player!
if GetUnitStealthState("player") ... -> else it won't work.

For example, I didn't know that we could not re-define the stock .xml Actions
I think we can for some of them, if it was not defined as noOverride or similar.
But it often leads to problems so better define your own and leave the stock/vanilla in place and unbind the key there.


I also didn't know that an if statement could inquire after a function, by name, rather than by numeric value. Very good to know!
STEALTH_STATE_NONE is actually a variable, a global one, no "name".
And it's value is a number, like your number 2.

All variables that are just defined, without using the "local" tag in front of it, will be added to the global table _G and is available lua wide (in the wole ESO environment) then!
Which makes defining variables always necessary to be local or at least added with a uniqueName if not local.

e.g.
local var = "test"

localt tab1 = {} -- local table
function tab1.myFunc(param1)
return var
end

MyAddon = {} --global table! All other addons and ESO environment got access to it now
local myAddon = MyAddon --local pointer to global table MyAddon! All other addons and ESO environment got access to MyAddon but only the current "scope" (like if ... then, for ... do, function() .... end, or the lua file where the local myAddon was defined at the top) got access to the local myAddon variable!




Here is a compilation for new addon devs, with links to the often asked questions, best practices, what addons can and cannot do etc.
https://www.esoui.com/forums/showthread.php?t=9867

If you got further questions feel free to join our Element / gitter chat too:
https://app.gitter.im/#/room/#esoui_esoui:gitter.im

Last edited by Baertram : 04/24/23 at 11:47 AM.
  Reply With Quote