Identify which bar you currently are using switch it

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
dorpond
RPTools Team
Posts: 5530
Joined: Thu Jun 01, 2006 2:05 pm
Location: Buffalo, NY

Identify which bar you currently are using switch it

Post by dorpond »

OK I have no idea how to approach this, but I am looking to write a macro to follow this logic:

If bar is currently green, then change it to red; if it is red, then change it to green.
(I use bars to specify Current HP)

Basically it will be used when a NPC/Monster changes loyalties or factions - one quick click and their bar switches to the other color that it isn't currently.

My guess is that this will only be a few lines of code, I just have no idea what code it would be.

Thanks in advance!
How to use my bundled artwork (MT1.3B60+): http://forums.rptools.net/viewtopic.php?f=8&t=11759

User avatar
aliasmask
Deity
Posts: 8625
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Identify which bar you currently are using switch it

Post by aliasmask »

I you use one of the MT built in bars specifying 2 colors but since the border shares a color it's a bit odd looking so I recommend 2 images, 1 red bar, 1 green bar. Set increments to 2 and if you set the bar to 0, then it's one color and anything else like 1 then it's the other. So, lets call this bar RedGreen.

To toggle the bar color you do this:

Code: Select all

[H: bar.RedGreen = 1 - bar.RedGreen]

dorpond
RPTools Team
Posts: 5530
Joined: Thu Jun 01, 2006 2:05 pm
Location: Buffalo, NY

Re: Identify which bar you currently are using switch it

Post by dorpond »

I'm not sure if you misunderstood my question of it I just didn't understand your answer. :p

I already have bars that are fully functional with my damage/heading macros - I've been using them for years, what I want is a simple macro that will be smart enough to look at what color the token is currently is using (let's say it's red and half way ATM), and with the click of the macro button, it switches it to the other color.

Changes loyalty- it is no longer a damaged red bar (bad guy), it is a damaged green bar (now a good guy) (but the macro is also smart enough to change a green bar to a red, because it retrieves what its current color is and makes it the other)

Make better sense?
How to use my bundled artwork (MT1.3B60+): http://forums.rptools.net/viewtopic.php?f=8&t=11759

User avatar
aliasmask
Deity
Posts: 8625
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: Identify which bar you currently are using switch it

Post by aliasmask »

Do you have your red and green bars already or is it something you need to create?

Sounds like you have some visual that indicates allies and enemies. If it is a standalone image in bar format that only have 2 settings, green or red, then setting the bar value to 1 or 0 does the trick.

Now, if it's more complicated than than perhaps a health bar for allies and enemies where you need to turn one off and the other on setting the value from one to the other then it's just a matter of taking the value of one and setting to the other then turning off the first one.

All the bar functions can be found here: http://lmwcs.com/rptools/wiki/Category:Bar_Function

So, here is the pseudo-code I imagine from your description:

Code: Select all

[H, if(isBarVisible("greenBar")), code: {
   <!-- set redbar to value of greenbar -->
   [H: bar.redBar = bar.greenBar]
   <!-- turn off greenbar -->
   [H: setBarVisible("greenBar",0)]
};{
   [H: bar.greenBar = bar.redBar]
   [H: setBarVisible("redBar",0)]
}]


If this doesn't give you a clue then perhaps screen shots or your campaign file are necessary.

dorpond
RPTools Team
Posts: 5530
Joined: Thu Jun 01, 2006 2:05 pm
Location: Buffalo, NY

Re: Identify which bar you currently are using switch it

Post by dorpond »

That worked like a champ, thanks, AM!!
How to use my bundled artwork (MT1.3B60+): http://forums.rptools.net/viewtopic.php?f=8&t=11759

Post Reply

Return to “Macros”