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] GroupInitiative -- Calculate the Initiative for all selected tokens [New Thread]

December 13 (9 years ago)
The Aaron
Pro
API Scripter
There is a bug in the API dice parser that causes it to fail like this because of space use in the formula. I was hoping they'd fix this bug soon, but it's been hanging on for a while.  I've not heard of this being an issues with the pathfinder sheet, but you might check that you don't have leading spaces in any of the stats used for initiative. 
December 14 (9 years ago)
vÍnce
Pro
Sheet Author
Not sure if this helps... I use this for PF without errors.

December 14 (9 years ago)

Edited December 14 (9 years ago)
I looked for any stray spaces in any of the character sheets I've tested for this script, no luck so far.
To make sure I didn't miss anything, I also made a brand-new character sheet and tested it out. It still returns the same error unfortunately.


On the other hand, I seem to have narrowed down the culprit to the recently-added Buffs section. Currently, it looks like the sheet calculates the Dexterity ability score this way:
@{DEX-base} + @{DEX-enhance} + @{DEX-misc} + @{buff_DEX-total} + @{DEX-drain}
When I try this out with the script, it breaks and returns the same error that I keep getting. However, when I remove the @{buff_DEX-total}, it works fine and calculates my total Dex just fine.


Edit:
Vince, I gave that a shot. Sadly still doesn't seem to work. Same error.

December 14 (9 years ago)
The Aaron
Pro
API Scripter
Hmm. I'll see if I can duplicate that tomorrow. 
December 14 (9 years ago)
vÍnce
Pro
Sheet Author
Yeah, I just realized that my screen shot is for a custom sheet with very old code.  
Do you get a result from @{selected|buff_DEX-total} in chat?  I noticed that if there's anything wrong with the buffs array (usually a syntax error in the macro-text field) will cause other rolls and/or auto-calc attributes that include the buff to error out.  
December 14 (9 years ago)
Yup:
((0(0)) + (0(0)) + (0(0)) + (0(0)) + (0(0)) + (0(0)) + (0(0)) + (0(0)) + (0(0)) + (0(0)))


