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]

Same for me in the console: "Error: No attribute or sheet field found for character_id -JoSSGYkY38i88nJdhwG named " "Error: No attribute or sheet field found for character_id -JoSSGYkY38i88nJdhwG named " "Error: No attribute or sheet field found for character_id -JoPkh2EB-t757jDqjgs named " "Error: No attribute or sheet field found for character_id -JoSSGYkY38i88nJdhwG named " /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. Restarting sandbox due to script changes... Hm....could it be because these are mooks, and it's looking for separate character ids? EDIT: Nope, just tried it with a non-mook character, and got the same result.
Gozer the Gozerian said: Same for me in the console: "Error: No attribute or sheet field found for character_id -JoSSGYkY38i88nJdhwG named " "Error: No attribute or sheet field found for character_id -JoSSGYkY38i88nJdhwG named " "Error: No attribute or sheet field found for character_id -JoPkh2EB-t757jDqjgs named " "Error: No attribute or sheet field found for character_id -JoSSGYkY38i88nJdhwG named " /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. Restarting sandbox due to script changes... Hm....could it be because these are mooks, and it's looking for separate character ids? EDIT: Nope, just tried it with a non-mook character, and got the same result. Yep, Mook, NPC, and PC all give the same result to me.
1432133424
The Aaron
Pro
API Scripter
Update v0.9.2 -- Fixed a crash bug with empty bonus groups. (Thanks Greg and Gozer!) Try again?
Well, that seems to have done it! Thanks!
1432134122
The Aaron
Pro
API Scripter
Yeah! =D
Now, what happens if I configure a bonus group, but the character doesn't have that attribute - such as a Surprise Bonus, but there's no attribute because there's nothing in the cell (not even a "0")?
The Aaron said: Update v0.9.2 -- Fixed a crash bug with empty bonus groups. (Thanks Greg and Gozer!) Try again? Still getting the error. API Output Console Your scripts are currently disabled due to an error that was detected. Please make appropriate changes to your scripts and click the "Save Script" button and we'll attempt to start running them again. More info... For reference, the error message generated was: /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 ^ Could not determine result type of: [{"type":"M","expr":"(floor(((11)-10)/2))+(0.01*(11))"},{"type":"C","text":") + (1d20)"}] Same options configured as before, sent you a link to the campaign, i'll GM you when I see that you've joined, but stepping away for a few hours... meetings. :( blah.
1432134686
The Aaron
Pro
API Scripter
It will come in as a 0. Unfortunately, with the advent of character sheets, only the first bonus group will ever get applied because every character will always have those attributes from the character sheet, and there isn't a way to distinguish between "not filled in" and "defaulted to 0". (I have some ideas, but we'll see what I get to...)
aha.... One more question. I use ascending initiative, so it seems like the "tie breaker" bonus as it's set up would work in reverse. If you have higher Dex, it should make you go earlier, not later (i.e., give a **lower** number).
1432134877
The Aaron
Pro
API Scripter
Greg, I joined your campaign. Looks like it doesn't like your bonus group, which appears to be Stat-DnD(attr) + Tie-Breaker(attr). Sound right?
1432135132
The Aaron
Pro
API Scripter
Gozer the Gozerian said: aha.... One more question. I use ascending initiative, so it seems like the "tie breaker" bonus as it's set up would work in reverse. If you have higher Dex, it should make you go earlier, not later (i.e., give a **lower** number). Hmm.. I'll see about adding a negative Tie-Breaker or similar...
The Aaron said: Hmm.. I'll see about adding a negative Tie-Breaker or similar... Would be nice if it would toggle with the choice of ascending or descending initiative...
The Aaron said: Greg, I joined your campaign. Looks like it doesn't like your bonus group, which appears to be Stat-DnD(attr) + Tie-Breaker(attr). Sound right? Yep, worked in the prior version but the pc was getting a 0 rather than using group 2
1432142521
The Aaron
Pro
API Scripter
Gozer the Gozerian said: The Aaron said: Hmm.. I'll see about adding a negative Tie-Breaker or similar... Would be nice if it would toggle with the choice of ascending or descending initiative... Yeah, That. =D
The Aaron said: Gozer the Gozerian said: The Aaron said: Hmm.. I'll see about adding a negative Tie-Breaker or similar... Would be nice if it would toggle with the choice of ascending or descending initiative... Yeah, That. =D *whistles*
So this is working logically, however it still presents a bit of a challenge for the 5e sheet and was wondering if there is a good solution. If I try to use this for both PC and NPC there is a challenge, because the values for npc_initiative_overall and initiative_overall are both defined by default, so it is always picking the first bonus group listed. Is there any options for this? If not, I can still just use this for NPC for sure :)
1432145654
The Aaron
Pro
API Scripter
I've got some thoughts about how to fix that. I was digging into it last night. I'll have to change the way bonus groups work, such that there is some sort of indicator attribute checked to tell if a rule applies. When I first wrote this script, there were no Character Sheets, so if you didn't add the attribute, they didn't have it. With the addition of Character Sheets, now pretty much all the attributes exist. You might be able to add a custom attribute to each of your PCs, something like IAmAPC, with a value of 0, then add that into the first bonus group. In theory, it SHOULD fail to find that attribute and bypass the first rule for all the NPCs, but it really depends on how getAttrByName() works. It MIGHT just return 0 for attributes that don't exist, it also might crash big time. I'll try to get something for that rolled out soon.
1432151078

