Thread Tools Display Modes
07-04-09, 04:12 AM   #1
netquick
A Murloc Raider
Join Date: Oct 2008
Posts: 4
UF Based on Class

Hello community.

I was playing around with rdx since a while and I have set up my own unitframes now.
As a druid I created a special player-unitframe that shows my druid's mana even in cat- and bearform.
The "problem" is now, that I have two player unitframes - one for druids and one for other classes. I am looking for a way to switch the playerframe based on the class i play.
I know i could do it with desktops, but I prefer to have a single desktop that works for all classes. I like to keep the list of desktops to choose as small as possible.

I don't know if there is a way to script it in autoexec. I am very bad in lua at the moment.

I would be very thankful for hints and suggestions about that. I can imagine that there are different ways to realize that.

greetings, netquick
  Reply With Quote
07-16-09, 12:11 PM   #2
netquick
A Murloc Raider
Join Date: Oct 2008
Posts: 4
I played around a bit with the frames and still have no final solution. Currently I use different desktops with different playerframes.

What I did so far:

I added the following code to my autoexec script:
Code:
RDX.RegisterFeature({
    name = "Variable: Druid Mana (dmana)";
    title = "Variable: Druid Mana (dmana)";
    category = i18n("Variables: Unit Status");
    IsPossible = function(state)
        if not state:Slot("EmitPaintPreamble") then return nil; end
        if state:Slot("Var_dmana") then return nil; end
        return true;
    end;
    ExposeFeature = function(desc, state, errs)
        state:AddSlot("Var_dmana");
        state:AddSlot("FracVar_dmana");
        return true;
    end;
    ApplyFeature = function(desc, state)
        state:Attach(state:Slot("EmitPaintPreamble"), true, function(code) code:AppendCode([[
local maxmana = UnitPowerMax("player",0);
local actmana = UnitPower("player",0);     
dmana = format("%.2f", (actmana/maxmana));
]]); 
        end);
        local mux = state:GetContainingWindowState():GetSlotValue("Multiplexer");
        local mask = mux:GetPaintMask("POWER");
        mux:Event_UnitMask("UNIT_POWER", mask);
    end;

    UIFromDescriptor = VFL.Nil;
    CreateDescriptor = function() return { feature = "Variable: Druid Mana (dmana)" }; end
});
I created an additional bar that shows this variable "dmana" under the regular powerbar. It works fine on my druid. I always have control over my manapool.

When I play another class that uses mana it works too. There is just a little difference in updating the two bars (powerbar and dmana-bar)

But when I play a class without mana it throws an error. That's why I asked about a way to switch unitframes.
Now I thought about scripting it the way that "dmana" only shows mana if unit player is a mana class and energy, rage or runic power if it's that kind of power.

Something like:

Code:
local maxmana = UnitPowerMax("player",0);
local actmana = UnitPower("player",0);
local maxpwr = UnitPowerMax("player");
local actpwr = UnitPower("player")     
local isclass = UnitClass("player")

if isclass = druid then
	dmana = format("%.2f", (actmana/maxmana));
else
	dmana = format("%.2f", (actpwr/maxpwr));
end;
I am that bad in lua & scripting that I don't know how to correctly code that if/else part. Any help about that?

Thanks i.a.
netquick

Last edited by netquick : 07-16-09 at 12:14 PM.
  Reply With Quote
07-18-09, 02:12 AM   #3
Brainn
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 263
1. Create a Symlink-Type Object and set the link to one of your Unitframes
2. Point your Single-Unitframe Window to that Symlink instead of the actual Unitframe
3. Add something like this to your autoexec script:
Code:
if (UnitClass("PLAYER") == "Druid") then
   RDXDB.SetSymLinkTarget("path:to_your_simlink", "path:to_your_druid_unitframe")
else
   RDXDB.SetSymLinkTarget("path:to_your_simlink", "path:to_your_NONdruid_unitframe")
end
  Reply With Quote
07-18-09, 02:31 AM   #4
sigg
Featured Artist
 
sigg's Avatar
Featured
Join Date: Aug 2008
Posts: 1,251
Add SVN

Code:
ApplyFeature = function(desc, state)
		state:Attach(state:Slot("EmitPaintPreamble"), true, function(code) code:AppendCode([[
			local dmana = 0;
			if UnitClass(uid) == "DRUID" then
				dmana = format("%.2f", (UnitPower(uid,0)/UnitPowerMax(uid,0)));
			end
			]]);
		end);
		local mux = state:GetContainingWindowState():GetSlotValue("Multiplexer");
		local mask = mux:GetPaintMask("POWER");
		mux:Event_UnitMask("UNIT_POWER", mask);
	end;

Last edited by sigg : 07-18-09 at 02:34 AM.
  Reply With Quote
07-18-09, 01:17 PM   #5
netquick
A Murloc Raider
Join Date: Oct 2008
Posts: 4
Thanks a lot!
for:
answering my question about changing the frame with symlinks

for:
adding the code to svn
one thought about it:

instead of returning "0" when player is not a druid, can you change it to show actual power then? Reason: I create a powerbar with let's say 10px and a dmana-bar with 4px. If player is not a druid I would make it look like a 14px powerbar when both bars show the actual powertype. It's the same like it looks on my druid when in no form.

Code:
ApplyFeature = function(desc, state)
		state:Attach(state:Slot("EmitPaintPreamble"), true, function(code) code:AppendCode([[
			local dmana = 0;
			if UnitClass(uid) == "DRUID" then
				dmana = format("%.2f", (UnitPower(uid,0)/UnitPowerMax(uid,0)));
			else
				dmana = format("%.2f", (UnitPower(uid)/UnitPowerMax(uid)));
			end
			]]);
		end);
		local mux = state:GetContainingWindowState():GetSlotValue("Multiplexer");
		local mask = mux:GetPaintMask("POWER");
		mux:Event_UnitMask("UNIT_POWER", mask);
	end;
What do you think? The only problem I had with two bars showing the same powertype: there was a little difference in updating the bars, but I think it was more because of my bad skills than a real issue.

Again many thanks for your help with that - I really love your addon.

netquick
  Reply With Quote

WoWInterface » Featured Projects » OpenRDX » OpenRDX Community » OpenRDX: Community Chat » UF Based on Class


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