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

[GroupInit] Add directly?

Was wondering if you could add a function to GroupInit Adding the initiative of a character directly without selection.  To be used from a separate macro, calling group init to open, sort, and roll initiative on the turn tracker. Example: Opening via macro: /em begins to transform into ... something else. You feel its only a matter of time before the transformation will be completed. !group-init --byid -LU88C3EMpmChO4vLFYR
1545306913
The Aaron
Pro
API Scripter
I could add something like that. I think I have a snippet that does that separately from GroupInit. I know I have one that does it by character name (finds a token for that character on the current map page). I’ll have to take a look...
1545353936

Edited 1545353952
that would be cool if it had that function ... I have a macro that takes three rounds for a werewolf PC to transform, during which he is incapacitated and prone.  Adding that macro would be cool to monitor what people could do during his transformation time ... such as getting him grappled and restrained ... etc....  He isn't in control of his character in his hybrid form ...
Something similar to adding without a token: I would like to track when a monster has multiple turns in a round, but only one token. I’m not fussed if the token doesn’t get highlighted again, but it would be nice to have a button to push (macro call) that adds the name of the current token to the top of the init order without disturbing its other turn already in the order (I am thinking this would add the new entry without associating it with the token, unless you can actually have multiple entries per token). Does that make sense?  It would be useful for tracking legendary actions, for example.
1548521874
The Aaron
Roll20 Production Team
API Scripter
This is still on my todo list, but I need to wrap a few other things first.  Lets chat though this a bit more when you have a chance.  Here's what I think the ask is: Take a TOKEN ID or CHARACTER ID on the command line to add a turn for.   - If the character doesn't have a token on the map, there is a small problem.  Turns are tied to tokens, not characters, so I'd have to either add a custom turn (which has no token associated) or create a token for them.  I won't know where to put one, so I'd probably just put it in the top left corner.  I could create a token based on either their default token, or their avatar picture, but only if it's in a user library  as the API can't create tokens for other images.  I could probably add some semantics around replacing it with one that is drug in later. A way to add a second (third, forth) turn for a token easily.  This is already supported (depending on the configuration) by selecting them and rolling another turn, but adding a way to do this regardless of configuration is a good idea.
Regarding the second point, I didn’t realize it was already possible to have multiple turns per token. I suppose before I had “replace existing number” turned on, and I thought turning it off would result in nothing happening (most PCs, if they roll twice by accident you want to ignore the second roll). If that instead adds a second turn, that’s exactly what I need already. I’ll have to try it out. Thanks!
1548529695
The Aaron
Roll20 Production Team
API Scripter
Yup, but I bet we can make that better. 
The Aaron said: Yup, but I bet we can make that better.  Well, apparently one of us is misunderstanding (probably me), as selecting a token that is already in the turn order and typing "!group-init" again does nothing when the "replace roll" option is turned off.  This is basically how I previously expected it to work, but it means I don't know how there is any support with this script currently to add a second turn for the same token. Thanks as always for your willingness to take feedback and tweak your scripts for our convenience!  :-)
The Aaron said: This is still on my todo list, but I need to wrap a few other things first.  Lets chat though this a bit more when you have a chance.  Here's what I think the ask is: Take a TOKEN ID or CHARACTER ID on the command line to add a turn for.   - If the character doesn't have a token on the map, there is a small problem.  Turns are tied to tokens, not characters, so I'd have to either add a custom turn (which has no token associated) or create a token for them.  I won't know where to put one, so I'd probably just put it in the top left corner.  I could create a token based on either their default token, or their avatar picture, but only if it's in a user library  as the API can't create tokens for other images.  I could probably add some semantics around replacing it with one that is drug in later. A way to add a second (third, forth) turn for a token easily.  This is already supported (depending on the configuration) by selecting them and rolling another turn, but adding a way to do this regardless of configuration is a good idea. Would we be able to add a generic token picture, the way it looks when the character sheet has no association to a picture in it?  That would add 'a picture' without adding 'the picture'.  The idea is for the reveal to wait until the last moment.  This would also go for things like traps that are supposed to go off at a certain time, etc.  The character id, something called by @{selected|character_id} would be useful if it refers to an actual character.  But there should also be something for non-characters, such as traps, grenades, lit fuse bombs, etc.  In that case, I want it to function on its initiative, but not necessarily by a part of a sheet.  This being a standard d20 roll.  The important part of this being that the initiative tracker will actually stop and sit on that turn order, rather than skip as it does with non-character turns, until the turn order advances to the next in line.
1548546164
The Aaron
Roll20 Production Team
API Scripter
Actually, Joe, sounds like I’m confused! Wolf, have you seen my AddCustomTurn scripts?
The Aaron said: Actually, Joe, sounds like I’m confused! Is that because it does add a second turn to the turn order for the selected token when you have the “replace” option turned off and use the command “!group-init”?
1548600339
The Aaron
Roll20 Production Team
API Scripter
No, it's because replace roll only controls if the existing roll will be replaced.  If replace roll is on, it will roll a new number and update the existing entry.  If replace roll if off, it will preserve the existing entry and not roll for that token. I was thinking in the second case that it would just roll a new one in, but I'm remembering when it did that unintentionally and was considered a bug, so I removed that behavior. =D  Probably instead of an on/off option, that needs to be a Preserve/Replace/Duplicate option, or some such.  I'll think on it. 
Thanks, I appreciate that! &nbsp;In the meantime, would it be easier to just use the existing turn tracker macro options to throw another custom item on there not associated with a token? &nbsp;I’m not in front of a computer right now to try it, but I was thinking something like “ 10 &amp;{tracker|MoltenDragon2} ” might work, reading over the wiki:&nbsp; <a href="https://wiki.roll20.net/Turn_Tracker" rel="nofollow">https://wiki.roll20.net/Turn_Tracker</a>
1548601152