Edited 1432151959
well I thought about adding an attribute "pcinit" to characters and have that equal "@{initiative_overall}". This worked well for the characters that had this attribute, however for the NPC, which didn't have this attribute it would crash the script: /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 ^ TypeError: Cannot call method 'replace' of undefined at evalmachine.:4148:33 at Array.map (native) at Function._.map._.collect (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:97:56) at _.(anonymous function) [as map] (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:1073:39) at evalmachine.:4145:18 at /home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:158:20 at Array.some (native) at _.some._.any (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:207:59) at Function._.find._.detect (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:157:5) at findInitiativeBonus (evalmachine.:4143:11)
1432151706
The Aaron
Pro
API Scripter
Ah, excellent! By which I mean, that's a fixable problem and indicates that getAttrByName() returns undefined for attributes that don't exist. This should be a viable solution to the problem, I just need to do some coding around it. Thanks for testing that out, I'll roll out a 0.9.3 tonight that fixes this. =D
1432152449
Gen Kitty
Forum Champion
My first solution, which causes T'Aaron far less coding time, so he can get on to other projects... is to let your PCs roll their own inits :> It's what I do. I've considered using this to roll init for everyone, but there's just something so classic about, "Annnd roll for init, guys", plus I do *not* want Aaron bogged down in trying to make this program handle my PCs weird-ass init (Those within 10 squares of a specific PC have a +2 bonus to init at roll-time). Secondly, Kevin has the right idea, adding a unique attribute to the journal. I guess it is time I went and tested in my own game to see what happens when I *do* try to use it for the PCs. It's set up for them, but I never used it.... Huh. Trying to use GroupInit for both NPCs and PCs in the same selection causes: /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 ^ TypeError: Cannot call method 'replace' of undefined at evalmachine.<anonymous>:1174:33 at Array.map (native) at Function._.map._.collect (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:97:56) at _.(anonymous function) [as map] (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:1073:39) at evalmachine.<anonymous>:1171:18 at /home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:158:20 at Array.some (native) at _.some._.any (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:207:59) at Function._.find._.detect (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:157:5) at findInitiativeBonus (evalmachine.<anonymous>:1169:11) For me this isn't an issue, I'll keep going as I have with the PCs rolling their own inits. The workarounds are that, and having everyone use the same attribute for init mods.
1432152729
The Aaron
Pro
API Scripter
Well, if GenKitty is testing right now.... Update 0.9.3 -- Fixed crash bug with missing attributes. (Thanks Kevin!)
1432153030

