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

is there an API to handle the Roll Tables token output?

Is there a way to set the Roll Tables token output from unit size of 1x1 to unit size 3x3? Currently the tokens are placed on the screen as 1x1 when you click the token button on the roll table, I want them to show up as 3x3. The GM can fat finger the set dimensions, but players don't get the option to resize at all. Thanks Jim Discussion in Specific Use Questions section of the Community Forums
1412554643
The Aaron
Roll20 Production Team
API Scripter
You can setup an on('graphic:add',..) event, (with a timeout of about 100ms), then check if the created graphic is a token and has the attributes that indicate it is for a rollable token, then resize it from the api. I can help you with that when I'm not just on my phone. :)
Way cool daddy oh! I will post again in a few days, I am going to try to wrap my head around what you posted.
Why not make these journal entries instead of a rollable table? You can set the size of the token when it's pulled out onto the map.
1412565264

Edited 1414592737
The Aaron
Roll20 Production Team
API Scripter
@James - This will do what you want. Change scaleSize to the number of units you want it scaled to. (Defaulted to 3) It will also set it to not be a drawing, so it will snap to the grid like a token. GIST: <a href="https://gist.github.com/shdwjk/075beec63a1e0ff085c" rel="nofollow">https://gist.github.com/shdwjk/075beec63a1e0ff085c</a>...
1412619806

Edited 1412642693
Thanks Aaron and HoneyBadger I will give both a try. I enjoy and use scripts from both of you!
@Aaron it works beautifully! You are King Kong or Donkey Kong, which ever you prefer. My player should get a kick out of using this.
1412645706
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Could you parse it from the name? token1 (1x2) token2 (1x1) token3 (3x3) This way different size tokes could be used in the same table.
HoneyBadger , I have always DM and didn't know the players could do that. That will help out a lot too, the druid in the group loves to assume an aspect of the Primal Beast. I have set up all the fey and natural aspects for her and gave your control but was dumb founded when she could not drag them of the sidebar, up to this point I had to drag them to the table for her. Now I will tell her to open her character sheets and drag the token to the table. Thanks
I like that ideal @ Stephen S. , I want my players to be able to use this roll table to display their spells area of effect.
1412657126
The Aaron
Roll20 Production Team
API Scripter
Stephen S. said: Could you parse it from the name? token1 (1x2) token2 (1x1) token3 (3x3) This way different size tokes could be used in the same table. Yeah, that wouldn't be hard at all.
James D. said: HoneyBadger , I have always DM and didn't know the players could do that. That will help out a lot too, the druid in the group loves to assume an aspect of the Primal Beast. I have set up all the fey and natural aspects for her and gave your control but was dumb founded when she could not drag them of the sidebar, up to this point I had to drag them to the table for her. Now I will tell her to open her character sheets and drag the token to the table. Thanks Player's can't pull tokens onto the map. We've asked for that ability before, but it hasn't been implemented.
1412673756
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
HoneyBadger said: James D. said: HoneyBadger , I have always DM and didn't know the players could do that. That will help out a lot too, the druid in the group loves to assume an aspect of the Primal Beast. I have set up all the fey and natural aspects for her and gave your control but was dumb founded when she could not drag them of the sidebar, up to this point I had to drag them to the table for her. Now I will tell her to open her character sheets and drag the token to the table. Thanks Player's can't pull tokens onto the map. We've asked for that ability before, but it hasn't been implemented. I have the same sort of problem with the 5E spell tables. Was thinking of.... keeping the tables (they are handy user interface for API arrays) and outputing them to chat when requested by the players (so they can see a visual copy of the table on request).... and some basic commands to change things like weight and edit name... or call them to the map.
Stephen S. said: HoneyBadger said: James D. said: HoneyBadger , I have always DM and didn't know the players could do that. That will help out a lot too, the druid in the group loves to assume an aspect of the Primal Beast. I have set up all the fey and natural aspects for her and gave your control but was dumb founded when she could not drag them of the sidebar, up to this point I had to drag them to the table for her. Now I will tell her to open her character sheets and drag the token to the table. Thanks Player's can't pull tokens onto the map. We've asked for that ability before, but it hasn't been implemented. I have the same sort of problem with the 5E spell tables. Was thinking of.... keeping the tables (they are handy user interface for API arrays) and outputing them to chat when requested by the players (so they can see a visual copy of the table on request).... and some basic commands to change things like weight and edit name... or call them to the map. Stephen , I am logged into Roll20 as a player , I can click the Rollable Tables Token button and a token is placed on the table. At this point the script sets the token to 3x3, as a player I can right click the token and select the multi-sided, click the random or choose buttons. Now the player can edit the token's name, bars, Auras, and the indicator status. Characters can drag avatars from their character sheets to the table. Thanks for all the feedback. :-) Jim
1412693816

