Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

[Script] TokenCondition -- Easily add full Token Condition Images to Character and Monster Tokens.

December 19 (5 years ago)

Edited January 01 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Update v0.1.1 -- So much changed, it's practically a different script... (Thanks Rainy)

Fixed GroupInitiative integration issue (Thanks Serpent-DM )


TokenCondition v0.1.1

TokenCondition makes it easy to drop condition tokens onto your player and monster tokens. Simply create a Character with a name that starts with Condition:, such as Condition: Charmed. Create a Token that represents that Character and assign it to the Character as the Default Token. When you want ot assign that condition to a Token, drag the condition Character's default token on top of it. From then on, it will stick to the Token and any changes made to either one will be mirrored correctly. When you're done with the condtion, just delete the Token. You can even drag multiple condtions onto a single token.

Commands

!token-condition

Display this help.

Controlling Mirroring

For more fine-grained control, you can add a bracketed block to the character name and specify various | delimited tags.

Use the mirror tag to specify properties to mirror.

Condition: Confused [mirror:aura1_radius]

The mirror tag takes as argument a comma delimited list of properties and can include spaces around the punctuation:

Condition: Confused [mirror : aura1_radius, aura2_radius , aura1_color ,aura2_color]

Properties can be preceded by an operation: +-

  • + -- Add the property to the list that are mirrored. (default)
  • - -- Remove the property to the list that are mirrored.
Condition: Confused [mirror: -width, -height]

In addition to the mirror tag, you can list several adjustments tags that are applied when mirroring properties. Adjustment tags are separated from their adjustment by a :.

  • rotation
  • width
  • height
  • left
  • top

Adjustment values are prefixed with one of several operations:

  • = -- Always set the propery to this value if it would change.
  • + -- Add this value to the property when it is changed.
  • - -- Subtract this value from the property when it is changed.
  • * -- Multipy by this value when the property is changed.
  • / -- Divide by this value when the property is changed.

For example, to have the width always 3 times larger than the target token, you could use:

Condition: Confused [width:*3]

Additionally, you could adjust the rotation to be 90 degrees further than the target token:

Condition: Confused [rotation:+90|width:*3]

Numbers can be suffixed with ug, etc just like with TokenMod.

The below tag can be specified to cause a token to be pushed below when it is created. Note: This is a one time adjustment currently.

Here is an example where the token is placed below and remains slightly larger than the target token:

Condition: Confused [below|width:*1.2|height:*1.2]

[EXPERIMENTAL] The forward tag works just like the mirror tag, save that any changes to the listed properties are reverted after they are mirrored forward. This is an incomplete feature which will probably get changed later, but is provided for experimentation.

Name Prefixes

In addition to the Condition name prefix, there are several more. Prefixing with any of the following will make the character active for TokenCondition, with varying default behavior:

  • Condition -- Mirrors: left, top, width, height, lastmove, controlledby, bar1_value, bar1_max, bar1_link, bar2_value, bar2_max, bar2_link, bar3_value, bar3_max, bar3_link, represents, statusmarkers, and tint_color.
  • Decoration -- Is below and mirrors: left, top, width, height, lastmove, and controlledby.
  • Mount -- Is below and mirrors: left, top, width, height, lastmove, controlledby, and rotation.
Character Name Examples

A speaking condtion that floats to the top right of a token and does not change size:

Condition: Speaking [left:+.75|top:-.75|mirror:-width,-height]

A spirit guardians decoration that is sized correctly and follows the token:

Decoration: Spirit Guardians [width:7g|height:7g]

A horse mount that is 3 times longer than it is tall, and scaled for the token that rides it. Additionally, it's rotation is corrected to account for the direction the horse image faces:

Mount: Horse [rotation:+90|width:*3]


TokenCondition v0.1.0

TokenCondition makes it easy to drop condition tokens onto your player and monster tokens. Simply create a Character with a name that starts with Condition:, such as Condition: Charmed. Create a Token that represents that Character and assign it to the Character as the Default Token. When you want ot assign that condition to a Token, drag the condition Character's default token on top of it. From then on, it will stick to the Token and any changes made to either one will be mirrored correctly. When you're done with the condtion, just delete the Token. You can even drag multiple condtions onto a single token.

Commands

!token-condition

Display this help.



Token Conditions will automatically get scaled to the size of the token they are dropped on.  Any manipulations (bar changes, status markers, move, resize, auras, etc) applied will be duplicated to the target token and any conditions.


Additionally, it does what you would expect with TokenMod and GroupInitiative.


