WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   OpenRDX: Community Chat (https://www.wowinterface.com/forums/forumdisplay.php?f=107)
-   -   Two Questions: Variable Based Period Repaint & Combining Variables (https://www.wowinterface.com/forums/showthread.php?t=32225)

unlimit 04-30-10 05:42 PM

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:<

Dgrimes 04-30-10 11:47 PM

Code:

local maxhealthpower = false;

if (unit:Health() == unit:MaxHealth()) and (unit:Power() == unit:MaxPower()) then
  maxhealthpower = true;
end

Make that into a variable script.

unlimit 05-01-10 12:04 AM

Quote:

Originally Posted by Dgrimes (Post 186642)
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"

Dgrimes 05-01-10 12:10 AM

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.

unlimit 05-01-10 12:26 AM

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. :(

unlimit 05-01-10 03:12 AM

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? :(

sigg 05-01-10 04:20 AM

end);
end;
UIFromDescriptor = function(desc, parent, state)

:eek:

sigg 05-01-10 04:26 AM

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

Brainn 05-01-10 04:29 AM

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.

sigg 05-01-10 04:35 AM

I was more thinking about a generic variable, where you can choose your variable name, the type and enter a small script.

Brainn 05-01-10 04:58 AM

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.

unlimit 05-01-10 05:08 AM

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.

unlimit 05-01-10 05:11 AM

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.

sigg 05-01-10 06:37 AM

Fixed

Don't know exactly where is the problem.

I copy paste an other feature and just replace the code inside.

unlimit 05-01-10 07:21 AM

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.

unlimit 05-01-10 07:24 AM

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


All times are GMT -6. The time now is 10:16 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI