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 .
×

Stepping up/down rollable table "dice" tokens

1644171401

Edited 1644172032
I just went pro so I could program my way around some of the clunkiness of trying to run a Cortex Prime game via Roll20.  I haven't worked with the api yet. I recently discovered rollable tables, which do a fantastic job of providing a means to add or remove dice tokens from a pool area on a map, then allow the player to multiselect and roll them--at first I thought I wouldn't need to program anything.  What doesn't work out of the box is stepping up or stepping down a die-type (like from d6 to either d4 or d8, for instance).  I was envisioning setting up assets and complications as visibly labeled dice to be pulled into a die pool, but some character abilities allow the dice to be stepped up/down for a particular roll. If I could swap out what rollable table the token represents, that would be ideal.  It doesn't seem like I can delete a token at all, so deleting it and then replacing it with a rollable table token from a different die table (but keeping the nameplate value) doesn't seem likely.  Can I actually swap out the underlying rollable table? Re: Cortex Prime: this RPG represents different abilities and gear/situational aspects relevant to a character via dice from 4-12 sided, the bigger the better.  A given check will have a minimum of three dice in it from traits found on a character sheet, but there will be more as stuff happens in a scene, like the character adding beneficial modifiers such as carefully aiming, or finding a gun (each is a die they add to their pool) or taking penalties from negative mods (dice the opposition gets to roll).  Assets and Complications stick around across rolls in a given scene, so stepping them up/down to either intensify them or get rid of them is very likely.
1644175531
The Aaron
Roll20 Production Team
API Scripter
Once a rollable table token is created, it isn't tied to a table anymore (note: rollable table tokens do not respect weights, every side has an equal chance), they have a list of potential sides and a current side. You can look at TokenMod for some examples of working with them. For what you're talking about doing, I'd just build the sides lists and set them with the API when you need to increase or decrease the sides.  Also, graphic objects (and most Roll20 objects) are deleted by calling .remove() on them. 
1644348942

Edited 1644348977
Not sure I follow.  Do I actually build rollable tables for each die type or just store the side lists in the code?  Can I create a "starter" token with multiple sides if I don't actually have a rollable table?  Ideally I'd change its attributes before the token even gets created. I must admit I like the idea of the code handling everything and making it changeable on the fly.  I'd probably just have a button for each die type (4,6,8,10,12) that either changes the type if a die token is currently selected or adds a die of that type if not. Any suggestions where to look for code examples that do some of this stuff?  Many thanks in advance!
1644363163
The Aaron
Roll20 Production Team
API Scripter
Yes, I'd not bother with creating Rollable Tables, or at least not primarily.  I'd create them from the API.  When you make a Graphic object, the property `sides` contains an encoded list of all the images for the multi-sided token.  If you make a Rollable Table Token, you can grab that property from it to see what it's like.  Basically, it's a pipe delimited string of URICompontent encoded image urls. If you look in TokenMod at the ImageOp class, around line 561 is where it deals with the sides listing.  Some things to be aware of: Setting the currentSide index does not change the image for a Graphic object.  You need to set currentSide to the index for the list of sides, and also set the imgsrc property to the image url. Images in that list need to be in a User Library for the API to set them. So, regardless of what your workflow is, I'd have the graphic objects get created by the API, then just set a new list of sides images, current side, etc from the API when you need to change the die size.