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

[Script Update] GroupInitiative - Now with the Initiative Stack System! Store turn orders for later use!

1485329048

Edited 1515689453
The Aaron
Pro
API Scripter
GroupInitiative Update v0.9.28 &nbsp;-- Added --toggle-turnorder command which just opens and closes the turnorder. (Thanks&nbsp; Cutter ) Update v0.9.27 &nbsp;-- Added logic to attempt to fix&nbsp; inline rolls that will crash the API . (Thanks&nbsp; Dougansf ) Update v0.9.26 &nbsp;-- Fixed bug where 0 was sorted strangely. (Thanks&nbsp; Maetco ) Update v0.9.25 &nbsp;-- Fixed bug causing ' (stat || "").replace is not a function ' error. (Thanks eastwood ) Update v0.9.24 &nbsp;-- Adjusted bonus calculation to deal with @{selected} and &{tracker} references (Thanks&nbsp; Thorsten B. ) Update v0.9.23 -- Add current and previous objects to the Notification. (Thanks&nbsp; Lucian ) Update v0.9.22 &nbsp;-- Added better handling for empty stats, hoping to fix empty character sheet attributes at creation time. &nbsp;(Thanks&nbsp; Nibrodooh ) Update v0.9.21 -- Case Sensitivity, sorting improvements and the Initiative Stack System. For full commands, see then&nbsp; previous threads or the in-game help. New & Updated Commands --add-group --&lt; adjustment&gt; ... -- All adjustments are now case-insensitive. You can use --bare, --Bare -- BaRe, etc. &nbsp;Added an adjustment type of --negative which applies the inverse of the value of an attribute. --sort -- Applies the configured sort method to the current list. --clear -- Removes all entries from the turn order. --adjust-current &lt;value&gt; [minimum] -- Adjusts the current turn by somevalue, with an optional minimum value. --stack [stack command] -- This is a big addition to GroupInitiative. &nbsp;The stack commands let you store the state of the initiative and restore it at a later point. &nbsp;Here's a list of the possible stack commands: list -- List all of the stored turn orders. This is the default command if you don't supply one. clear -- Clear all the stored turn orders. copy &nbsp; [label] -- Copy the current turn order to the stack. &nbsp;Anything after the command will be used for naming it in the stack. &nbsp;You can also use the dup instead of copy . push [label] -- Puts a copy of the current turn order on the stack and clears the turn order. &nbsp; Anything after the command will be used for naming it in the stack. pop -- Replaces the current turn order with the last entry in the stack, removing it from the stack. apply -- Replaces the current turn order with the last entry in the stack, but leaving a copy in the stack. swap &nbsp; [label] -- Swaps the current turn order with the last entry in the stack.&nbsp; Anything after the command will be used for naming it in the stack. tail-swap [label] -- Swaps the current turn order with the first entry in the stack. &nbsp; Anything after the command will be used for naming it in the stack. &nbsp;You can also use tswap instead of tail-swap . merge -- Removes the last entry in the stack and adds it to the current turn order, then sorts the new turn order with the configured sort method. apply-merge -- Just like merge, but leaves the stack unchanged. rotate [label] -- Pushes the current turn order onto the end of the stack, then removes the first entry in the stack and replaces the turn order with it. &nbsp; Anything after the command will be used for naming it in the stack. &nbsp;You can also use rot instead of rotate . reverse-rotate [label] -- Just like rotate, but puts the current turn order on the front of the stack and pulls off the end of the stack. &nbsp; Anything after the command will be used for naming it in the stack. &nbsp;You can also use rrot instead of reverse-rotate . Examples The stack stuff is very powerful, but not as polished as I would like (I actually released it tonight by accident, but there ya go!). Save a copy of the Turn Order: !group-init --stack dup Backup Turn Order at round 5 List the saved turn orders: !group-init --stack Restore the saved copy: !group-init --stack pop Saving again, but this time clearing the turn order by pushing: !group-init --stack push Saving again Now with sort descending set (was sort ascending when I pushed), I'll use apply-merge to build a new turn order with what's stored, but leaving the copy on the stack: !group-init --stack apply-merge Now, swapping the current turn order for the saved one: !group-init --stack swap (I didn't name that one, so it got a generic title of {8 records} ) Will store custom turns and their auto change parameters as well (I named this one "A custom Turn"). Well, that's about all the examples I've got in me. &nbsp;Try it out a bit and let me know what you come up with! Github:&nbsp; <a href="https://github.com/shdwjk/Roll20API/blob/master/Gr" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/master/Gr</a>... Previous Forum Post:&nbsp; <a href="https://app.roll20.net/forum/permalink/3975602/" rel="nofollow">https://app.roll20.net/forum/permalink/3975602/</a> Support my work on If you use my scripts, want to contribute, and have the spare bucks to do so , go right ahead. However, please don't feel like you must contribute just to use them! I'd much rather have happy Roll20 users armed with my scripts than people not using them out of some sense of shame. Use them and be happy, completely guilt-free! Disclaimer: This Patreon campaign is not affiliated with Roll20; as such, contributions are voluntary and Roll20 cannot provide support or refunds for contributions.
1485334810
vÍnce
Pro
Sheet Author
Interesting addition Aaron. &nbsp;So was "stack" added so you could pre-roll initiatives for upcoming encounters and then recall them when needed?
1485352187

Edited 1485352206
The Aaron
Pro
API Scripter
Possibly, though I need to add a few fetures to make that completely satisfactory. Being able to pause one combat, then come back to it later was the initial thought. It grew from there.&nbsp;
1485378317
vÍnce
Pro
Sheet Author
Pre-rolling initiative is something I've of heard suggested as a way to speed up combat as well as not give away an imminent threat with "Roll for initiative." &nbsp;I've never actually tried this and I'm not sure how situational modifiers might affect a pre-rolled init. &nbsp;Thanks for the updates Aaron. &nbsp;Great stuff as always.
1485379988
The Aaron
Pro
API Scripter
Yeah, I'd say try and use it for that, or test with that intent and let me know what it's lacking. &nbsp;I've already got a short list of things (I wanted to put in before releasing it.. silly deploy script!), but I'm very open to suggestions. &nbsp;It's kind of an alpha feature at this point, and I think different names might make using the stack stuff easier or at least more intuitive.
So for a Pathfinder game I'm setting up I decided to see what APIs there could be. I looked and got myself swamped, with a summer flu I'm hitting a stone wall trying to remember the names of the API/s that did the next thing Im looking for. This Script doesn't allow for Active Token Highlighting &nbsp;but was wondering if others knew of one that would work with this API. I also am looking for a end of turn &nbsp;that players can use to advance the Turn Order, as well as a round counter . I know there was one, but from I recall it wasn't being updated [or at least the thread I found was locked] and I can't recall its name. Got to say thou, I love this Script. Once I understood how to make a group, why I would make a group and stopped trying to make rolls for everything, I found this to be useful for a Pathfinder system. !group-init --add-group --Bare init --Tie-Breaker init
1485521159
The Aaron
Pro
API Scripter
Thanks! &nbsp; TurnMarker1 will highlight the active token, as well as provide an end of turn command: !eot It also interoperates with GroupInitiative so that changes GroupInitiative makes are properly highlighted. &nbsp;
1486748428
Nibrodooh
Pro
Sheet Author
I have found a bug, it's a bit of an edge case, but it causes an API lock. If you use !group-init on a group that contains a character that represents a character, but that character sheet is not initialized(default values have not been set) it throws the following error: SyntaxError: Expected [0-9] but ")" found. undefined I am on the following version v0.9.21 &lt;= [Wed Jan 25 2017 06:41:53 GMT+0000 (UTC)]
1486748872
The Aaron
Pro
API Scripter
Yeah, I actually walked through that with another user yesterday, so it's on my list to fix. &nbsp;It's weird it's showing up now as I haven't changed that part of the code in a year. &nbsp;I'll see about getting an update to that pushed up.
1486749710
The Aaron
Pro
API Scripter
So, I can't duplicate this issue. &nbsp;Can you do me a favor and try this version to see if it fixes the crash for you? <a href="https://gist.github.com/shdwjk/9df7774c298d1a7405b" rel="nofollow">https://gist.github.com/shdwjk/9df7774c298d1a7405b</a>...
1486749951
Nibrodooh
Pro
Sheet Author
That fixes it.
1486749980
The Aaron
Pro
API Scripter
I went ahead and pushed that up, hopefully it will fix it. &nbsp;It will fix when attributes are defined and are empty. &nbsp;I'm not certain it will fix it for autocalc fields that end up empty.
1486750070
The Aaron
Pro
API Scripter
Great! thanks!
1486750092
Nibrodooh
Pro
Sheet Author
My brief testing shows that it fixes it in both cases, but i'll let you know if i manage to break it again haha.
1486750114
The Aaron
Pro
API Scripter
Update v0.9.22 -- Added better handling for empty stats, hoping to fix empty character sheet attributes at creation time. (Thanks Nibrodooh )
1486752500
Nibrodooh
Pro
Sheet Author
I spoke too soon on it fixing things. It appears that it fixed the issue but bonuses ceased to function all together.&nbsp;
1486753184
The Aaron
Pro
API Scripter
Oh noes!?!? &nbsp;PM me an invite?
1486755690
The Aaron
Pro
API Scripter
Hmm.. I'm not able to duplicate THAT either. &nbsp;What rules do you have and what character sheet?
1486847973
Nibrodooh
Pro
Sheet Author
Sorry for delay, yesterday was busier then i expected. Steps to reproduce bonuses failing to calculate: Create game (The Pathfinder sheet was used, it occurs with 5e shaped as well). Add&nbsp;groupinitiative 0.9.22. configure game to preference(On pathfinder I used the following commands): !group-init --del-group 0 !group-init --add-group --bare init --tie-breaker init create a character ensuring that the relevant stat is non zero assign a token to the character run "!group-init" with the token selected. I'll send a PM with an invite in it to a game with the bug.
1486851056
The Aaron
Pro
API Scripter
Fixed. &nbsp;I just updated the v0.9.22 version as it hasn't been pulled into Roll20's repo yet.
The Aaron said: Fixed. &nbsp;I just updated the v0.9.22 version as it hasn't been pulled into Roll20's repo yet. Hey, The Aaron! Thanks for the script. I asked you about this once a long time ago and you said you would get around to adding it eventually, but I run a D&D 5e group, and the ranger has advantage on their initiative rolls. As far as I can tell theres no way for your script to roll initiative twice and take the higher of the two values, so im just having my player go in and roll their initiative manually after the fact. Does this seem like a feature you would like to add? It seems pretty important to 5e players who use the revised ranger, since its a core level 1 feature. Or is maybe this possible with the script as is and I just dont know how to do it?
1487865314
The Aaron
Pro
API Scripter
It's still on my todo list: =D It is definitely something I want to do. &nbsp;It will require me to rewrite the whole rules system unfortunately. &nbsp;However, that is one of the next big things I want to tackle.
Sorry, but I am a bit of a noob -- love the idea of this script, and as I use roll20 to track initiative for a group that is not rolling for themselves (they just see the tokens on the map along with relevant npc / monsters), my goal is to select all of the player / npc / monsters on a section of a map, and have initiative rolled for all of them with the appropriate init bonus added (based on dexterity).&nbsp; Is the this right syntax for the macro I am creating? !group-init --set-roller Individual-Roll --Stat-DnD dexterity
1488161188
The Aaron
Pro
API Scripter
Almost. It will be individual roll by default. Then you'll need to remove the default stat group: !group-init --del-group 1 Then add a stat group for your game. Honestly, if you're using a character sheet, there may be a better stat to pick than dexterity (initiative, or some such.). Assuming Dexterity is what you want to use and you want to do the standard (X/2-5) DnD 3, 3.5, pathfinder, 4, 5 calculation, you'd add it like this: !group-init --add-group --stat-dnd dexterity Once that config is done, you just need to run this with tokens selected: !group-init What character sheet are you using? What game are you playing?
I may be in the same boat as Eric B Here's what I have: New game, D&D 5e using SRD5e Roll20 sheet. Using the script as is makes it roll for dex, which is the ability score, not the ability bonus. But since there's other things that may affect init, the tag i see on the sheet when I mouseover is called 'initiative_bonus'.&nbsp; I tried removing the group 1 and adding it like this &nbsp; &nbsp;!group-init --del-group 1 &nbsp;&nbsp;!group-init --add-group --stat-dnd initiative_bonus &nbsp; &nbsp;!group-init It compiles fine. Upon use though there's no bonus, its 0 (instead of before when it was adding the stat score)&nbsp; Thanks!
1488376763
The Aaron
Pro
API Scripter
You're exactly right. =D
1488456678
Lucian
Pro
API Scripter
Hey Aaron, I have&nbsp; a request. At the moment, the observer system from GroupInitiative is somewhat... uncommunicative. It says "something changed" but it doesn't say what changed and gives you no way to found out. Scripts like, e.g. TurnMarker, when they monitor the turn order, look to see if an update looks like a new character being added or a sort/turn change, so that they can take the appropriate action. When the event comes via GroupInitiative rather than direct from Roll20, this isn't possible. I'd be happy with either (1)&nbsp; a custom set of events specific to GroupInitiative - sort, add/roll, stack_pop or somesuch or (2) just getting a curr, prev pair like you do for the normal roll20 event. Cheers!
1488457676
The Aaron
Pro
API Scripter
I can do that. :). Current/Previous would be pretty easy to add here. I'll start with that.&nbsp;
1488459268
Lucian
Pro
API Scripter
Oooh ooh. I have another one! Sorry :-) This may be more controversial... As things stand, initiative on the shaped sheet has got quite complicated - there are lots of bonuses that can be factored in, some of which can be expressions, and not all of them are included in a single field anywhere. The only accurate source of initiative on the sheet is rolling the initiative roll. Would you consider adding a new roller to GroupInit that just called an ability rather than doing the math itself?
1488460550
The Aaron
Pro
API Scripter
Update v0.9.23 -- Add current and previous objects to the Notification.
1488460649
The Aaron
Pro
API Scripter
I've been chatting with Kryx about that. &nbsp;There is a problem with calling the ability but I think we've found a solution.
1488524799
Lucian
Pro
API Scripter
Cool, thanks Aaron. I have another suggestion which you probably already have an idea about solving, I suspect. Given that GroupInitiative is potentially a dependency of other scripts, and given that people often don't use 1-click (for the Shaped Companion I often recommend that people don't use it, because of the lack of control over upgrades), it would be nice if there was a way for clients to get access to the version of the script so that they can check it meets their requirements....
1488547151
The Aaron
Pro
API Scripter
Generally, I try to write the scripts so that other scripts shouldn't care what version is running, but as you know, I do have a plan... &nbsp;=D
1488570706
Lucian
Pro
API Scripter
The Aaron said: Generally, I try to write the scripts so that other scripts shouldn't care what version is running, but as you know, I do have a plan... &nbsp;=D Actually, in the end it fails fairly gracefully if the two parameters aren't there, so it's not a huge deal. Hopefully most people will have it installed via 1-click and it will update fairly soon. I do have YET ANOTHER related request :-) I have something that's watching when the turn order gets opened and closed. Any chance of a notify for that one as well?
1488571073
The Aaron
Pro
API Scripter
Now I'm starting to feel like I should send an event label as well as a obj and prev...
1488571474
Lucian
Pro
API Scripter
Well, I'd hope that whatever was registering the handlers would register a handler that at least had enough context to know what event it was registered against...
1488571533
The Aaron
Pro
API Scripter
Actually, a notification does get sent out when that happens. &nbsp;For example, you could do something like: if(obj && '[]'===obj && false === Campaign().get('initiativepage')){ // page was hidden } Slightly more complicated on the show side of things, but this should work: if(prev && '[]'===prev){ _.defer(()=&gt;{ if(false !== Campaign().get('initiativepage')){ // page was shown } }); }
1488571600
The Aaron
Pro
API Scripter
Lucian said: Well, I'd hope that whatever was registering the handlers would register a handler that at least had enough context to know what event it was registered against... Well, right now there isn't a way to specify the events of interest, just a callback for GroupInit to call. =D
1488571670
Lucian
Pro
API Scripter
Ah ok, cool, I can live with that for the moment
1488587886

Edited 1488587950
Thorsten
KS Backer
@The Aaron, I'm having trouble with Group Initiative 0.9.23, Shaped 10.1.2, and the new initiative_formula. When I do !group-init --add-group --bare initiative_formula (and make sure that's the only group), then run !group-init on a number of tokens that include PCs and NPCs, I get: SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "s" found. undefined And the API sandbox stops. I know you've tested this in @Kryx's test campaign and it works there. What do you need to find root cause? I should add: If I then restart the API and replace the group with !group-init --add-group --bare initiative|current --Tie-Breaker --Stat-DnD dexterity|current Then !group-init works just fine
1488597170
The Aaron
Pro
API Scripter
Can you post what you get in chat if you do @{selected|initiative_formula} with some of the tokens? &nbsp;There's something unexpected in that and knowing what it is would be helpful in tracking down the issue.
1488630219