Edited 1548608547
The Aaron
Roll20 Production Team
API Scripter
It would be nice if that syntax would work. I was pushing for something like that a few years ago when they added the &amp;{tracker:-} and &amp;{tracker:+} stuff, but no love. =D I definitely have scripts that add additional turns for things: on('ready', () =&gt; { const multiplyTurn = (token_id,count) =&gt; { let to = JSON.parse(Campaign().get('turnorder')||'[]'); let turn = {pr:-10000}; to = to.filter((o) =&gt; { if(o.id !== token_id){ return true; } if( o.id === token_id ) { if(o.pr&gt;turn.pr) { turn = o; } } return false; }); if(turn.id){ [...Array(parseInt(count)).keys()].forEach((n)=&gt;{ to.push(Object.assign({},turn,{pr:(parseInt(turn.pr)-(20*n))})); }); } Campaign().set({ turnorder: JSON.stringify(to.sort((a,b)=&gt;parseFloat(b.pr)-parseFloat(a.pr))) }); }; on('chat:message', (msg) =&gt; { if( 'api'===msg.type &amp;&amp; /^!dup-turn/.test(msg.content) ){ let args = msg.content.split(/\s+/); let count = args[1]||2; msg.selected.forEach((m)=&gt;multiplyTurn(m._id,count)); } }); }); That one puts in a number of turns at increments of 20 lower for the selected tokens.&nbsp; For example, if you had: Bob: 113 Sally: 87 Timmy: 56 and ran: !dup-turn 3 With Bob and Sally selected, you'd get: Bob: 113 Bob: 93 Sally: 87 Bob: 73 Sally: 67 Timmy: 56 Sally: 47 And here's basically the same script, modified to add 10 to turns: on('ready', () =&gt; { const multiplyTurn = (token_id,count) =&gt; { let to = JSON.parse(Campaign().get('turnorder')||'[]'); let turn = {pr:-10000}; to = to.filter((o) =&gt; { if(o.id !== token_id){ return true; } if( o.id === token_id ) { if(o.pr&gt;turn.pr) { turn = o; } } return false; }); if(turn.id){ [...Array(parseInt(count)).keys()].forEach((n)=&gt;{ to.push(Object.assign({},turn,{pr:(parseInt(turn.pr)+(10*n))})); }); } Campaign().set({ turnorder: JSON.stringify(to.sort((a,b)=&gt;parseFloat(b.pr)-parseFloat(a.pr))) }); }; on('chat:message', (msg) =&gt; { if( 'api'===msg.type &amp;&amp; /^!dup-turn/.test(msg.content) ){ let args = msg.content.split(/\s+/); let count = args[1]||2; if(Array.isArray(msg.selected)){ msg.selected.forEach((m)=&gt;multiplyTurn(m._id,count)); } } }); });
Thanks! &nbsp;That’s exactly what I needed. :-)
Original idea: So I think what I was looking for most (this is drawing back on an old idea I had) was being able to call a initiative roll directly from a macro, not using selected or targeted as it's reference, but being able to use the character ID or Token ID directly, so that it's part of the macro call itself, independent of a selected token.&nbsp; If that makes sense.&nbsp; In other words, having the token selected or not, it rolls initiative for whatever token ID is passed into group init. Why: This would make a great macro for a single character that is going to be talking to someone one second, and go psycho by raging and hitting someone they are talking to the next. Or a group of monsters, already having a ambush ready to be sprung based on a certain sequence (per the Macro) and WHAM - initiative is rolled and the PCs realize they are in some serious crap. But by doing this in prep, already have the sequence ready to be rolled from a macro, instead of selecting the tokens individually or in groups.&nbsp; It also helps when the PCs are surrounded by hidden monsters that spring up and then roll their initiative.&nbsp; This way, you're not catching the PC in the middle and rolling their initiative for them too&nbsp;&nbsp;(you could preroll on the GM layer - but that combat tracker coming up suddenly rather than after the fact really adds the 'oomph' in their situation). Unrelated to topic, secondary thought: To add onto that last statement, another unique function that could be added is that GMs could have to roll twice (as a toggled option, non-default for those who are used to the current setup) to add creatures that are controlled by players if their are non-GM controlled creatures in the group.&nbsp; i.e.: Selecting a group with player controlled characters, as a GM,&nbsp; ignores their tokens a first time. But if the group is selected again (or is the same selection), it ignores the gm controlled characters (that already now have initiative rolls) the second roll and adds the player characters in that time (in case the player wants the gm to roll their initiative).&nbsp; If all characters/ creatures have an initiative roll in the currently selected group, then all are replaced with the new rolls.
The Aaron said: Actually, Joe, sounds like I’m confused! Wolf, have you seen my AddCustomTurn scripts? I will check that out, I was just hoping to have something incorporate into group-init, since I use that exclusively to roll both monster and PC initiative.&nbsp; See what it has to offer.&nbsp;
Wolf Thunderspirit said: The Aaron said: Actually, Joe, sounds like I’m confused! Wolf, have you seen my AddCustomTurn scripts? I will check that out, I was just hoping to have something incorporate into group-init, since I use that exclusively to roll both monster and PC initiative.&nbsp; See what it has to offer.&nbsp; Couldn't find it at&nbsp; <a href="https://github.com/shdwjk/Roll20API" rel="nofollow">https://github.com/shdwjk/Roll20API</a> &nbsp;- I'm thinking you haven't put all in there ...
1548886957

Edited 1548886976
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
---&gt;&nbsp; &nbsp; Voila .
keithcurtis said: ---&gt;&nbsp; &nbsp; Voila . Yes,&nbsp; This.&nbsp; Yes.&nbsp; I have need of this for so many reasons ... yes .... yes .... tyvm Keith Aaron, all of your snippets need a home too :-)&nbsp; You have so many different APIs, whether snippet or full-blown, that need an entire site to rest in .&nbsp; Hard to keep track of em all!
1548891125
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Vince maintains&nbsp; The Aaron's Roll20 Enhancement pack &nbsp;thread, which contains many snippets and bookmarklets. The link is also found with other helpful threads at the end of the index in the Stupid Tricks thread.
1548892329
The Aaron
Roll20 Production Team
API Scripter
Yeah, that’s a good point...
1548917898
vÍnce
Pro
Sheet Author
keithcurtis said: Vince maintains&nbsp; The Aaron's Roll20 Enhancement pack &nbsp;thread, which contains many snippets and bookmarklets. The link is also found with other helpful threads at the end of the index in the Stupid Tricks thread. I'm an official member of the&nbsp; Aaron Fan Club . ;-P
Vince said: keithcurtis said: Vince maintains&nbsp; The Aaron's Roll20 Enhancement pack &nbsp;thread, which contains many snippets and bookmarklets. The link is also found with other helpful threads at the end of the index in the Stupid Tricks thread. I'm an official member of the&nbsp; Aaron Fan Club . ;-P I'm with ya.&nbsp; The AddCustomTurn snippet: 1) using countdown, had a problem with getting decrements to work.&nbsp; 2) Sometimes increments as well, sometimes had to do so with adding a duplicate, only one of them would work 3) Both when using !eot from TurnMarker Would it be possible to get the description to change, but the increment/ initiative order to stay the same? 1) Add a turn that is declared by the command to be ...say ... 18. 2) Name it "Bomb Counter: 3 rounds" &nbsp;&nbsp; a) Declare a new variable named BmB with 3 as it's value &nbsp;&nbsp; b) In the naming, declare the variable and it's decrement or increment &nbsp;&nbsp; c) Set to do something at count "0", outputted to chat 3) Next time it gets a turn, it renames itself "Bomb Counter: 2 rounds" 4) etc. Ridiculously convoluted example, perhaps Initial command: !act 0 18 --BmB|3 --"Bomb Counter " [[BmB-1]] " rounds" --EndOn|0 --ChatOutPut|"The grenade goes off!" [[2d8]] "Damage!" Starting Initiative Display: 18 Bomb Counter: 3 rounds Counter reached 0, this hits chat output: Dungeon Master: The grenade goes off! 9 Damage!
1548938667
The Aaron
Roll20 Production Team
API Scripter
It’s definitely possible, it would just have to be written. =D Part of the problem with AddCustomTurn is that it is a second class citizen of the turn order. The major scripts don’t realize it exists and it tries to cabbage on to their commands and work with them, but can’t fully. What really needs to happen is for GroupInitiative and TurnMarker to both understand the place and intent of those pseudo-turns, and to treat them correctly. To do that requires some changes to both scripts as well as a formal definition of the relationship those pseudo-turns have to other turns (“who’s line is it anyway”) and their behavior when their turn comes up (“on 3 or 3 and then go?”). &nbsp;And of course, in a way that other scripts that are out there won’t get confused or break them.
The Aaron said: It’s definitely possible, it would just have to be written. =D Part of the problem with AddCustomTurn is that it is a second class citizen of the turn order. The major scripts don’t realize it exists and it tries to cabbage on to their commands and work with them, but can’t fully. What really needs to happen is for GroupInitiative and TurnMarker to both understand the place and intent of those pseudo-turns, and to treat them correctly. To do that requires some changes to both scripts as well as a formal definition of the relationship those pseudo-turns have to other turns (“who’s line is it anyway”) and their behavior when their turn comes up (“on 3 or 3 and then go?”). &nbsp;And of course, in a way that other scripts that are out there won’t get confused or break them. Tall orders.&nbsp; Don't I always ask the impossible ?&nbsp; lol
1549026320
The Aaron
Roll20 Production Team
API Scripter
Nothing fun about mundane and simple, I suppose. =D
1549061766

