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

[API] TokenCondition macro use?

I'm trying to figure out this out.... With the TokenCondition API,  is the ONLY way to attach a condition token to a player token by physically dragging the condition token on top of the player token?  Is there any way to call that API via MACRO, and use a macro to attach or remove a certain Condition token instead?
1593803694
The Aaron
Roll20 Production Team
API Scripter
That is the only way that the script natively supports, but it does expose an interface for other API scripts.  Combat Master can use it for statuses.
hmmmmm..... looks like it's finally time for me to learn macros.   What about this.... In theory, the following method should work, yes? Install TokenCondition and TokenMod 1. Create a Conditions: Character Sheet 2. Create a rollable token image,  with all images the same size. 3. Use tokenmod to create a token macro,  which allows users to select which rollable image they want, at-will. 4. link that rollable token to that character sheet,  and then assign that rollable token to the token slot on that character sheet. 5. drag and drop the rollable conditions character token, from the character sheet window,  and place it on the player token. 6. Player can then use the assigned token macro to change what image the rollable token is showing at any given time. As long as all images take up the same size on the map,  that should work,  right? 
1593805659
The Aaron
Roll20 Production Team
API Scripter
uhh... maybe?  It's slightly hard for me to follow. Let me ask you this: In broad strokes, what problem are you trying to solve?
I'm trying to attach a custom facing ring to a player token,  with the option to change what the actual image used for that specific facing ring is,  for that specific token,  on-the-fly,  using a token-specific macro. I think it will work.  Still in testing mode.
1593807762
The Aaron
Roll20 Production Team
API Scripter
I see.  Well, let me know if you hit any snags!
ok, it ALMOST works.   I think there must be something wrong in how the name of a Condition:token  gets processed? I have a rollable token table,  named  " Melee_facing_RH" I create two tokens based on that table. I edit one of those tokens so that it represents a character sheet named "test" I edit the other token so that it represents a character sheet named  " Condition: RH_size_med[top|width:*1.25|height:*1.25]" I open both character sheets, and set their default tokens to the matching tokens I just created. I delete both tokens from the map. In both character sheets,  I give them an ability called "Change_Weapon", and check "show as token taction" In both abilities, I enter the following: !token-mod --set currentside|?{What facing token would you like? |  One Weapon,1 |  Buckler+Weapon,2 |  Small Shield + Wep,3 |  Med+ Shield,4 |  Two-Handed Weapon,5 |  Two Weapons Defensive,6 |  Two Weapons Offensive,7 |  Two Bucklers,8 |   Buckler on RH Small+ SH on LH,9 |   Small+Shield on RH buckler on LH,10 |   Two small+ SH,11} I drag both characters back onto the map,  so that their default token shows up. I copy-paste the ability text into chat, with each token selected: !token-mod --set currentside|?{What facing token would you like? |  One Weapon,1 |  Buckler+Weapon,2 |  Small Shield + Wep,3 |  Med+ Shield,4 |  Two-Handed Weapon,5 |  Two Weapons Defensive,6 |  Two Weapons Offensive,7 |  Two Bucklers,8 |   Buckler on RH Small+ SH on LH,9 |   Small+Shield on RH buckler on LH,10 |   Two small+ SH,11} on both tokens it works. Now, I run the "change_weapon"  ability, as a token action,  on both new tokens. On the "Test" token,  it still works. on the   " Condition: RH_size_med[top|width:*1.25|height:*1.25]" token,  it does NOT work.   The drop-down menu does not appear.  instead, I get this message in chat: Condition: RH_size_med[top|width: 1.25|height: 1.25]|Change_Weapon  and then nothing happens. Where am I going wrong here....  has to be something to do with the token name itself, right?
ok, running those same procedures on a token called Condition: Test works successfully....
ok, running those same procedures on a token called Condition: Test[] works successfully....
1593812888
The Aaron
Roll20 Production Team
API Scripter
That's really bizarre.  Is that the whole of the macro? or just the TokenMod part?
ok, running those same procedures on a token called Condition: Test[top] works successfully....
that's the whole of the macro. exactly as it is entered.
1593813084
The Aaron
Roll20 Production Team
API Scripter
I just don't see where the name would even come into that, which is what I find strange.
running those same procedures on a token called Condition: Test[top|width:*1.25] fails. and outputs message Condition: Test[top|width:*1.25]|Change_Weapon looks like it must be that vertical break line...?
1593813348
The Aaron
Roll20 Production Team
API Scripter
Yeah.  If you want to PM me an invite to your game and GM me, I can come try and figure out what's going on.
He helped me fix it,  thanks The Aaron for the record, we had to use a universal macro,    %{selected|Change_Weapon} to call the character ability named Change_Weapon which says: !token-mod --set currentside|?{What facing token would you like? |  One Weapon,1 |  Buckler+Weapon,2 |  Small Shield + Wep,3 |  Med+ Shield,4 |  Two-Handed Weapon,5 |  Two Weapons Defensive,6 |  Two Weapons Offensive,7 |  Two Bucklers,8 |   Buckler on RH Small+ SH on LH,9 |   Small+Shield on RH buckler on LH,10 |   Two small+ SH,11} otherwise, it would include the character name, which breaks things if the character name has a vertical bar in it.
Huh, that's interesting.... When I attach the Condition Token   to a player Token,    %{selected|Change_Weapon}  stops working,  even when I'm certain I have the correct Condition token selected. But If change it's name to Decoration ,  it starts working again. oh well.  Decoration SHOULD work just as well for my current purposes...
1593818631
The Aaron
Roll20 Production Team
API Scripter
The Condition changes the Represents to the character it is attached to.  The original intent was to be a condition on top of the token, since you wouldn't be able to select the actual token, the condition becomes a proxy for it. Decoration does not set represents.
makes sense..... hmmmm...... Is there a way to override the fact that Decoration is normally BENEATH the token?
1593826328
The Aaron
Roll20 Production Team
API Scripter
Hmm... not currently.  You could remove the represents from Condition with -represents in the name.
That MIGHT work.  Or I found a different workaround which is HORRIBLE coding practice,  and a total hack,  but it works. for the character Conditio n: RH_siz e_med[top|width:*1.25|height:*1.25]  Drag it's default token to the map. Run this command on the token: @{selected|character_id} Then, copy that result,  and paste it into the Token's individual NAME field Then, set that revised token as the new default token for that character sheet. You now have a character sheet,  whose token has a name,  which name is identical to the character sheet ID. Drag the Condition: Token onto a PC Token, to attach it. Then, define this macro as a universal macro:  CAlled, say, Facing_Link [Change_Ring](~@{selected|token_id}|Change_Weapon) If you press this macro button,  while you have the Condition: Token  selected, it will output to CHAT,  an ADDITIONAL link,  which will call the macro on that token's ORIGINAL character sheet, NOT the PC character sheet it currently represents. With the condition token still selected,  click on the CHAT link,  and THAT will allow you to change the rollable table of the condition token,  using the query macro which is correctly specific to THAT condition token. that way, you can have several DIFFERENT types of rollable token condition overlays,  each of which uses a DIFFERENT set of images,  and when you run the initial Facing_Link  macro,  it will output to chat a link to the CORRECT  character attribute macro,  which is neccessary to change that SPECIFIC overlay token. This is a HORRIBLE hack,  and very bad coding practice, and embarrasingly ugly,  and I'm very ashamed. But it works.