Thread Tools Display Modes
04-30-10, 05:42 PM   #1
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Two Questions: Variable Based Period Repaint & Combining Variables

Well, since I don't know the first thing about LUA, I need some help.

The unitframes I'm creating right now automatically switch from portrait to healthbars when you're either not at Max Health OR at Max Power.

Now, there are a couple of problems with what I want.

If I use two show/hide variables (in this case, IsMaxHealth & IsMaxPower) on the same subframe, one of them doesn't work. When I lose health, It doesn't update, however when I lose power, it updates.

I want to combine both of them, for IsMaxHealth OR IsMaxPower for it to update.

Now, with that said, there's another problem.

Because I use a portrait, I can't use periodic repaint, or my portrait will flicker animations over and over again.

Is it possible to create a variable based Period Repaint? When a variable is triggered it can switch between Multiplexer Parameters & Periodic Repaint events?

Such as, as long as I'm IsMaxHealth & IsMaxPower, it will be Multiplexer, but if I lose health OR Power, it will trigger an event to repaint every 0.1 seconds?

Otherwise I'm going to have to get rid of my portrait. D:<
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **
  Reply With Quote
04-30-10, 11:47 PM   #2
Dgrimes
A Black Drake
 
Dgrimes's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 89
Code:
local maxhealthpower = false;

if (unit:Health() == unit:MaxHealth()) and (unit:Power() == unit:MaxPower()) then
  maxhealthpower = true;
end
Make that into a variable script.
__________________
What was is, what will be was.
  Reply With Quote
05-01-10, 12:04 AM   #3
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Originally Posted by Dgrimes View Post
Code:
local maxhealthpower = false;

if (unit:Health() == unit:MaxHealth()) and (unit:Power() == unit:MaxPower()) then
  maxhealthpower = true;
end
Make that into a variable script.
That's funny, I JUST finished making this one with the help of my friend. xD Came on here to post it!

Code:
RDX.RegisterFeature({
	name = "var_isMaxAll"; title = i18n("Var: IsMaxAll?"); 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_ismaxall");
		return true;
	end;
	ApplyFeature = function(desc, state)
		state:Attach(state:Slot("EmitPaintPreamble"), true, function(code) code:AppendCode([[
local ismaxall = false;
if unit:Health() == unit:MaxHealth() and unit:Power() == unit:MaxPower() then ismaxall = true end;
]]);
		end);
		local mux = state:GetContainingWindowState():GetSlotValue("Multiplexer");
		local mask = mux:GetPaintMask("HEALTH");
		mux:Event_UnitMask("UNIT_HEALTH", mask);
	end;
	UIFromDescriptor = VFL.Nil;
	CreateDescriptor = function() return { feature = "var_isMaxAll" }; end
});
I guess calling it "IsMaxPowerHealth" or, like you put, "MaxPowerHealth" would be better than "IsMaxAll"
__________________


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

Last edited by unlimit : 05-01-10 at 12:08 AM.
  Reply With Quote
05-01-10, 12:10 AM   #4
Dgrimes
A Black Drake
 
Dgrimes's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 89
The problem with the variable you just made is that it only adds the multiplexer for the unit health, not both. You don't need to add them again to your unit frame if you are already using the fh/fm variables which I would presume you are since you are using status bars.
__________________
What was is, what will be was.
  Reply With Quote
05-01-10, 12:26 AM   #5
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
See, what I did was, I just copy and pasted the IsMaxHealth one, and tried to combine the two.

I don't know LUA :S

Though, I am having my friend help me with another part.

So, I don't understand what I'd have to get rid of. I really would love to learn LUA but I don't have the time right now.
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **
  Reply With Quote
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

WoWInterface » Featured Projects » OpenRDX » OpenRDX Community » OpenRDX: Community Chat » Two Questions: Variable Based Period Repaint & Combining Variables


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off