Is there a tool to look at ur code better it's not entirely neat like some i have looked at. Like it's all 1 line almost. Also what is the purpose of the xml file then if it is purely Lua?
Hah. No, there are line breaks, but your text editor sucks (Windows Notepad?) and doesn't support that kind of line break (there's more than one kind).
Personally I use Notepad2; it's very similar to the Windows Notepad, but supports all 3 line break types, supports UTF8 encoding and others, and has lots of nice basic coding features like matching brace highlighting, line numbers, etc. It differs from other "Notepad replacement" programs in that it isn't stuffed full of frills like a tabbed multiple document interface (I like alt-tab kthx), code folding, spell checking, etc.
The XML file is "embeds.xml" and basically extends the TOC with references to embedded library files to simplify things for non-embedded library users by allowing them to delete the embedded library files without having to edit the TOC or increase their load time. It has nothing at all to do with the addon's form or function, and isn't relevant to what you're trying to do.
frame = CreateFrame("Frame"); -- frame created, OnLoad handler called
frame:SetScript("OnLoad", function() print("Frame loaded") end); -- never called
local power = UnitPower("player" [, type]);
local frame = CreateFrame("FRAME", "FooAddonFrame");
local function eventHandler(self, event, ...)
print("Hello World! Hello " .. event);
do i have to only tailor it to warriors or would it be too much for it to cover say a druid's needs for energy/rage
You don't "have to" do anything - its your addon :P.
As a druid I use separate from unit frames energy monitor. I find rage monitor not "needed" but if I liked an addon that did both I would use it. I will say few things about about energy tracking. It is important to me that the monitor is updating precisely without visible delays.
I suppose its best to start simple and learn then expand your code to meet the demands of other classes, especially if you can't test it in person.
Uhhh... that's not correct Lua syntax. It's also messy. Try this:
local _, class=UnitClass("player")
if class == "WARRIOR" then
print("I am a Warrior. I have " .. UnitPower("player") .. " rage.")
Hmm, didn't know you could use underscores in that way. The brackets are because Lua syntax sucks (imo), and I tend to forget it doesn't use braces.
On the rest, I did that on purpose. UnitPower was in a variable because he would be using it later. The WARRIOR conditional was there so he could disable his addon for classes that don't use it (I forgot about druids, though). I didn't use print because I test in WoWLua, and it puts print calls in its own frame, which I find annoying, so its a habit.
It's fairly common to use an underscore for a "junk" variable whose value you don't care about. It's also move obvious at a glance that it's junk than if you have to read some word, even if you use the same word every time. :p
If you want it to be more robust between classes, try this:
local _, powerType = UnitPowerType("player")
local powerAmount = UnitPower("player")
if powerType == "RAGE" then
print("I have " .. powerAmount .. " rage.")
The other power type tokens are "MANA", "ENERGY", "FOCUS", and "RUNIC_POWER".
local _, token = UnitPowerType(unit)
local unitTypeText = _G[token] -- Localized Power type. :)
Re: Possessive "S"
UnitName("player") .. "'s "
This would be better and more accurate (at least for English grammar):
local name = UnitName("player")
local possessiveName = "";
if strsub(name, -1) == "s" then
possessiveName = name .. "'" -- Marcus' rage is whatever
possessiveName = name .. "'s" -- Bob's mana is whatever