Edited 1432153406
Gen Kitty
Forum Champion
Oh so you're going to 'make' me re-open my campaign & console. Fiiiiine ^_- Installing... testing.... !!! Aaron, my table is possessed. I have no idea how it got the init mod it did for the PC in the test. O_O Edit: I'll hang out in my campaign, in case you have time to drop in and poke at this. I'm really quite fascinated in how it drew a number out of thin air for the PC :>
1432153349
The Aaron
Pro
API Scripter
Well.. at least it didn't crash? =D Guess I'll be debugging that a bit later...
1432153427
Gen Kitty
Forum Champion
No, no it didn't CRASH. :>
1432153607
The Aaron
Pro
API Scripter
If you try it with just the one PC, does it get an appropriate number? Is it possible it's getting the bonus for someone else? (Vince broke it like that the other night and it took 2 hours to figure out it was a change in the way dice are rolled on the dev server... but that shouldn't affect prod (and shouldn't affect dev anymore either.) )
1432153875
The Aaron
Pro
API Scripter
Also, I won't be able to jump in until later tonight, sadly. =/
This worked quite well, thanks! Essentially I created a "pcinit" attribute and set this to "@{initiative_overall}". Then I simply added 2 "Bare" groups the first being "pcinit|current" and the second being "npc_initiative_overall|current". This allowed all of the PC to have their overall calculated initiative while still allowing the npc (who didn't have pcinit attribute added) to use the proper NPC initiative number. Thanks as always!
1432154546
Gen Kitty
Forum Champion
Um, cancel the exorcism, I figured it out. It is working perfectly and exactly as coded. (Cats apparently can't do math right)
1432155462
The Aaron
Pro
API Scripter
Sweet on both counts! (When it comes to cats, math isn't really the important thing, is it?)
1432172320
The Aaron
Pro
API Scripter
Update v0.9.4 -- Fixed crash bug with Stat-DnD (Thanks Greg!)
The Aaron said: Update v0.9.4 -- Fixed crash bug with Stat-DnD (Thanks Greg!) LOL. Umm welcome, are you thanking me because you know i'd break it when I tried it. :)
1432173735
The Aaron
Pro
API Scripter
ah, you did break it. =D I just fixed it. =D
The Aaron said: ah, you did break it. =D I just fixed it. =D Well its definitely back to where it was pre-version .9; however I still have the same issue with multiple bonus groups not applying the second group if it doesn't detect any on the first. Or maybe you are still working on that?
1432174131
The Aaron
Pro
API Scripter
The work around that The Kevin perfected is adding an attribute to the PCs and adding that to the first grouping. Not a perfect solution, but very viable...
The Aaron said: The work around that The Kevin perfected is adding an attribute to the PCs and adding that to the first grouping. Not a perfect solution, but very viable... oh so add the npc_dexterity value to the PCs?
1432175822
The Aaron
Pro
API Scripter
Or just add an attribute like "isPC" with a value of 0.
1432183818
vÍnce
Pro
Sheet Author
Quit playing around Aaron. Post v1.0.0 already. :-P
1432183867
The Aaron
Pro
API Scripter
HA. I don't go up to 1. lightly. =D
1432205608

Edited 1432205632
Would it be possible to add the functionality to add a constant value (+/-) to all selected tokens initiative?
1432214958

Edited 1432215017
vÍnce
Pro
Sheet Author
Like the --bonus option? Not sure if that works with negative numbers though... Update v0.8.1 - Removed dependency on isGM, added --bonus to add a number to the rolls: !group-init --bonus 5
Doesn't bonus roll and THEN add the value specified by bonus?
1432216192

Edited 1432216220
The Aaron
Pro
API Scripter
It does. inthink I know where you are going with this and I can write you a command for it. You want to run a command which will adjust the selected token's initiative by some value, say reduce them by 10. That sound right?
Exactly. :)
I was wondering if the tie-breaker initiative would work for ascending initiative if I just set up a bonus like --bonus [[ dexterity * -0.01 ]]
1432220854
The Aaron
Pro
API Scripter
Probably, though you might want to do: --bonus [[ 1 - (dexterity * 0.01) ]] instead. That way 17 with a dex of 10 ends up as 17.9 instead of 16.9
Ok, so I ran into a problem last night at our session. Here is the macro I set up for my players for their individual initiative rolling: /me rolls for initiative! !group-init --bonus ?{Speed?|0} Now, I tested this as GM, and it worked - rolled initiative for the individual, allowing me to put in a weapon speed modifier, and then adding the SurpriseBonus attribute I'd already set up as a group bonus. But for some reason, when the players tried it, it didn't work. I could still roll it as GM. Then I tested it myself after the session, logging in as a player (something I hadn't done before the session - need to do that in the future), and sure enough, it didn't work for me as a player. Am I missing something? Why would this work for a GM, but not a player?
1432443359
Gen Kitty
Forum Champion
*scratches head* I don't see any GM restrictions in the code, on my quick skim through, but this *was* originally developed for GMs to use. Any reason you're not having your players use a standard init macro on their end, since they're rolling their own inits?
1432444959
The Aaron
Pro
API Scripter
line 686 checks playerIsGM() if (msg.type !== "api" || !playerIsGM(msg.playerid) ) { ... ... ... Update v0.9.5 -- Allow players to execute !group-init and also access the --bonus argument.
GenKitty said: Any reason you're not having your players use a standard init macro on their end, since they're rolling their own inits? The reason is really just cosmetic - ever since Aaron got so fancy with the output, I like having their rolls come up in the chat the same as the monsters (I have everything set to Visible). Otherwise, I could (and was previously) using plain init macro.
1432446570
vÍnce
Pro
Sheet Author
The Aaron said: line 686 checks playerIsGM() if (msg.type !== "api" || !playerIsGM(msg.playerid) ) { ... ... ... Update v0.9.5 -- Allow players to execute !group-init and also access the --bonus argument. Let me get my hammer... Thanks for this change. I was planning on changing my init ability macros to !group-init as well. Good catch Gozer