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 to add custom value to tracker?

Hi, is there a script that I can use to add a custom entry to the initiative tracker? I know you can access items in the tracker with  @{tracker|itemname} to get the value, but is there any way to create and write new items? I'm using the tracker e.g. to keep track of the current time, the next rest, but also for torches, lights etc.
1473601857
The Aaron
Pro
API Scripter
I wrote one a while back, which I call AddCustomTurn: on('ready',function(){ "use strict"; on('chat:message',function(msg){ var args,cmds,who,initial,change,entry; if('api' === msg.type && msg.content.match(/^!act\b/) && playerIsGM(msg.playerid) ){ if(_.has(msg,'inlinerolls')){ msg.content = _.chain(msg.inlinerolls) .reduce(function(m,v,k){ var ti=_.reduce(v.results.rolls,function(m2,v2){ if(_.has(v2,'table')){ m2.push(_.reduce(v2.results,function(m3,v3){ m3.push(v3.tableItem.name); return m3; },[]).join(', ')); } return m2; },[]).join(', '); m['$[['+k+']]']= (ti.length && ti) || v.results.total || 0; return m; },{}) .reduce(function(m,v,k){ return m.replace(k,v); },msg.content) .value(); } args = msg.content .replace(/<br\/>\n/g, ' ') .replace(/(\{\{(.*?)\}\})/g," $2 ") .split(/\s+--/); cmds=args.shift().split(/\s+/); change=parseFloat(cmds[1])||'+1'; initial=parseFloat(cmds[2])||0; entry=args.join(' '); if(entry.length){ let to=JSON.parse(Campaign().get('turnorder'))||[]; to.unshift({ id: "-1", pr: initial, custom: entry, formula: change }); Campaign().set('turnorder',JSON.stringify(to)); } else { who=getObj('player',msg.playerid).get('_displayname'); sendChat('ACT',`/w "${who}" <div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"><div style="background-color: #ffeeee;">Error: no entry name provided.</div></div>`); } } }); }); The syntax is: !act [rate of change] [initial value] --<name to use> Some examples: !act --Counter gives you an entry named Counter that starts at 0 and increases by 1 each round. !act 4 --Quad Counter Same as above, but counts up by 4s. !act -1 10 --Countdown Starts at 10, decrements by 1 each round. !act {{ -[[1d4]] [[@{selected|Intellignce}d10!]] --Something long and interesting number [[1d6]] }} A very complicated entry where the change is -1 to -4, the starting number is the selected token's intelligence in d10s exploding, and with a title containing a number between 1 and 6. Enjoy!
This is exactly  what I've been looking for. Thanks!
1473617047
The Aaron
Pro
API Scripter
No problem! Let me know if you need anything else!  =D
Me thinks... I wonder what other magic Aaron has up his sleeve.... 
1473697285
The Aaron
Pro
API Scripter
=D  Tons.. just need the time to do all the incantations... =D
How do you still keep the overview? You seem to have a script solution for everything. And not only the script itself, but a complete set of instructions with it. I mean... do you have one of these old, dusty libraries with thousands of scrolls in it, and Unseen Servants pulling out the right scroll at the right time everytime someone comes up with a request?
1473706690
The Aaron
Pro
API Scripter
=D  Largely I have a good memory.  But I also have grep and ag to help out.  And of course, I have a good repo structure where I store all of my scripts (both in published and in development) and snippets (little things like this that I haven't formalized into full scripts) and scripts I've tweaked that others wrote.  I've also got a pretty complicated release system...
Git-based, I assume?
1473708500
The Aaron
Pro
API Scripter
Indeed. =D I store my private repo in BitBucket (private is free, public is $$) and my public repo in GitHub (public is free, private is $$).  I used to have it setup to have different branches tied to different upstreams, but that became a bit of a hassle (I also had truncated branches where a subdirectory of the github branch was the root of the truncated branch to allow subtree'ing into the Roll20 master repo.).  Now I have a more divided solution where all dev branches are in BitBucket and Production branches are in GitHub.  Files get copied into the Prod repo for published changes, and also into Roll20's repo (referred to as release by me).  It works pretty well, actually. =D
Ah sorry, the image loaded just now. What the heck is gulp? :/
1473708716
The Aaron
Pro
API Scripter
Gulp is a build system (gulpjs.com) is an automation system.  It's comparable to grunt, if you've used that.  It's Node.js based.  It's usually used for doing things like compiling SASS, minifying JS and CSS, running Javascript Tests, etc.  I use it largely as a command parser and task driver.  Most of my work is actually in a custom Node Module.
I keep my stuff all on gitlab. Have some old github account as well, but as you say, private repos cost money. Gitlab is for free (and I like the issue tracker there just a tiny little bit more). Still, I have enough trouble keeping my co-worker from developing directly on the master branch... ;) I really need to dive back into javascript a bit. Have been doing too much PHP and applescript at work, but hardly any JS...  
I need to have a look into that. If it isn't too much to gulp for me right now. *5 cp into the bad pun piggybank*
1473708897
The Aaron
Pro
API Scripter
I concur.  Death to PHP!  =D  I'm stuck developing on a Kohana (PHP, Hierarchical MVC, end of lifed 5 years ago, abandoned 2 years ago) based website.  We're moving more toward React and Laravel/Lumen.  I'm a C++ programmer at heart, but I've really come to love JS in the last 3 years... All Roll20 API's fault. =D
1473709004
The Aaron
Pro
API Scripter
I'm sure you'll gobble it up...  Oh wait.. that's another build system apparently...  I'll have to look at that.. =D
I'm actually more a designer than a programmer. But as we shift more and more towards database publishing, I was kinda forced into that. Now I eat code snippets and poop xml junks. But Kohana isn't that bad, come on.
1473710195
The Aaron
Pro
API Scripter
... said no programmer ever.   =D   It's not PHP Nuke, but it's still not great. To be honest, it could be the 35 or so programmers that worked on it in the preceding 15 years (and migrated it from VBForum to Perl to PHP to Kohana in the same codebase... we still have a VBForum database... *shudder* ).
Ah, that sounds more like it. Nothing worse than having to continue with somebody else's code. I pity the poor guy that has to work with some of my stuff in the future ;) Most of the time it's probably the best to start from scratch.
1473745707
Lithl
Pro
Sheet Author
API Scripter
The Aaron said: I concur.  Death to PHP!  =D  I'm stuck developing on a Kohana (PHP, Hierarchical MVC, end of lifed 5 years ago, abandoned 2 years ago) based website.  We're moving more toward React and Laravel/Lumen.  I'm a C++ programmer at heart, but I've really come to love JS in the last 3 years... All Roll20 API's fault. =D Kohana works well, they just have terrible documentation.