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
05-01-10, 04:20 AM   #7
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,251
end);
end;
UIFromDescriptor = function(desc, parent, state)

  Reply With Quote
05-01-10, 04:26 AM   #8
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,251
also your code should be :

Code:
local ismaxhealthpower = false;
local pt = unit:PowerType();
if unit:Health() == unit:MaxHealth() then
	if unit:Power() == unit:MaxPower() and (pt == 0 or pt == 2 or pt == 3) then
		ismaxhealthpower = true;
	elseif  unit:Power() >= 1 and (pt == 1 or pt == 6) then
		ismaxhealthpower = true;
	end
end

BTW add in SVN
  Reply With Quote
05-01-10, 04:29 AM   #9
Brainn
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 263
this is actually something i thought about a while ago as a new feature...
something like "Variable: Combine Variables" where you could add multiple variables and combine them using logical operators like and/or/not
ex: you add a variable for maxhealth and a variable: incombat, then use the feature combine variables to create a third variable x that links those two variables with an and operator, but i thought that would be used so rarely that its not worth to create a feature for it. it could use a editor somewhat like the filterset-editor but without all the sets and instead a selection of all existing variables in the object.
  Reply With Quote
05-01-10, 04:35 AM   #10
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,251
I was more thinking about a generic variable, where you can choose your variable name, the type and enter a small script.
  Reply With Quote
05-01-10, 04:58 AM   #11
Brainn
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 263
that would in effect lead to the same thing, using other variables that exist in the object should be possible, but you would use a small script to combine them instead of a complex feature-editor.
  Reply With Quote
05-01-10, 05:08 AM   #12
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Oh, and fyi:

local str = "This feature is inverse when power is rage. \n";

should be

local str = "This feature is inverse for Runic Power or Rage. \n";

I mistyped the first time.
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **
  Reply With Quote
05-01-10, 05:11 AM   #13
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Also, another question before it becomes lost, is Variable Based Period Repaint possible?

To switch between multiplexer and period repaint say, if the new variable (var_ismaxhealthpower) triggered could it switch from multiplexer to 0.1 repaint or something? Or not possible?


Still getting the same error by the way, when trying to drag and drop "Var: isMaxHealthPower?", not sure what I did X_X


Code:
nterface\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>

Code:
Interface\AddOns\VFL\UI\DragDrop.lua:70: VFLUI.DragContext:Drag(): called twice.

Stack trace:
-----------
Interface\AddOns\VFL\UI\DragDrop.lua:70: in function `Drag'
Interface\AddOns\RDX\ObjectMgr\FeatureEditor.lua:26: in function <Interface\AddOns\RDX\ObjectMgr\FeatureEditor.lua:22>
I just tried it on my girlfriends computer / account.

Error persists there, too. So it isn't just me.
__________________


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

Last edited by unlimit : 05-01-10 at 06:02 AM.
  Reply With Quote
05-01-10, 06:37 AM   #14
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,251
Fixed

Don't know exactly where is the problem.

I copy paste an other feature and just replace the code inside.
  Reply With Quote
05-01-10, 07:21 AM   #15
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Yep, fixed up just fine, besides one importaint part:

Runic Power & Rage still don't work xD

Code:
	elseif  unit:Power() >= 1 and (pt == 1 or pt == 6) then
		ismaxhealthpower = true;
This line must be wrong somehow.
__________________


kúdan: im playing pantheon
JRCapablanca: no youre not
** Pantheon has been Banned. **
  Reply With Quote
05-01-10, 07:24 AM   #16
unlimit
Lookin' Good
 
unlimit's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 484
Code:
	elseif  unit:Power() = 0 and (pt == 1 or pt == 6) then
		ismaxhealthpower = true;
Oh, that's because the math is wrong! :P Sorry. Most of my original code or contribution was screwed up anyways. D:

So just change >= 1 to == 0
__________________


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

Last edited by unlimit : 05-01-10 at 07:27 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