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

[Request] Round tracker

Hey guys, I was hoping someone might be willing to do me a solid and code this, since I'm power-dumb when it comes to coding. I believe it's a fairly simple request, but if it turns out to not be easy to code it then it won't hurt my feelings if it get scrapped. I'd like it to be set up where I add a custom item to the turn order box and label it "Round 1" and it will be at the very top of the rotation. I'd like the API to be set up so that once the turn order box has been cycled through it changes the name to "Round 2" and so on and so forth. That way it would let me keep track of how long we've been in combat and how long we've got left on buffs. Once again, I'd really appreciate it if one of you guys did this whenever you have a bit of spare time, but it really won't hurt my feeling if you're too busy or if it's just a pain to get it to work. Thanks, -Joe
1385933763
Sam
Sheet Author
Well I don't know how to code it per say because I'm not a mentor, therefore I haven't worked with the Roll20 javascript api. I can offer some pseudo code which should help with developing the actual product. I believe this idea has merit and is doable since there are already scripts that can detect the token at the top of the turn tracker and then either highlight them or move a green highlight token underneath them to indicate that they are the active token. What it looks like you need to make is a token named "Round #" (# is a placeholder for a number. This token would always reside on the GM level so players would never see it. The token could be in the shape of an hour glass for added effect if you wish. Then the pseudo code would basically go. Execute on Round Change : Get token_name of the token at the top of the turn tracker Perform a compare or contains search on the returned token_name: IF (token_name contains the string "round") (probably good to do a toupper or tolower, just in case) TRUE: Process the token_name to extract the number portion at the end. Evaluate this to determine the next number in the sequence. Replace the token_name with "Round <New Number". FALSE: Do nothing. I hope this helps yourself or the person who ultimately codes this. Good luck!
1385970679

