View Single Post
01-16-13, 05:53 PM   #3
Expunge
A Defias Bandit
Join Date: Sep 2008
Posts: 2
Originally Posted by Phanx View Post
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)
Doh. I knew it was something silly like that. Thank you for the help Phanx, love your work!
  Reply With Quote