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 Update 7/20: Inline Roll Support, Selected Token Information

There's a new version of the API that was just pushed out. The highlights: Inline Rolls and Floor/Ceil Support This update brings the sendChat() function inside of the API up to par with the new dice rolling features that are currently in-game. So you can now do an inline roll or use floor/ceil inside your sendChat rolls, for example: sendChat("Test", "/roll floor([[1d20]]/2)"); In addition, there is a new property in the "op" object of the "chat:message" event, called "inlineroll." I don't have it fully documented yet, but if you log it like so: on("chat:message", function(op) { log(op); }); And then do a [[1d20]] in-game you should get the gist of it.  Selected Token Information I'm pleased to report that we're also able to start giving you some additional insight into what's going on with user's interactions on-screen for use in your API scripts. Now for API commands (so commands beginning with "!" in the chat), there is an additional "selected" property on the "op" object of the "chat:message" event. It's a simple array of objects, each of which contains two properties, the "_id" and "_type" of the selected token/path/text on the screen. So for example if I had a token selected and did "!hide", the API would see (in the "chat:message" event handler): op = { ...     selected: [         {             _type: "graphic",             _id: "-Iva56adfadf"         }     ] } I could then use that information to get the object that was selected when the command was entered. NOTE: Currently selected token information is only sent for Campaigns on the DEV SERVER. It will be pushed to Main in the next update in about two weeks. Let me know if you have any questions, thanks!
I'm so happy right now, Riley. If I could express my happiness in words, I would, but I can't, so I can just say... thank you. My Shadowrun scripts are much cleaner now, for this reason.
The selected return will open up a whole new layer of scripting possibilities.  My question is on the scope of the selected array.  Will it be scoped to just the elements the user who issued the !command, or will it also include any elements selected by other players?  My hope would be that it was scoped to the user issuing the command, but an additional array of any element selected by any player may also be useful.
Yes, it's scoped to the user who issued the command. 
Squeal!
Is there an intention to allow users to select a token in which they cannot control? i.e. select but be unable to move & unable to edit? I'm not sure how difficult that'd be to achieve, but it'd be extremely useful to scripts for targeting specific tokens.
Emile l. said: Is there an intention to allow users to select a token in which they cannot control? i.e. select but be unable to move & unable to edit? I'm not sure how difficult that'd be to achieve, but it'd be extremely useful to scripts for targeting specific tokens. I can see how that would be needed. I'll have to think about the best way to make that happen.
Wow can't believe I didn't see this post before, I'd been waiting for the selected token stuff. Riley D. said: Emile l. said: Is there an intention to allow users to select a token in which they cannot control? i.e. select but be unable to move & unable to edit? I'm not sure how difficult that'd be to achieve, but it'd be extremely useful to scripts for targeting specific tokens. I can see how that would be needed. I'll have to think about the best way to make that happen. Maybe have them press a button, like Alt or Ctrt or something. Or maybe have some sort of "secondary selection" so they can target their own token (to use the right properties via the selected array) and then have a "target selection" for the enemy they're attacking or something, and pull the Armor Class etc from there
Possibly just make it so that if a player moves it who doesn't have control of the token, have it take Δ top and Δ left, and just add it to it's new position. Would make it extremely easy to add to existing code without having to create a more complicated system. Another (and if this is a feature for the sake of features, I deserve the online beating I'll receive), but just use a checkbox on the token screen to determine if it's clickable by players who aren't in control. That should pretty much cover the coding in the easiest possible way, except if there's a script involving change:graphic, in which case, you'd have to assure the original and new locations are different.
1375850453

Edited 1375850542
I use attack macros to achieve similar results  - my autosheet generator makes the character sheets, and puts in the macros.  macro looks like this currently !Attack Cano offhand ?{attack bonus|+0} ?{damage bonus|+0}  so it executes the attack using the offhand stats from Canos character sheet and then adds whatever situational mods the attack needs before the attack script prints out its results - automatically applying damage to the target. working on making that a whisper to the GM so that he gets a printout of the characters attack roll, the modifiers involved, and use a second macro that applies the damage or not (!Attack hits ?{apply damage? Y/N?|n} that bit needs work though. very alpha.  there are currently four attack types, all on the character sheet - main, offhand, thrown, and ranged. not always needed, but easier to manage from a modifier point of view - can set each macro up (I have 'normal' macros set up as well) for each attack type would like to have it work with spells too - planning on integrating that script with Joshs(?) status tracker so it can apply the relevant marker and if his script is present add the effect to his tracker.  haven't  done any work there, but have had success in working with other scripts before. most notably the initiative tracker (again from josh) working in conjuction with movementTracker from alex(?) none of this is published yet, (some isn't written) as I work full time with three kids so code at night. not much time to really concentrate on it - even now i'm cooking dinner for the 7 people in my house. 
If I didn't link my monster tokens to journal entries, giving all players control over monster tokens would actually be pretty useful since they could then move the tokens around when there's forced movement. So sadly I'm gonna have to rely on unique names/ids for each token.
1375864214
Alex L.
Pro
Sheet Author
HoneyBadger said: If I didn't link my monster tokens to journal entries, giving all players control over monster tokens would actually be pretty useful since they could then move the tokens around when there's forced movement. So sadly I'm gonna have to rely on unique names/ids for each token. Well the sugestion was to be able to select something you cant control.
Thing is, if you're gonna allow players to select tokens they can't control... it seems to me you should just go all out and give the GM the ability to allow players to set/remove markers on tokens they can't control. That would eliminate the need for of one of my scripts.
1375870590

Edited 1375870600
Alex L.
Pro
Sheet Author
HoneyBadger said: Thing is, if you're gonna allow players to select tokens they can't control... it seems to me you should just go all out and give the GM the ability to allow players to set/remove markers on tokens they can't control. That would eliminate the need for of one of my scripts. The functionality of being able to select things you cant control is very general and is almost necessary to have a good form of targeting, changing tokens is not.
It's not necessary, but it makes more sense. Rather than have the player click the token, then click inside the chat box, and type in the API command... they can just click on the token and select the icon they want.
That kind of goes back to my fear of "features for the sake of features". Correct me if I'm wrong, but roll20 is designed as an extrememly generic/universal playing element, and the API is designed to allow us as players to mold that board to do different things based on our game system. Selecting generic tokens that can't be controlled is the simplest way I could think of to give more access through API, without sacrificing a ton of screen space, and throwing in bundles of unnecessary script. If it's more an issue of being able to click 3 times to change status token on an icon, wouldn't it  be easier to make a basic script to change the icon to whatever and just have a macro button on the bottom of your screen to be able to add the status? It'd reduce it to 2 clicks, and would take a player a few seconds to build a macro...
figured I'd give this post a little bump and see if Riley has any input as to whether selection of non-playable tokens is in the roadmap? More out of curiousities sake than anything.