Edited 1549062327
Being a psuedo script/ snippet, could you build it's function into Groupinit (as a go to in adding turns to combat) and make Turnmarker recognize it?&nbsp; It's good as a snippet, but may actually grow to add complete functionality within the context of your other Initiative-based scripts like groupinit and turnmarker.&nbsp; Building it out to make an API - like you said - means you'd have to incorporate it to every script out there that handles anything initiative to avoid stepping on toes and breaking their scripts, which may not be good. Suggestion Examples: Group Init : toggle "AddCustomTurn" (default: Off) !group-init --ACT Set|On In settings: Toggle Custom Turns Command (default: Off): On command to add a custom turn: !group-init --ACT Add|-1 10 Bless Timer !group-init --ACT Add|0 10 Bob's Bless Timer: %%-1 10 -1 (token-mod --ids -LXWR_IRQLLJpOewxayS --set statusmarkers|-blue)%% In the example above, the turns would look like this, respectively: "10 Bless Timer", until it counted down to " -99 Bless Timer", having no real end point.&nbsp; This would continue decrementing it's initiative order. "10 Bob's Bless Timer: 10 ", until it counted down to " 10 Bob's Bless Timer: -1 ", at which point it (In the example given) it would delete itself from the turn order and run the command through token-mod, using the chat window, to turn "Bob's" blue dot status marker off via token id (just what we use in our campaign to indicate concentration on a token). Everything between the double percentage signs (%%) is a command to be tracked for the lifetime of the ACT.&nbsp; It follows as such: %%[increment/decrement amount] [starting value] [end value which deletes this ACT in combat tracker / Optional: fire final command] [Optional: readied fire command for chat window]%% Optional Firing off a final command before self destruct: If parenthesis surround, then automatically add "!" before everything that comes afterward, as above, when sent to chat window.&nbsp; If square brackets, then roll the indicated dice (Ex: [[ (2d20+6)[fire damage] ]] ).&nbsp; Good for bombs If double quotes just send to chat output as is (Ex: " /em You are all whisked away to another plane.&nbsp; The air is acrid, and choking heat fills your lungs! " ). If double hash marks (##), then consider it the same as %{ name_or_id|ability } , running the indicated ability.&nbsp; (Example: ## Bob|RadCons ## ) would execute his Aasimar Radiant Consumption burst ability. TurnMarker: toggle "recognize GI-ACT turns" (default: Off), toggle "stop at GI-ACT turns" (default: Off) !tm --ACT Set|On --ACT-Stop Set|On In Settings: Recognize GI-ACT turns (default: Off): On&nbsp; Stop at GI-ACT turns" (default: Off): On Recognizing the turn only decrements or increments the counter, but skips ahead to the next turn (Useful for spell countdowns that do no damage but remind when that one minute timer is up) Stopping allows you to do whatever needs to be done and then use !eot to advance to the next turn (useful for lair actions, etc., that need the extra time to address them.)
Back to my Original start of this post, I can use a method to call from a macro as a work around to selected.&nbsp; But this does not open the combat tracker on add as group init does. Works, But token must be selected: /em Volodar's Initiative: [[1d20&nbsp; @{selected|initiative} &amp;{tracker}]] This below functions in a macro, but uses the name to call it.&nbsp; Maybe that's a way to add functionality to groupinit?&nbsp; By calling it from name and not id? /em Volodar's Initiative: [[ 1d20 @{Volodar Ichor|initiative} &amp;{tracker}]]&nbsp; I couldn't get the workaround to work with character_id or token_id, which may have just needed me to pass the correct syntax.&nbsp; @{-LXWR_IRQLLJpOewxayS|initiative} and @{-LU88C3EMpmChO4vLFYR|initiative}, Token and Character ID's, respectively, failed to be found by Roll20 and threw errors. But this worked, so should be something group-init is capable of replicating for the purposes of surprising actual players at the table when suddenly the dice are rolling and - using tokenmod in the same macro - the enemy tokens are coming out of nowhere!&nbsp; Makes me wish that I had a delay call API that would delay the next stepped call, so that I could make them roll and appear every other second... Muhahahaha! Oooops ... sorry .... got a little carried away there ... Damn you, Strahd!!!! Still ... he has a good idea .... It would look something like this when used ... Strahd's Master Macro: /em The ground lifts and tears as skeletal hands rise from the earth, south of your position ... !group-init --name|Skeleton.1 !token-mod --set layer|objects --ids @{Skeleton.1|character_id} !delayNext --minutes|00 --seconds|01 --milliseconds|00 --rounds|00 /em Suddenly, another set of skeletal hands rises from the north ... !group-init --name|Skeleton.2 !token-mod --set layer|objects --ids @{Skeleton.2|character_id} !delayNext --minutes|00 --seconds|02 --milliseconds|00 --rounds|00 /em From both sides of you, zombies burst from their coffins and attack! ... !group-init --name|Zombie.1 !token-mod --set layer|objects --ids @{Zombie.1|character_id} !group-init --name|Zombie.2 !token-mod --set layer|objects --ids @{Zombie.2|character_id} !delayNext --minutes|00 --seconds|00 --milliseconds|00 --rounds|01 /em From Off to the edge of the graveyard, you see the vampire ruler himself with a stern look on his face, as he gestures for the first of two swarms of bats to descend on you ... !group-init --name|Strand von Zarovich !token-mod --set layer|objects --ids @{Strand von Zarovich|character_id} !group-init --name|Swarm of Bats.1 !token-mod --set layer|objects --ids @{Swarm of Bats.1|character_id} !group-init --name|Swarm of Bats.2 !token-mod --set layer|objects --ids @{Swarm of Bats.2|character_id}