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

Function for removing tokens from the Turn Tracker?

Hey there everyone! This may seem like an odd question, but is there a function to remove a token from the Turn Order that can be used via macro? Basically the reverse of the &{tracker} command? I'd like to incorporate it into the combat-tracking framework I've setup for my HackMaster campaign. Thanks!
1432257573
Lithl
Pro
Sheet Author
API Scripter
No. The API can manipulate the turn tracker easily, but you can't do this with a simple macro.
Shucks, I was afraid that would be the answer. Guess I'm gonna be hitting the API books! Thanks very much Brian!
1432312014
The Aaron
Pro
API Scripter
Something like this should work: var removeTokenTurn = function(tid) { "use strict"; Campaign().set({ turnorder: JSON.stringify( _.reject( ( '' === Campaign.get('turnorder') ? [] : JSON.parse(Campaign().get('turnorder')) ), function(to) { return to.id === tid; } ) ) }); };
Thanks Aaron! Unfortunately, that's Greek to me... After saving the script to the campaign, how would I go about calling the function in-game?
Gilfreezy said: Thanks Aaron! Unfortunately, that's Greek to me... After saving the script to the campaign, how would I go about calling the function in-game? λειτουργία (τρεις φορές ημερησίως) { "χρησιμοποιήσει αυστηρή"? Εκστρατεία (). Σετ ({ turnorder: JSON.stringify ( _.reject ( ('' === Campaign.get («turnorder») []:?. JSON.parse (Campaign () να πάρει («turnorder»))), λειτουργία (να) { επιστρέψει to.id === τρεις φορές την ημέρα? } ) ) })? }? The scriptlet in Greek.
1432322983
The Aaron
Pro
API Scripter
Ah, it's a function you could call from another script. You could do something like: on('ready',function(){ "use strict"; var removeTokenTurn = function(tid) { Campaign().set({ turnorder: JSON.stringify( _.reject( ( '' === Campaign.get('turnorder') ? [] : JSON.parse(Campaign().get('turnorder')) ), function(to) { return to.id === tid; } ) ) }); }; on('chat:message',function(msg){ var args; if (msg.type !== "api" || !playerIsGM(msg.playerid)) { return; } args = msg.content.split(/\s+/); switch(args.shift()) { case '!noturn': _.each(msg.selected,function(s){ removeTokenTurn(s._id); }); break; } }); }); Then you could select tokens and issue: !noturn to remove each selected token from the turn order if it's in there.
1432323054
The Aaron
Pro
API Scripter
al e. said: Gilfreezy said: Thanks Aaron! Unfortunately, that's Greek to me... After saving the script to the campaign, how would I go about calling the function in-game? λειτουργία (τρεις φορές ημερησίως) { "χρησιμοποιήσει αυστηρή"? Εκστρατεία (). Σετ ({ turnorder: JSON.stringify ( _.reject ( ('' === Campaign.get («turnorder») []:?. JSON.parse (Campaign () να πάρει («turnorder»))), λειτουργία (να) { επιστρέψει to.id === τρεις φορές την ημέρα? } ) ) })? }? The scriptlet in Greek. Ha!
al e. said: Gilfreezy said: Thanks Aaron! Unfortunately, that's Greek to me... After saving the script to the campaign, how would I go about calling the function in-game? λειτουργία (τρεις φορές ημερησίως) { "χρησιμοποιήσει αυστηρή"? Εκστρατεία (). Σετ ({ turnorder: JSON.stringify ( _.reject ( ('' === Campaign.get («turnorder») []:?. JSON.parse (Campaign () να πάρει («turnorder»))), λειτουργία (να) { επιστρέψει to.id === τρεις φορές την ημέρα? } ) ) })? }? The scriptlet in Greek. Well played! Haha! The Aaron said: Ah, it's a function you could call from another script. You could do something like: on('ready',function(){ "use strict"; var removeTokenTurn = function(tid) { Campaign().set({ turnorder: JSON.stringify( _.reject( ( '' === Campaign.get('turnorder') ? [] : JSON.parse(Campaign().get('turnorder')) ), function(to) { return to.id === tid; } ) ) }); }; on('chat:message',function(msg){ var args; if (msg.type !== "api" || !playerIsGM(msg.playerid)) { return; } args = msg.content.split(/\s+/); switch(args.shift()) { case '!noturn': _.each(msg.selected,function(s){ removeTokenTurn(s._id); }); break; } }); }); Then you could select tokens and issue: !noturn to remove each selected token from the turn order if it's in there. Ahhhhh, I see! Sorry for the confusion, I should have clarified that I know jack-all about working with the API. Unfortunately, the !noturn command didn't work, and fed this error to the API Output Console: /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: Object function () { return getObj("campaign", "root"); } has no method 'get' at removeTokenTurn (evalmachine. :1559:39) at evalmachine. :1579:21 at Array.forEach (native) at Function._.each._.forEach (/home/symbly/www/d20-api-server/sandcastle/node_modules/underscore/underscore.js:78:11) at evalmachine. :1578:19 at eval ( This is even more Greek to me! And again, thank you for taking the time to tinker with this, Aaron! It's much appreciated!
1432324879
Lithl
Pro
Sheet Author
API Scripter
Should be Campaign().get('turnorder') at the start of line 8, just like at the end of line 8.
Hmmm just tried that out Brian, but no change. Still got the same error message.
1432326220
The Aaron
Pro
API Scripter
Ah, nice catch Brian. try this: on('ready',function(){ "use strict"; var removeTokenTurn = function(tid) { Campaign().set({ turnorder: JSON.stringify( _.reject( ( '' === Campaign().get('turnorder') ? [] : JSON.parse(Campaign().get('turnorder')) ), function(to) { return to.id === tid; } ) ) }); }; on('chat:message',function(msg){ var args; if (msg.type !== "api" || !playerIsGM(msg.playerid)) { return; } args = msg.content.split(/\s+/); switch(args.shift()) { case '!noturn': _.each(msg.selected,function(s){ removeTokenTurn(s._id); }); break; } }); }); Just tested this and it worked for me.
The Aaron said: Ah, nice catch Brian. try this: on('ready',function(){ "use strict"; var removeTokenTurn = function(tid) { Campaign().set({ turnorder: JSON.stringify( _.reject( ( '' === Campaign().get('turnorder') ? [] : JSON.parse(Campaign().get('turnorder')) ), function(to) { return to.id === tid; } ) ) }); }; on('chat:message',function(msg){ var args; if (msg.type !== "api" || !playerIsGM(msg.playerid)) { return; } args = msg.content.split(/\s+/); switch(args.shift()) { case '!noturn': _.each(msg.selected,function(s){ removeTokenTurn(s._id); }); break; } }); }); Just tested this and it worked for me. Perfect, works like a charm! Brian and Aaron, thank you both again so much!
1432327384
The Aaron
Pro
API Scripter
Cheers!