Github:   https://github.com/shdwjk/Roll20API/blob/master/TokenCondition/TokenCondition.js





If you use my scripts, want to contribute, and have the spare bucks to do so, go right ahead. However, please don't feel like you must contribute just to use them! I'd much rather have happy Roll20 users armed with my scripts than people not using them out of some sense of shame. Use them and be happy, completely guilt-free!
Disclaimer: This Patreon campaign is not affiliated with Roll20; as such, contributions are voluntary and Roll20 cannot provide support or refunds for contributions.
December 19 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

You mad wizard, you!

December 19 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

I am not mad, merely perturbed! =D

December 23 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

Very intriguing. Is this serving the same purpose of the old Custom Status Markers script?

December 23 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

No, Custom Status Markers does a bit more, I think.  This basically just decorates a token with a same sized graphic which will then follow the token around and delegates all changes on it to the real token/character.

December 23 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter

I'm curious about the timing of the release of this script. Does this offer an advantage over the new custom token markers? 

December 23 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Nope, just a different way of doing some things.  It came out of this discussion: https://app.roll20.net/forum/post/7989442/animated-conditions

It sounded like a fun problem to solve, so I solved it. =D

Well, this script will let us play around with full-token-sized markers, right, Aaron? That's something the built-in custom token markers aren't equipped to do (yet).

(Plus, it means that !Bump now has a codebase sibling.) :-)

December 23 (5 years ago)
GiGs
Pro
Sheet Author
API Scripter


The Aaron said:

Nope, just a different way of doing some things.  It came out of this discussion: https://app.roll20.net/forum/post/7989442/animated-conditions

It sounded like a fun problem to solve, so I solved it. =D


Ahh that makes sense. Great :)

December 23 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter


Lady Victoria said:

Well, this script will let us play around with full-token-sized markers, right, Aaron? That's something the built-in custom token markers aren't equipped to do (yet).

(Plus, it means that !Bump now has a codebase sibling.) :-)


Well, that's true!  It also works with animated tokens. 

At this point, Bump has quite a few siblings abs even some cousins!  I know I said I'd modify Bump, but I actually wrote this from scratch, save for copying the list of properties to clone.  =D


December 30 (5 years ago)
Mino
Marketplace Creator

Oh, would there be a way to define if the condition goes above or below the token in question, as well as define a scale for the condition? If it's not too much trouble, I have a bunch of animated conditions that go underneath the token, and takes up a 3x3 grid. I had given up on the api being able to control them for a good long while, but since this seems to work just fine with animated conditions, would it be possible to add those kinds of control to work with my existing images?



In this example, the left image is how the API works currently, while the right image is the ideal use I'm looking for. I'd be willing to provide a copy of all my animated conditions for testing purposes if you want to add support.


Hopefully it's not too much trouble. Thanks for this script either way though!

December 31 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

I can definitely do that. Let me think about the best way to do that...

January 01 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Updated to version 0.1.1!

I added the full help to the initial post, but here are the highlights:

You can prefix with one of Condition, Decoration, or MountCondition behaves the same as before,  Decoration only mirrors position, size, and control and is placed below the target token.  Mount is just like Decoration, but also mirrors rotation.

Additionally, you can can adjust what is mirrored and how by adding a bracketed list of options to the Character name:

Decoration: Charmed [width:*3|height:*3]

Would make a decoration that is 3 times the size of the token it is applied to, and below it.  For more examples, see the help text above, and of course, ask questions!

January 01 (5 years ago)
Mino
Marketplace Creator

Nice! That did exactly what I needed it to. Even made it work with scaled tokens. Thanks for the help!



Though, on the topic of scaling, I noticed some strange behavior when using the bracketed list options as provided with the Spirit Guardians example.

Decoration: Charmed [width:3g|height:3g]

In this case, the command keeps it at a 3x3 grid no matter what. And, sure enough, the decoration doesn't scale when the carrier is scaled up.
However, if I try to scale the decoration up beyond 3x3, it'll automatically snap back to 3x3, which is expected behavior. Yet, it'll scale the carrier up to whatever value you picked.

I'm guessing the code for mirroring scaling the carrier token goes through even though no scaling actually happens. I could only really see this being an issue if someone made a horse token or something (Though, that'd be used with the Mount Prefix instead,) and tried to Enlarge/Reduce the horse but not the rider. However, I think this is a rare situation. Just something I noticed.

Regardless, using the multiplicative example you provided works perfectly for what I was trying to do, so, thanks again for the help!


January 01 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Looking great so far!

