View Single Post
05-01-10, 03:12 AM   #6
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
So, I tried to make a variable all my own, but I've decided I can't figure out this crazy LUA language.

^- Is not a programmer.

I tried to make it be inverse, since Warriors, Bear Druids, and Deathknights's power starts at 0, not at 100%.

=(

Code:
RDX.RegisterFeature({
	name = "var_IsMaxHealthPower"; title = i18n("Var: IsMaxHealthPower?"); category = i18n("Variables: Unit Status");
	IsPossible = function(state)
		if not state:Slot("EmitPaintPreamble") then return nil; end
		return true;
	end;
	ExposeFeature = function(desc, state, errs)
		state:AddSlot("BoolVar_ismaxhealthpower");
		return true;
	end;
	ApplyFeature = function(desc, state)
		state:Attach(state:Slot("EmitPaintPreamble"), true, function(code) code:AppendCode([[
local ismaxhealthpower = false;
local pt = unit:PowerType();
	if unit:Health() == unit:MaxHealth() and unit:Power() == unit:MaxPower() then
		if pt == 0 or pt == 2 or pt == 3 then
		ismaxhealthpower = true;
		end
	elseif unit:Health() == unit:MaxHealth() and unit:Power() >= 1 then
		if pt == 1 or pt == 6 then
		ismaxhealthpower = true;
		end
]]);
		end);
	UIFromDescriptor = function(desc, parent, state)
		local ui = VFLUI.CompoundFrame:new(parent);
		
		local stxt = VFLUI.SimpleText:new(ui, 2, 200); stxt:Show();
		local str = "This feature is inverse when runic power or rage. \n";
		
		stxt:SetText(str);
		ui:InsertFrame(stxt);

		function ui:GetDescriptor()
			return {feature = "var_ismaxhealthpower"};
		end
		
		return ui;
	end;
	CreateDescriptor = function() return { feature = "var_ismaxhealthpower" }; end
});
I'd like to think I did okay for my first time trying to do ANY type of coding, but I don't think I did.

This is the error message that I get when trying to add my variable. D:<

Code:
Interface\AddOns\RDX\ObjectMgr\FeatureEditor.lua:314: attempt to index local 'feat' (a nil value)

Stack trace:
-----------
Interface\AddOns\RDX\ObjectMgr\FeatureEditor.lua:395: in function <Interface\AddOns\RDX\ObjectMgr\FeatureEditor.lua:394>
Interface\AddOns\RDX\ObjectMgr\FeatureEditor.lua:78: in function <Interface\AddOns\RDX\ObjectMgr\FeatureEditor.lua:59>
Interface\AddOns\RDX\ObjectMgr\FeatureEditor.lua:246: in function `OnDrop'
Interface\AddOns\VFL\UI\DragDrop.lua:48: in function <Interface\AddOns\VFL\UI\DragDrop.lua:40>
So, was I close to correct? Is what I made fixable?

or should I never attempt this again?
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **

Last edited by unlimit : 05-01-10 at 04:18 AM.
  Reply With Quote