From WoWWiki
This page is intended to accumulate frequently asked questions about Interface Customization and developing AddOns. For now the questions and answers will both be on this page, but may get split up if it starts to get unwieldy.
Basic Questions
Where do I start if I want to write an AddOn?
- Try the
UI Beginners Guide. For a slightly historical perspective, you could also look at
WoW UI Customization Guide (Slouken's original forum post that got us all started way back then. However, please note that this guide is
extremely out of date). Also see
UI FAQ/AddOn Author Resources.
Where do I start with these XML files?
- Try the
XML User Interface guide - its full of useful information!
- Or try the
WoW UI Designer utility to design your widgets graphically and generate XML automatically.
How do I reload my UI?
- Type
/console reloadui or
/script ReloadUI(). Some addons also add shortcut slash commands to ease development (e.g. Ace-Console adds
/reload,
/rl and
/reloadui)
What is Lua?
- See the
Lua page for an explanation, and pointers to lots more information about the language.
And then what?
- Dive head-first into the
Interface Customization section, and especially the
World of Warcraft API. Also,
look at other addons!. There's nothing better than learning by example. You can view the Lua and XML files of all other addons freely.
How do I know what verion number to use in the .toc files?
- Generally, it is constructed from the version number. I.e. version "1.11" is "11100". If there is a minor version, e.g. "1.11.02", it is generally ignored and the number stays "11100". If the second version indication is a single number, it's padded: "1.9" becomes "10900". If you don't have access to the game you could check on the
WoW Interface Customization forum. Or
get it from the game files.
Targetting
Can I target mobs via raid icons? The ones set via the SetRaidTarget() API?
- No, and it is highly doubtful that we ever will. Blizzard explicitly does not want to allow unambiguous saving and restoring of targets programatically.
Minimap
Can I re-color/enumerate/scan/detect the dots on the minimap?
- No, the minimap tracking layer is rendered in the game engine, the UI doesn't have any visibility of the contents of the layer other than the dot the cursor mouses over. It IS possible to add your own simulated tracking dots by moving a frame containing a dot graphic of your own creation over the mininimap, but you are responsible for calculating where to put it.
Spells
How do I cast 2 (or more) spells?
You can't cast more than one spell (or use more than one ability) per user input. The first successful cast will work, and all subsequent cast requests will silently be ignored. (You CAN, however, have a function which chooses which of a number of spells to cast, and casts just one of them). There are however a few exceptions for certain instant-casts, see the addendum at the end of UI FAQ/Macros and Scripts.
How can I find out if a spell is in range?
- The only range checking function is for action buttons, so you need to assign the spell to an action button slot, and then use the
IsActionInRange(slot) function to test it. If you want to cast spells on another unit than your current target,
CheckInteractDistance(unit, distanceType) is quite a lot faster than changing targets (it has certain limits though).
Why doesn't UnitDebuff accurately report the spell I just cast
- There is a ~0.5 second gap (actually, the network roundtrip time between you and the server, plus some reaction time in the server itself) between the end of a spell being cast and its associated debuff texture showing up on the unit upon which it was cast. This gap causes problems for "Smart Cast" scripts which try to prevent a spell like Immolate from being run when the target already has the debuff on it. If there is a pause between casting, the script would work; however, if the script is triggered rapidly then it is likely to try to cast Immolate twice (since it does not yet see the debuff on the target unit). The workaround for this problem is to subscribe to the SPELLCAST_STOP event. Every time that event is triggered, store the
current time in a variable. From then on, whenever you subtract the
current time from the stored time of the last SPELLCAST_STOP event, you get the time (in seconds) since the last spell stopped. If that time is greater than 0.5, you can proceed to cast your spell. If not, do not cast your spell. Note: this is not an issue for instant cast spells (their debuffs seem to be immediately noticeable), therefore it would be inefficient to do this check on them.
A quickfix would be to remember your last cast spell and simply skip that one, since that usually gives the server<->client communication time to catch up and show debuff icons. This is of course only useful if you cast a number of spells, but for Warlock multi-DoT:ing it works quite well.
Items
Why do I get disconnected when I try to view an item link from another server?
- When you attempt to 'link' an item, the game first looks in your client's item cache to see if it's there, if it is not there, then it queries the server to look in its cache (The server's cache contains every item that's been legitimately "seen" since the server was last started). If the item you request is not in the server's cache then you will be disconnected. This doesn't affect normal use because when you log in your inventory is added to the server cache, when you talk to vendors, view your bank, etc, all of those items are added to the server cache.
The problem arises if you have a link to an item which nobody has seen on your server since it started, usually because it's very rare and no player owning the item has logged in yet. This mechanism is in place to stop people 'fishing' for item links by trying to guess the links of items they have never seen themselves. Linking an item you have seen during your current play session is always safe.
Why do I get disconnected when I try to send someone else a link that I could view?
- (Read the previous answer first). Sending an item link to another person requires that the item be in the server's cache. Since the first step of checking a link locally looks at your client's local cache, there's a chance that you have cached information about an item which the server has not yet seen since it restarted. The simple rule is never link an item you have not seen during your current play session.
How do I get the name (etc) from an item?
- There are a couple of ways to get information about an item, you can use a hidden tooltip and the appropriate :SetXXXItem method, and then parse the tooltip data, or you can get the item link via one of the GetXXXItemLink functions, and then use the GetItemInfo function.
local link = GetContainerItemLink(1,1)
-- This expression extracts the name from the link (if you just need name)
local justName = string.gsub((link,"^.-%[(.*)%].*", "%1")
-- This expression extracts the item ID from the link
local justItemId = string.gsub(link,".-\124H([^\124]*)\124h.*", "%1");
-- Then get info from link (NOTE: will return nil if item is not in local cache)
local itemName, itemLink, itemRarity, itemMinLevel, itemType, itemSubType,
itemStackCount, itemEquipLoc = GetItemInfo(justItemId);
Note that GetItemInfo ONLY returns information if the item is in your local cache, for most normal use this will be the case, but if you're using item ID's collected at another time, that may not be the case. If the link isn't in your cache, then it will return nil - You can attempt to bring the information to your cache by using a tooltip function to view the item link, but see the questions above regarding disconnection from invalid links.
See also