Trying to put medium rider in upper left square of large mount since I would like horse and rider to be in discrete squares. They still center on each other. I am using the name:

Mount: Horse [width:2g|height:2g|left:+1|top:+1]

What am I doing wrong?

January 01 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Try:

Mount: Horse [width:2g|height:2g|left:+1g|top:+1g]

+1 will just be a single pixel.

January 01 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter


Rainy said:

Nice! That did exactly what I needed it to. Even made it work with scaled tokens. Thanks for the help!



Though, on the topic of scaling, I noticed some strange behavior when using the bracketed list options as provided with the Spirit Guardians example.

Decoration: Charmed [width:3g|height:3g]

In this case, the command keeps it at a 3x3 grid no matter what. And, sure enough, the decoration doesn't scale when the carrier is scaled up.
However, if I try to scale the decoration up beyond 3x3, it'll automatically snap back to 3x3, which is expected behavior. Yet, it'll scale the carrier up to whatever value you picked.

I'm guessing the code for mirroring scaling the carrier token goes through even though no scaling actually happens. I could only really see this being an issue if someone made a horse token or something (Though, that'd be used with the Mount Prefix instead,) and tried to Enlarge/Reduce the horse but not the rider. However, I think this is a rare situation. Just something I noticed.

Regardless, using the multiplicative example you provided works perfectly for what I was trying to do, so, thanks again for the help!



That's because it is mirroring the size change, kind of a round about way to the Forward behavior.  You can get it to not do that with:

Decoration: Charmed [width:3g|height:3g|mirror:-width,-height]

January 01 (5 years ago)

Edited January 01 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter


The Aaron said:

Try:

Mount: Horse [width:2g|height:2g|left:+1g|top:+1g]

+1 will just be a single pixel.


Derp.

Thanks. After some tweaking I figured out that it needed to be:

Mount: Horse [width:2g|height:2g|left:+.5g|top:+.5g]

Works great. They even fit nicely on the MM horse portrait. :D



January 01 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Nice!

January 02 (5 years ago)

Interesting! This seems like it could be used for a lot more than just conditions! Might wanna change the title!


Would it be possible to make the condition follow any rotation, while still allowing it to rotate freely without impacting the followed token? If I do mirror rotation+90 for instance, and rotate either token they will rotate with each other, but I would like it if the condition only followed the token's rotation, not the other way around as well

January 02 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

You're thinking about tank turrets, right?  I can add that in the next iteration. Kind of a "reverse" tag. Actually, that would be pretty easy. The major complication is the same thing that is a problem with the "forward" tag right now: I need a way to specify that the change should be additive and not absolute. 

Titles are immutable on the forum, outside of mod or dev intervention. =D I'll just have to fix it on the next thread. 

January 02 (5 years ago)

Yeah, exactly! So I'd be able to rotate the turret freely but if I rotate the hull the turret rotates the same amount.


And ah, yeah, I can see how that is problematic since the API only checks when something updates, and doesn't have any data on an object before the update? If so it'd be hard to know how much the object rotated I guess

January 02 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

No, it does get the precious state in the event, it's more about where I'm updating the dependent objects I need to know how to apply it. Some properties should overwrite (tint_color), but others should just apply the delta (rotation), but sometimes we don't want the delta (rotation). So it's a question of when/where to specify that, and how to make it as intuitive as possible. 

So I'm not sure exactly what I did wrong here with this, but for some reason, the condition automatically goes behind the implied token every time like it just is re-figured to go on the bottom layer no matter what. Is there a parameter I'm missing to keep it above?

January 12 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Hmm. What is the name of the character the token is associated with for the condition?

January 16 (5 years ago)

Edited January 16 (5 years ago)
keithcurtis
Forum Champion
Marketplace Creator
API Scripter

Here's a fun use. Find a torch token. Create a character and call it:

Condition: Torch [width:.5g|height:.5g|left:-.25g|top:-.25g]

Make sure its "controlled by" and "In Journal" fields are blank.

Set the light to 40/20,  and give it "Sight" and "All Players See Light".

Save as default token.

You now have a drag and drop torch you can add to any character. I set it to appear on the upper left hand corner of the token, so as not to interfere with Token Markers. Giving it Sight is essential so that it will appear on top of the character token. (Performance is actually better than this—my gif capture software is pretty weak). Player view on left, GM view on right.


Map is from Forge of Fury by Wizards of the Coast, used for demo purposes. Tokens are mine. Nifty compact journal tab style is here.

January 16 (5 years ago)
vÍnce
Pro
Sheet Author

That's cool.