Edited 1385970775
Fabio M.
KS Backer
Here is a prototype. I doubt it will be of great use since you will probably need to heavily customize it, but nonetheless... Turn Counter It rolls a d20 for each token selected and adds the result to the DEX attribute in the corresponding character sheet. In case you don't use character sheets linked to the tokens, comment out that part, then you can just use the roll. If you want to change it to a different sided dice, change the number of die faces in the variable at the beginning. Hope this helps. Edit: Forgot to say that you have to select the tokens that you want in your initiative and then input the command !initiative
I appreciate the help, but I think I did a bad job of communicating what I'm asking for. I have a token named "Round" and I want his initiative to increase by 1 every time it's his turn. That way I can always tell, at a glance, how long we've been in combat. But thank you for giving me the a new initiative roller! I'll use that too!
Ok, I see. Sorry, I read quickly your post and I misunderstood. I updated the script with a function that does that as well. You need a token on the same page where the PCs are (any layer) and you have to name it "Round 1". If you want to quickly try it without setting up character sheets for each token you can just change the block of code with the _each loop like this: _.each(selected, function(obj) { if(obj._type != 'graphic') return; var token = getObj("graphic", obj._id); aChars[nCount] = new Array(2); aChars[nCount][0] = token.get('_id'); aChars[nCount][1] = randomInteger(initiativeDie); nCount++; });
You're awesome. I'm out of town now, but I'll try this out en I get home and let you know how it works for me! Thanks again.
Fabio, I hate to keep pestering you, but I was hoping you could do me another solid. Is there any chance you could change it so that instead of rolling and adding dex it rolls and adds the attribute "Initiative"? I've been messing with it for the past 15 minutes and it keeps giving me errors saying there are undefined objects =/ Also, any chance you could throw a command in there to reset the counter? There are times where we elect to keep the same initiative over multiple combats, and it'd be a pain to have to go in a delete everything, then reset it all, and then manually add back in the old initiatives. Have I mentioned how much I appreciate you for doing this? :P
Actually, if it's rolling initiative automatically I don't need to be able to reset it. I'd be fine with just always having new rolls if it was adding the attribute "Initiative" instead of just "dex".
Hmm, I just updated it in Gist with the !restart command, that resets the counter to 1 leaving the original initiatives and original tokens. I also changed the code to take Initiative instead of Dex. What do you need exactly?
Ok, another update: Now you can reset the counter, leaving the old initiatives, or you can reroll them while resetting the counter. The command to reroll is "!restart reroll". If you type "!restart" it only resets the counter, but leaves everything else the same. Fabio
You're my hero. I'll be home in about an hour and a half and I'll check it out to make sure its working correctly for me! thanks a ton, this should be perfect.
Hey Fabio, I've been playing with this off and on since last night. For the most part it works great. But once in a while it will randomly shoot me a message saying "no round token present". It usually happens after I reset everything and it happens on like the 2nd or third round, but it will sometimes happen when I do the !restart command. Actually, I've been playing with it for a while now and I think I've got it figured out. It's happens when the token on the GM layer "Round 1" has been renamed up to like "Round 7" it gives that message when you restart up until the script is asking for "Round 7". Also, once it's been up for a while it bugs out and disables itself. I went to bed while it was working and I woke up to an error. I wish I'd checked to make sure I had it before I refreshed the script and lost it, because apparently something didn't work when I tried to copy the error. But it was something about turnorder being undefined and 88:9. I'll keep an eye out in case it pops back up and post it verbatim.
I've gotten a few different error messages now. I've not gotten the undefined turnorder message again, but I've just gotten both of the following. TypeError: Cannot call method 'get' of undefined at evalmachine.<anonymous>:149:86 at Array.forEach (native) at Function._.each._.forEach (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:78:11) at Sandbox.<anonymous> (evalmachine.<anonymous>:140:15) at eval ( TypeError: Cannot call method 'get' of undefined at evalmachine.<anonymous>:118:86 at Array.forEach (native) at Function._.each._.forEach (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:78:11) at Sandbox.<anonymous> (evalmachine.<anonymous>:109:15) at eval ( I had a token that didn't have an "initiative" attribute set up, and it was giving me those errors and crashing the whole script. But it seemed to work fine once I added that attribute to the char sheet.
Sorry, that error is because I didn't check correctly the existence of the character's initiative attribute, now it is fixed (if you download the script again from Gist). The error about the token is because if you emptied the Turn Tracker the Round token remained with the round number at which your combat ended. It then looked for a token named "Round 1". Now I slightly twisted the code so it should always work. Mind though that the script won't keep its status between sessions or if there is a restart of the sandbox, so it won't "remember" the round number or the tokens involved in the initiative in those cases, even if the Turn Tracker will keep showing you a list. You will have to empty it manually and to rename the Round token to "Round 1" before using the script again.
1386194175
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Place the round number in a player sheet as an attribute and archive it.... if round is missing pull from the player sheet attribute.
You're awesome. I don't have words for how much I appreciate this community!
The round number is not the only thing that should be saved. You would also need to store the entire array of tokens in the initiative with their Initiative score and rolled die. It can be done as you said in a character's sheet (probably one linked to the Round token to keep things neat).
1386197911
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Fabio M. said: The round number is not the only thing that should be saved. You would also need to store the entire array of tokens in the initiative with their Initiative score and rolled die. It can be done as you said in a character's sheet (probably one linked to the Round token to keep things neat). You don't have the array on round 1.... you build it on the fly. You would do the same thing on round 6 (assuming the group broke secession on the end of round 5.) And agree you store the Round Token in the sheet (default token) and also place the commands in the Abilities for this too.
You would need to store the array anyway, at every round, since you don't know when they are going to stop or when and if the sandbox is restarted (especially if playing on the Dev server). That is unless you make a command that saves the state on request, but it wouldn't be useful in case of a sandbox restart, or if the game master didn't remember to use it before logging out ;)
I got the first error again. I went to bed while the campaign and the API pages were still open. Woke up with the API saying it had been shut down due to campaign inactivity. I couldn't get it to come back online. I ended up having to go back to the "my campaigns" page and reopen the API for this campaign. Once I opened it up again I was given the following error message. ReferenceError: turnorder is not defined at evalmachine.<anonymous>:85:9 at eval (
Yes, as I told you, in case of a sandbox restart, if you were in the middle of a combat (with some tokens in the Turn Tracker) you would need to empty the Turn Tracker by hand and rename the Round token to "Round 1". Then you can re-issue the command !initiative.
Gotcha! I must have misunderstood! Thanks!
1386281359