On a sidenote, ignoring everything else and using --addgroup --Bare buff_DEX-total produces a slightly different error than before:
/home/symbly/www/d20-api-server/node_modules/firebase/lib/firebase-node.js:1
orts, require, module, __filename, __dirname) { function g(a){throw a;}var j=v
                                                                    ^
SyntaxError: Expected "(", ".", "[", "abs(", "ceil(", "d", "floor(", "round(", "t", "{", [ |\t], [+|\-] or [0-9] but ")" found.
December 15 (9 years ago)
vÍnce
Pro
Sheet Author
As soon as the Dev's push the next update to the main server, the PF sheet will be using javascript (sheet workers) to handle all auto-calculated attributes, including buffs.  So it's possible this could be a non-issue with the update.  I'm not sure because Chris has handled the js conversion.

You could try running a test on the dev server with the latest build of the sheet (https://github.com/Roll20/roll20-character-sheets/...) to see if it's still going to give group init problems.
December 15 (9 years ago)
vÍnce
Pro
Sheet Author
I just tried group-initiative with the latest sheet build (see above), and everything seems to work great.  No errors.
!group-init --add-group --Bare init --Tie-Breaker init|current
December 15 (9 years ago)
The Aaron
Pro
API Scripter
Ok. I'll hold off on the duplication attempt until tomorrow.  Vince, have you tried your usual cadre of crazy commands with the new character sheet to make sure you haven't found more bugs in my scripts?  =D
December 15 (9 years ago)
vÍnce
Pro
Sheet Author

The Aaron said:

Ok. I'll hold off on the duplication attempt until tomorrow.  Vince, have you tried your usual cadre of crazy commands with the new character sheet to make sure you haven't found more bugs in my scripts?  =D
I haven't... real-life and character sheets have been eating up too much time.  Friends have decided to give 5e a trial run, so I hope to "stress test" your scripts real soon.  ;-P

December 15 (9 years ago)
The Aaron
Pro
API Scripter
Excellent!  5e is my favorite version. :)
December 15 (9 years ago)

Edited December 15 (9 years ago)
Tested it out on the dev server as Vince suggested, and it works perfectly on my end as well. Now I gotta wait until the update is released so I can start using this script with creatures using the character sheet.

Thanks a bunch for the help guys!
December 15 (9 years ago)
The Aaron
Pro
API Scripter
That should be released live now, if you want to give it a go.
December 22 (9 years ago)
Coal Powered Puppet
Pro
Sheet Author
I don't know why, but in my Iron Kingdoms game, the Group Initiative take a very long time; sometime up to five minutes.  Usually, it just fails if I have more than a dozen tokens selected.  

I had to do the following adjustments (in the in-chat-dialogue)
  • 2 dice
  • d6 dice
  • bare attribute added to the roll is called @{initiative} (labeled "initiative" in the in-chat-command area)
  • bare attribute added to the roll is called @{Preternatural_Awareness-switch} (labeled "Preternatural_Awareness-switch" in the in-chat-command area); this was added after-the-fact, but was promoted to top level.
...what am I doing wrong?


December 22 (9 years ago)
The Aaron
Pro
API Scripter
Are you using the latest version?
December 22 (9 years ago)
Coal Powered Puppet
Pro
Sheet Author
I pulled from github today, so I think so.
December 22 (9 years ago)
The Aaron
Pro
API Scripter
Hmm.. If you want to PM me an invite, I can jump in and do some testing...
December 23 (9 years ago)
Coal Powered Puppet
Pro
Sheet Author
Link sent
December 24 (9 years ago)
The Aaron
Pro
API Scripter
Update v0.9.13 -- Fixed bug where having 10+ enemies could result in the wrong bonus being applied. (Thanks Jurph!)
December 24 (9 years ago)
Coal Powered Puppet
Pro
Sheet Author
Hooray!

Wait, does this fix my issue?  I will check!
December 24 (9 years ago)
The Aaron
Pro
API Scripter
Unfortunately, it probably won't fix that. =/  I think the issue in your case is too many rolls for for the API to handle.  Still testing that one.
December 24 (9 years ago)

Edited December 24 (9 years ago)
Coal Powered Puppet
Pro
Sheet Author
I can still dream....

No, it doesn't fix it.  But the rolls are better, so there is that.
December 24 (9 years ago)
The Aaron
Pro
API Scripter
I just reviewed the character sheet for you game.  The way it is set up ends up having 3 nested inline rolls, 2 of which requires at least 2 nested attribute lookups (2 deep). That's likely going to be too much for the API to do all at once (it fires off a separate sendChat() in parallel for each token to roll the results).  I could likely make you a custom version that would do them in series instead, but I don't know that it would work any better.  =/
December 24 (9 years ago)
The Aaron
Pro
API Scripter
Ok, I tried that.  It's still slow, but it does finish running without crashing!  I left it in your API with the name GroupInitiative-SerialRolls.

While there might be a way to make those rolls faster, it would be sizable system (Analyze actual rolls, cache minimal dynamic rolls and adjustments to avoid the cost of inline rolls and attribute lookups, event tracking for changes to the stats to rebuild the formula, etc..) which I don't think I can commit to right now. =(
December 24 (9 years ago)

Edited December 24 (9 years ago)
Coal Powered Puppet
Pro
Sheet Author
I was going to tell you not to worry about it.  Actually, going to tell you now: don't worry about it.  It wold be nice, but there are much better things to do.  And no worries about the Silhouette Core dice; its easy just to look at the rolls (at least, as far as I am concerned).
December 24 (9 years ago)
The Aaron
Pro
API Scripter
Ok!  The version I left in your game does work, so depending on how you need to use it, it should be fine. Just a little slow. :)

I'll mark SC off my immediate list, though I'll likely finish it at some point. :)
Hi Aaron!

I'm having a weird issue occur with GroupInit.  I'll select a group of NPCs and then issue the command to calculate their initiatives, but I get some wild numbers coming back.  Like a Kobold getting a result of 25 (a normal Kobold only has a +2 DEX bonus)??  Even a result of 22 for an NPC that I know has no DEX bonus.  Since NPCs do not get proficiency bounses, I just don't see how these numbers are possible.  I've had to result to manually rolling for each in the middle of sessions because my players cried foul (and rightly so).  I know its probably something I've got misconfigured, but I'm stumped.  Any idea on what may be going on here?

Thanks!

Craig L. said:

Hi Aaron!

I'm having a weird issue occur with GroupInit.  I'll select a group of NPCs and then issue the command to calculate their initiatives, but I get some wild numbers coming back.  Like a Kobold getting a result of 25 (a normal Kobold only has a +2 DEX bonus)??  Even a result of 22 for an NPC that I know has no DEX bonus.  Since NPCs do not get proficiency bounses, I just don't see how these numbers are possible.  I've had to result to manually rolling for each in the middle of sessions because my players cried foul (and rightly so).  I know its probably something I've got misconfigured, but I'm stumped.  Any idea on what may be going on here?

Thanks!


DId you set a Bonus Stat Group?
January 07 (9 years ago)
vÍnce
Pro
Sheet Author
Posting a screen cap can help others see what your settings are as well.  
BTW:  Love that avatar David.  ;-P

example: here's my settings for groupinitiative

January 07 (9 years ago)
The Aaron
Pro
API Scripter
That does sound weird.  I second the request for configs.  Also, do you get aberrant behavior with a single token selected?  If you turn on the Announcer and hover over the results, do they reflect the strange numbers?
January 07 (9 years ago)
vÍnce
Pro
Sheet Author
Tiny future suggestion: I know the version info is at the top of the help/info screen, but it might be nice to include it at the bottom as well... small and indiscreet.  I have to nit-pick, otherwise there's nothing left to do on your scripts Aaron.  ;-P
January 08 (9 years ago)
The Aaron
Pro
API Scripter
It is in the API Log window... =D
January 08 (9 years ago)
vÍnce
Pro
Sheet Author
What, I have to look at another screen.?  ;-P
January 08 (9 years ago)