Edited 1412694069
Aaron said: Stephen S. said: Could you parse it from the name? token1 (1x2) token2 (1x1) token3 (3x3) This way different size tokes could be used in the same table. Yeah, that wouldn't be hard at all. I love this ideal. where can I get a list of the commands for building scripts of my own? Besides asking the scripting Gurus I have no ideal how to tell the script to ask for a users input.
Never mind I am looking it up on the wiki.
1412700285

Edited 1412742225
The Aaron
Roll20 Production Team
API Scripter
Scripts can't ask for user input. They can receive it via api commands of the form: !command arg1 arg2 arg3 arg4 But they can't prompt for it directly. (The above comes to the API as a string and then gets parsed by the script, usually with msg.content.split(/\s+/); or the like.) What can be done, is combining the techniques for macros with the api commands to give the semblance of prompting the user: !command ?{value of arg1?|default} @{target|token_id} @{selected|ac} [[1d20+@{bob|bonus}]] Note that all of the attribute and query bits are substituted before the API sees the command, so what the API sees is something like: !command value -Jz123ad135adfq45 18 [[$1]] Where 'value' was typed into the popup by the user '-Jz123ad135adfq45' is the id of the token the user selected '18' is the value portion of the 'ac' attribute on the selected token at the time the command was entered '[[$1]]' is the placeholder for the inline dice expression. Inline dice expressions are special. The msg object will have an additional property called 'inlinerolls' that contains entries for each inline roll, which are keyed off of that $-prefaced number in the double square brackets. There are some more eccentricities, but that should give you a good idea of what's possible. =D
Thanks @ The Aaron I need to wrap my head around this... Jim
1412742455
The Aaron
Roll20 Production Team
API Scripter
No worries, happy to help!
It may be better for ease of use and to help move the game play along at a faster pase to adjust the API to dump a larger Area of effect (AOE) token to the table. By having the largest (what would be the largest AOE needed?) AOE graphics in the roll table, they could be scaled down by using transparent edges. Question on for the API Gurus, can the token in this script be sent to the background via the API? Jim
I think I need to use this to send the newly made token to the background. _zorder "" Comma-delimited list of IDs specifying the ordering of objects on the page. toFront and toBack (and their associated context menu items) can re-order this list. Read-only.
Next question, is there a way to interact with the "token button" on a roll table via a macro? You can also roll a table directly in the chat input, or in a macro, by using the special roll command 1t[table-name] . For example, to roll your "crit-failure" table one time, you would enter /roll 1t[crit-failure] . You can change 1 to whatever number you would like.
1412783880
The Aaron
Roll20 Production Team
API Scripter
James the DM said: It may be better for ease of use and to help move the game play along at a faster pase to adjust the API to dump a larger Area of effect (AOE) token to the table. By having the largest (what would be the largest AOE needed?) AOE graphics in the roll table, they could be scaled down by using transparent edges. I think it might be just as easy, or at least more user friendly to take the suggestion @Stephen S to create them based on the size encoded in the title of the table row. Question on for the API Gurus, can the token in this script be sent to the background via the API? You need to use the toBack() function to move a token's zorder. Any of the properties of an object that are prefaced with an underscore (_) are read only properties. You can add the following line after line 17 in the above to bury the token below other tokens: toBack(obj); James the DM said: Next question, is there a way to interact with the "token button" on a roll table via a macro? You can also roll a table directly in the chat input, or in a macro, by using the special roll command 1t[table-name] . For example, to roll your "crit-failure" table one time, you would enter /roll 1t[crit-failure] . You can change 1 to whatever number you would like. Regarding interacting with a Token Button via a macro, are you talking about creating the token via macro? There isn't a way to do that, but I could write an API command that would emulate the behavior.
The Aaron said: Stephen S. said: Could you parse it from the name? token1 (1x2) token2 (1x1) token3 (3x3) This way different size tokes could be used in the same table. Yeah, that wouldn't be hard at all. Oh (light goes off over head) I see the "item Name" inside the Roll Table would set the size of the token. I like his ideal even more now that I understand it better.
The Aaron said: James the DM said: Next question, is there a way to interact with the "token button" on a roll table via a macro? You can also roll a table directly in the chat input, or in a macro, by using the special roll command 1t[table-name] . For example, to roll your "crit-failure" table one time, you would enter /roll 1t[crit-failure] . You can change 1 to whatever number you would like. Regarding interacting with a Token Button via a macro, are you talking about creating the token via macro? There isn't a way to do that, but I could write an API command that would emulate the behavior. @ The Aaron , I want my players to press a macro button for their power "Burning Hands" or what ever and have your TableTokenSizer API do it's thing. Currently TableTokenSizer API works only when the Roll Table token button is clicked. Sounds like I am asking for to much? Thanks Jim
1412806729
The Aaron
Roll20 Production Team
API Scripter
=D Not THAT much. So, something like this: !summon-effect burning hands
The Aaron said: =D Not THAT much. So, something like this: !summon-effect burning hands So, that gets written into your TableTokenSizer API, along with Stephen S. parse the effect from the name ideal "3x3 burning hands" or "2x2 burning hands" Token for that effect is pulled from a Roll Table and placed on Roll20's table?
1412822773
The Aaron
Roll20 Production Team
API Scripter
Yeah, probably.
Uhm now what? Rollable Table Property Default Value Notes _id A unique ID for this object. Globally unique across all objects in this campaign. Read-only. _type "rollabletable" Can be used to identify the object type or search for the object. Read-only. name "new-table" showplayers true Table Item Property Default Value Notes _id A unique ID for this object. Globally unique across all objects in this campaign. Read-only. _type "tableitem" Can be used to identify the object type or search for the object. Read-only. _rollabletableid "" ID of the table this item belongs to. Read-only. avatar "" URL to an image used for the table item. See the note about avatar and imgsrc restrictions below. name "" weight 1 Weight of the table item compared to the other items in the same table. Simply put, an item with weight 3 is three times more likely to be selected when rolling on the table than an item with weight 1.
1412831158
The Aaron
Roll20 Production Team
API Scripter
From my perspective, now I make good on a few other promised improvements, then start working in this one! :) I'll try to make some useful notes tomorrow... Sleepy...
Oh yeah no worries, I will get keep tying to do it myself, but I think some people just see the Matrix (The Aaron).
1412870231
The Aaron
Roll20 Production Team
API Scripter
All I see is blonde, brunette, red-head.... =D So, I see 2 ways to go about doing this: 1) Store the sizes in the table encoded as part of the name: Cone of Code [30x30] 2) Size specified by the command !summon-effect Burning Hands 15x15 3) (ok, I lied.. 3 ways at least...) Default to 1, but override with 2. Here is the basic order of operations as I see it: Parse the command for the effect name (and size argument if present) Look in the table (of known name, Spell Effects perhaps?) for an item with the same name (lower case both) Create a graphic token with: The table item's graphic as the token's graphic The table items's name as the token's name visibility by players for the name control by the player who created it on the object layer, forced to back (probably? Should be a config option...) Sized based on either the encoding in the name or the argument positioned at.... somewhere.... ? If we know the token that is performing the action, we can place it adjacent. If we know the target, we can place it there if we don't know either, we can find all tokens controlled by the calling player and place it adjacent to the first one. Worst case, we could add a token id/character id to the command (actually, we can do it automatically, like in my Use Power script. So, if I were writing this (or, WHEN I'm writing this... =D ), this is the command I would use: !summon-effect [Character ID] some free form name of an effect [size] I'd shamelessly steal the code I wrote in Use Power for adding and updating the Character ID to the command. On execution, I'd split the arguments on /\s+/ to get the words. I'd shift() the character ID off the front. I'd check the last argument against /\d+x\d+/ (or similar) and .pop() it if it matches and use it for sizing, I'd .join(' ') the remaining arguments to form the name and search for the table item. I think that about covers it...
1412885073
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
"Brand" the effects drawings some sort of way... GM note... or naming... that way they can be moved to the upper corner of the map for easy deletion.... Sometimes its hard to get rid of images when they are all on top of each other. !cleareffects sort of thing....
1412888856
The Aaron
Roll20 Production Team
API Scripter
Ah, great idea Stephen, and easily done. Could also "clear" them after the player's turn automatically.
The Aaron , I know this is putting the cart before the horse, but I had started building my "spell-effect" table storing the sizes in the table encoded as part of the name. Because of my limited scripting knowledge, I had only thought option 1 was possible. Option 3 sounds super sweet. If I understand option 3, the players would not have to interact with the Rollable Table at all, except having the command !summon-effect [Character ID] some free form name of an effect [size] in a macro? Will this work If the command is used in the macro of a monster controlled by the GM? Create a graphic token with: The table item's graphic as the token's graphic The table items's name as the token's name visibility by players for the name (visibility to all) control by the player who created it (Would the GM also be able to control it?) on the object layer, forced to back (probably? Should be a config option...) Sized based on either the encoding in the name or the argument (could it be based on name like "blast 3"(which is 3x3) or "burst 3"(which is 7x7)?) positioned at.... somewhere.... ? (Positioned on the Character ID, because D&D4e Burst Effect originate on the caster and blast normally have a range to them and the player will need to reposition the effect anyways.) Jim
The Aaron said: Ah, great idea Stephen, and easily done. Could also "clear" them after the player's turn automatically. needs another argument, some effects last to the end of the encounter.
1412909474
The Aaron
Roll20 Production Team
API Scripter
Yeah, it will totally work for the GM. Could just add a token macro that dispels the effect.