Edited 1488630434
Thorsten
KS Backer
Here you go. These are the formulas of that group. d20 + 3[dex] + 0.03[tie breaker] d20 + 2[dex] + 0.02[tie breaker] d20 + 4[dex] + 0.04[tie breaker] d20 + 3[dex] + 0.03[tie breaker] d20 + 2[dex] + 0.02[tie breaker] d20 + 3[dex] + 0.03[tie breaker] d20 + 0[dex] + 0[tie breaker]
1488630871
The Aaron
Pro
API Scripter
Hmm. Wanna pm me an invite and GM me?
Thorsten B. said: @The Aaron, I'm having trouble with Group Initiative 0.9.23, Shaped 10.1.2, and the new initiative_formula. When I do !group-init --add-group --bare initiative_formula (and make sure that's the only group), then run !group-init on a number of tokens that include PCs and NPCs, I get: SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but "s" found. undefined And the API sandbox stops. I know you've tested this in @Kryx's test campaign and it works there. What do you need to find root cause? I should add: If I then restart the API and replace the group with !group-init --add-group --bare initiative|current --Tie-Breaker --Stat-DnD dexterity|current Then !group-init works just fine I had the same experience last night- using the latest shaped sheet (10.1.2 and most recent companion script) &nbsp;along with both the 0.9.23 and the 0.9.22 versions of Group Initiative. Ended up just using the stat dnd dex option, which meant it worked fine for the mobs but couldnt use it for the players
1488640610
The Aaron
Pro
API Scripter
Yeah, the problem is that @{selected|...} doesn't work from the API. &nbsp;I've got a beta version in Thorsten's game that is trying to fix that...
1488643396
The Aaron
Pro
API Scripter
Ok, I think I've got a fix for it.
1488643743
The Aaron
Pro
API Scripter
Update v0.9.24 -- Adjusted bonus calculation to deal with @{selected} and &{tracker} references (Thanks Thorsten B. )
1488645140
Kryx
Pro
Sheet Author
API Scripter
Awesome, thanks for the support, Aaron!
Aaron- your responsiveness is amazing
1488646738
The Aaron
Pro
API Scripter
I try! &nbsp;=D