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

Use macro to choose from rollable table token

November 04 (4 years ago)

Greetings and good afternoon coding Lords & Ladies!

I've got a druid in one of my games and I just got the WildShapeResizer API working correctly. He's got a dozen or so forms that I have a rollable table set up with and I've put each of the animal's HP as damage-only attacks (Eagle HP 'attack' rolls the 4d6kh2 to find his HP since we don't like taking the averages when we can help it, though I do so at advantage but that's beside the point).

What I'd REALLY like to do may or may not even be possible with a macro with or without the help of an API, but I'd like to create a macro (I know how to create the drop-down options) and choose, say, "Polar Bear" from the drop down, the 'answer' to that query set the HP_Temp field to the 5d10 roll, and change the selected rollable-table token to the 4th option or something along those lines.

If it's of any help, here's my current API library (yes I know I have a lot compared to most other screenshots I've seen)


Is this even possible or would Roll20 not support such a thing?


Thanks in advance,

Agnati

November 05 (4 years ago)

Edited November 05 (4 years ago)
Oosh
Sheet Author
API Scripter

Both of those are possible - the HP formula is stored as an Attribute (this is for the R20 5e sheet) @{selected|npc_hpformula}. If you wrap it in an inline roll, you'll get a HP roll:

[[@{selected|npc_hpformula}]]

You will obviously need to use API to automatically apply the HP to a sheet or a token.


A rollable token has its possible images stored in an array under the 'sides' property of the object. You can then set the graphic with the 'currentSide' property. There's a code snippet I've seen to deal with these images, but you'd probably need to customise it a bit. You'll need to know the index of the images you need as well - it'll be a bit of setup, but it can be done. How are you handling the Druid's actions when Wildshaped? Are you changing which sheet the token is linked to each time? Or do they just manually grab the character sheet they need?


There's already this Wildshape script, does it not do what you want it to? It would be significantly easier than creating your own version, though I've never used it and I'm not 100% sure on the features it has.



November 05 (4 years ago)

Edited November 05 (4 years ago)
David M.
Pro
API Scripter

Here's a (truncated) example of a wildshape chat menu that uses token-mod to select the side, size, vision (using LDL), hp, and speed for a rollable table token. It references additional character sheets that you set up for the wildshape forms, e.g. named "Dire Wolf(wildshape)" in the below example. Changes the "represents" property of the token to the new form, so easy to use attacks, etc. Uses the 5e OGL sheet and npcaction template.

&{template:npcaction} {{name=@{selected|token_name} }} {{rname=Shapeshifter}} {{description=[Revert Humanoid](!token-mod --set currentside|1 width|70 height|70 represents|@{Druid|character_id} bar1_link|hp bar2_link|ac bar3_link|speed name|Druid showname|yes light_radius| light_dimradius| light_angle|360 --off light_otherplayers @{selected|token_id})
[Dire Wolf](!token-mod --set currentside|2 width|140 height|140 represents|@{Dire Wolf(wildshape)|character_id} bar1_link|hp bar2_link|npc_ac bar3_link|npc_speed name|'Druid Dire Wolf' showname|yes light_radius|60 light_dimradius| light_angle|360 --off light_otherplayers @{selected|token_id} !token-mod --set bar1_value|@{selected|bar1|max}) 
}}

Oosh's recommendation of the wildshape script is a good one, though. It takes a bit to set up and get used to (of course, so do all wildshape approaches, really), but it's pretty slick in use.

November 05 (4 years ago)

Holy crap, both of your solutions are pure magic. I hadn't seen the Wildshape API yet, but got it setup and working correctly with the 11 forms she's used so far. Still tinkering with it to try to get it to roll the HP, but with everything else it does, if I can't figure it out it's a small inconvenience comparatively!

Thank you guys for your replies!

-Agnati