January 20 (5 years ago)

Oooh, that's nice! Will definitely have to make myself one of those!


By the way, any progress on the rotating conditions? Would be real nice to be able to do some testing of this idea of mine!

January 20 (5 years ago)
The Aaron
Roll20 Production Team
API Scripter

Oh!  I got totally caught up in other things!  I'll take a look tonight. Setting a reminder. 

February 10 (5 years ago)

Hey! Hope It's not sounding like I'm nagging, I'm just genuinely appreciating that you're even willing to look into it, I'm just curious if you have any idea of how to add the functionality I'm looking for or if you've hit a snag and likely won't be able to do it!


Thanks a bunch regardless!

March 05 (4 years ago)

First off, love the API! Just started using it with animated effect tokens.
I was wondering if there is a way to layer tokens. i.e. whenever a new token is placed it pushes the old token right while keeping it on the same plane.
I would like to have a layer of active effects on the bottom of tokens without having to code each position (although I will if there is currently no other way).

Maybe something like - [left: +Condition: Name]?

March 06 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Oh, basically the same behavior as TokenStatusMarkers, where they start stacking up from some location?  That could be done, I'll have to think about how I would do that...

March 19 (4 years ago)

Edited March 19 (4 years ago)

Whenever I use this, the "condition" seems to inherit the settings of the token its on. So it suddenly has bars and HP for example (the same as whatever token its on), even if that condition token is set to have no bars. Any thoughts on this? (I'm specifically looking at this type of char as condition: Condition: Torch [width:.5g|height:.5g|left:-.25g|top:-.25g])

Pre drop on the left, post drop on the right (I changed the hit points in between so the red dot didn't cover up the icon, as status indicators are also inherited):


March 20 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Change the name to:

Decoration: Torch [width:.5g|height:.5g|left:-.25g|top:-.25g]

And it should do what you want. =D


The Aaron said:

Change the name to:

Decoration: Torch [width:.5g|height:.5g|left:-.25g|top:-.25g]

And it should do what you want. =D


Thank you! Follow up questions:

  1. If I want the torch to sit on top of the char token, but still maintain the "decoration" mirroring, is there a way to do that?
  2. Is there a command to "drop" the decoration (say the char wants to drop the torch, but I don't want to delete it and drag a new one back out)?

So if I wanted to do this with my torch, light spell and any other light source how would I do that? 

The mount thing looks hella cool too. 

April 23 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Just like the mount.  You'd make a token with the properties you want (light, size, etc), then assign it to a Character, then name that character something like:

Decoration: Torch

Then just drag it out and drop it on the character you want it attached to.  It will exist under that character, and follow after them.

You might want to add some minor tweaks to make it more apparent, such as:

Decoration: Torch [top:-.5g|left:+.5g]

That will make it placed just under the top right corner of the token, making it easier to see, and easier to select and delete when you want to remove it.

Thanks. 

I should be able to do that with other items too right? 

April 23 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Oh yeah!  It's fantastic for things like Spirit Guardians, where you have a zone following something.

Is this going to be turned into one of the added scripts or will be it be where I have to install it myself for a while? 

April 23 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

It should already be in the 1-click scripts.

April 23 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Just verified, it's in there under Utilities

So I have a torch token tried to put it on another token and it didn’t work what do I need to do to the torch token so it will meld with the original token 

April 24 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Does the Token represent the "Decoration: Torch" character?

How do I make a character a decoration? I thought by loading the api any token just became a decoration lol 

April 24 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

It's based on the Character's name, if it a character's name starts with "Decoration:", "Condition:" or "Mount:", TokenCondition will use it.

I'm really enjoying the utility of this script. I haven't looked at the code (yet), but I was wondering how plausible it would be to modify the script to allow the parameters (positioning, size, etc.) to be put into the token's GM Notes?

I might be the only one who wants this, I dunno. I figure I'll be setting all these up for my players anyway, and it'd look tidier and more immersive™ in the journal.

April 24 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

It shouldn't be too hard to support both. I'll take a look. 

April 24 (4 years ago)
The Aaron
Roll20 Production Team
API Scripter

Ok, I can definitely do that, but it's going to break the external API interface to TokenCondition that CombatMaster uses.  Let me get that squared away so CombatMaster isn't broken by the change and I'll get GM Notes based configuration setup. =D


The Aaron said:

It's based on the Character's name, if it a character's name starts with "Decoration:", "Condition:" or "Mount:", TokenCondition will use it.

So does the item need that name or the token need that name? Cause I already name them tokens with that %%numbered%% script so I can do that again