Edited 1386281450
Stephen S.
Pro
Marketplace Creator
Sheet Author
API Scripter
Few notes.... it will be looking for your _d20userid (see mine: <a href="https://wiki.roll20.net/User:135636" rel="nofollow">https://wiki.roll20.net/User:135636</a> ) for who is allowed to use the commands. It will make a GM_CombatMaker player sheet with API commands as abilities and track current round number and total last rounds (last turn will persist until new new combat begins) as attributes It will be looking for a round marker... I used this one: Be sure to make something the default token once the GM_CombatMaker player sheet is created (once it's made you never need to make it again.) It places a unsorted table showing the rolls in the chat (so you can see the modifiers) It sorts and updates the turn order. Edit to your system in the TurnOrderManagement function... You can add other things in the areas marked: /* Extra Start of Combat stuff goes here.... Extra Start of Combat stuff goes here.... Extra Start of Combat stuff goes here.... */ /* Extra Next Round stuff goes here.... Extra Next Round stuff goes here.... Extra Next Round stuff goes here.... */ /* Extra End of Combat stuff goes here.... Extra End of Combat stuff goes here.... Extra End of Combat stuff goes here.... */ Right now its rolling.. //dice used for combat var rollValue = 10; And modified based on the tokens green bar value for player tokens... var greenBar = loopGraphic.get("bar1_value"); GM tokens are not modified with the as is code. It does some error messaging in the script to guide you through getting it set up. Copy the code and enter: !NewCombat <a href="https://gist.github.com/BaldarSilveraxe/7813764" rel="nofollow">https://gist.github.com/BaldarSilveraxe/7813764</a>
Hi again, Another update: I inserted the use of the state object in the code. Now the initiative is kept during different sessions and in the event of a sandbox restart. I also added a sendChat to tell everybody the rolls made. The commands are still the same: !initiative - insert into the tracker the selected tokens, rolling for initiative and sorting them; !restart - resets the counter to 1; !restart reroll - resets the counter to 1 and rerolls for initiative for every token in the tracker, resorting them. In case you empty the Turn Tracker manually, you don't need to rename the Round token anymore. Next time you will select some tokens and type !initiative, it will be renamed to "Round 1" automatically.
Holy.,. shit... Lol, this is way more in depth than I ever expected someone to code for me out of the kindness of their heart :P. Since you've been super accommodating so far... Is there any chance I could beg a few changes? As of now it rolls one die for the entire party, is there any chance I could talk you into setting it up so that every token gets their own d20 roll? Also, its currently set to add the value of Bar1 to the d20 that was rolled, could you have it pull the attribute "Initiative" instead? I don't need it to roll a separate die for the GM since it will be rolling the die individually for each token I have selected when I make the command.
You're awesome Fabio, this is wonderful.
No worries! I added another command that could be useful: !addtokens (selecting one or more new tokens first). This is in case you want to add one or more tokens (not in the Turn Tracker) into the current round. It rolls for the new tokens and re-sorts all the tokens in the initiative showing the new list. You can also delete a token from the Turn Tracker (using the bin icon, of course) without problems, in case you don't need it anymore (dead, fled, etc.). Didn't test it too much but it should work fine. Enjoy!
We played last night and we used the API script you made, but every time someone wanted to delay their action I'd move them to a lower place in the initiative order, but once the ound was over it put everyone back in their original order again. Is that something thts fixable?
1386368533

Edited 1386382219
Fabio M.
KS Backer
You're talking about mine or Stephen script? I reckon mine would behave like you described, since it is basically an array of tokens sorted by their Initiative total that is put into the Turn Tracker at the beginning of every Round. So any change of order you make is "lost" when a new Round kicks in. Yes, it is possible to make your custom order permanent overwriting the array with the contents of the Turn Tracker at every new Round. But in case you issue the "!restart reroll" or the "!addtokens" command, you would loose the order again (both those commands re-sort the array) unless you changed the Initiative totals in the Turn Tracker first and then at least a Round passed by. Edit: I amended the code to allow fiddling with the order in the Turn Order. The new order is than kept between rounds, with the limitations above mentioned, though. 2nd Edit: I had to fix a bug, so I re-uploaded the script. Another warning: If you move the tokens in the Turn Order (to allow for a delayed action, for example), be sure that you move away from the header first. It means that your highlighted line in the Turn Order (the topmost one) mustn't be the "ROUND x" one, or as soon as you move one of the tokens it will increase by 1 (everytime you move something). Sorry but I couldn't think of a quick solution to avoid that. If somebody comes up with a nice suggestion I'd be happy to code fix it.
I posted the script under a more specific post here , and I also made other fixes and changes to the code. Please address any further questions or requests over there, thanks!