Edited January 08 (9 years ago)
Thanks for the responses.  Here are my current settings.


January 08 (9 years ago)
The Aaron
Pro
API Scripter
Ok.  The issue is you have only the default group setup (which happens to be 'dexterity').  This default is vestigial, from the days before character sheets.  Back then, you literally didn't have any attributes and had to manually set them up yourself. I should really take out the default.

Anyway, so I bet your kobold has a dexterity and it is at least a 5.  =D  What's happening is it is rolling a d20 and adding the value of dexterity to it.  That's why you're getting large numbers.

You'll want to remove that default group:
!group-init --del-group 1
Then add something that makes sense.  Anymore, that means finding the initiative field on your character sheet (right click the field, view source, copy the name of the input, stripping attr_ off the front of it) and use that.  If you're running a custom game system or not using character sheets, there are some options.

Assuming your init mod is named 'init_total', you'd then add it as a group with:
!group-init --add-group --Bare init_total
You'd only need to do this once to setup the configuration.


So, to proceed, what do you use for a character sheet or do you use something else?

January 24 (9 years ago)

Edited January 24 (9 years ago)
Thanks for the response, Aaron.  Sorry it took so long to get back to you.  The last couple of weeks have been crazy and I haven't even been gaming. 

I thought it might be that, but wanted to get thoughts from the SMEs.  ;-)  I'm using a custom 5e sheet that I wrote myself.  However, the attributes are pretty standard so what you have above should work just fine.  As always, thanks a lot!
January 24 (9 years ago)
The Aaron
Pro
API Scripter
No problem!  If you are still having problems, definitely PM me an invite and GM me and I'll come sort it out with you. =D
January 24 (9 years ago)

Edited January 24 (9 years ago)
I may be asking the impossible, but that seems to be your speciality :)

Is there a way please, using the 5e (shaped) sheets, for PC's initiative roll to be entered manually following 'real dice' rolling as a query, eg 'rolledint ?{rolledint?|0}' and add tiebreaker from the 5e sheet

then NPC to take the initiative_overall|current + Tie-Breaker( initiative_overall|current ) from the 5e sheet.

And then the turn order to be opened and sorted?
January 25 (9 years ago)
The Aaron
Pro
API Scripter
The API doesn't really have a way to prompt the user for input.  About the best I could do is add a way of flagging manual rolls and have a button that will prompt for all of the manual rolls, which would be output to chat during a !group-init roll, and then would need to be clicked to be prompted for the numbers.

Easier might be to have it put -- in for manual rolled characters and sort all -- to the top, allowing you to input them each as you roll them.  That might be better too.. hmmm....
January 25 (9 years ago)
i had a feeling it would not that easy lol.
Aaron, I was playing around w/ this script today and found a couple of issues when trying to use the --reroll flag.

  1. The Replace Roll toggle overrules the --reroll flag.  So if you have the Replace Roll option set to Off, you cannot use the --reroll option.  Any chance this could get changed?
  2. When I try to use the reroll flag, the tracker disappears and I need to manually reopen it (but only if the Replace Roll option is Off, so it may fix itself if you resolve issue #1).

Thanks for the wonderful script!
January 29 (9 years ago)
The Aaron
Pro
API Scripter
Update v0.9.14 -- Fixed bug with --reroll not working if Replace Roll was off. (Thanks Three of Swords!)

Both issues were resolved by fixing #1.  =D
Great!  I was planning on re-rolling every round in my new game, but I realized that might not work out well.

I like to set spell durations (using the round calculator) in the Turn Order, and it would end up rerolling them as well.
January 31 (9 years ago)
The Aaron
Pro
API Scripter
Update v0.9.15 -- Fixed bug with --reroll causing custom entries to be dropped off the Turn Order. (Thanks Three of Swords!)

That should clear it up.. =D
January 31 (9 years ago)

Edited January 31 (9 years ago)
I wish people I paid to do things for me were as prompt!

So it works mostly fine, but there is one border case where your latest change will cause it to crash.

If you rotate through the Turn Order list until the Custom entry is at the bottom of the list, then use !group-init --reroll the script crashes and returns "Cannot call method 'get' of undefined".

This one was my fault.  I forgot I had a different script that actually accessed the turn tracker.  Aaron logged into my game and spotted the issue right away.

So once again, Aaron saved the day!

February 09 (9 years ago)
The Aaron
Pro
API Scripter
Update v0.9.16 -- Added --clear to remove all turns from the turn order. If Auto Open Init is enabled, it will also close the turn order window. (Thanks Lucian H.!)
February 10 (9 years ago)
Cool!