View Single Post
01-16-13, 05:46 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
1. Whenever you are writing/modifying code, make sure you have Lua errors turned on. "Not loading" or "not working" means an error is occurring. If you can't see the error, you're basically working in the dark.

2. Your problem is that you are defining "local health" inside the scope of the "if/else/end" check, so once the "if/else/end" block is done, the "health" variable no longer exists, so the following lines that try to do something with the "health" variable don't have anything to work with, and trigger errors about attempting to index nil values.

Change:
Code:
if unit == "player" or unit == "focus" or unit == "target" then
	local health = ns.CreateStatusBar(self, 16, "RIGHT", true)
else
	local health = ns.CreateStatusBar(self, 8, "RIGHT", true)
end
to:
Code:
local health
if unit == "player" or unit == "focus" or unit == "target" then
	health = ns.CreateStatusBar(self, 16, "RIGHT", true)
else
	health = ns.CreateStatusBar(self, 8, "RIGHT", true)
end
or better yet:
Code:
local health = ns.CreateStatusBar(self, (unit == "player" or unit == "focus" or unit == "target") and 16 or 8, "RIGHT", true)
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote