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?