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

Does anyone know what API this could be?

I used this API below to create a turn tracker in the turn order for things like Bless, Rage The command I use is !act -1 10 --@{target|1|character_name} , @{target|2|character_name}, @{target|3|character_name}. Blessed If i run this command it works, If a player runs it the command doesn't work. I am try to fine out is there a function that only let the GM use it or can I set it to allow players to use. I got this API from a post that I can't find anymore and maybe some of you recongnize it. 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>`);             }         }     }); });
1506979199
The Aaron
Pro
API Scripter
yup.  I wrote that snippet a while back.. can't remember where I posted it.. it has only been posted to the API forum, so far as I know. 
1506979269
The Aaron
Pro
API Scripter
I was just thinking about that the other day.  Really needs support added for !eot, so that if you don't use the button to transition the turn order, it can still adjust the counts. Though that might need to be a more general purpose script...
1506979347
The Aaron
Pro
API Scripter
Change this line:         if('api' === msg.type && msg.content.match(/^!act\b/) && playerIsGM(msg.playerid) ){ to this line:         if('api' === msg.type && msg.content.match(/^!act\b/) ){ and players will be able to use it too.
1506982103
The Aaron
Pro
API Scripter
Here, I expanded it a bit. !act now gives rudimentary help: And let's players use it.  It will whisper to the GM who added what with what parameters: It will also correctly adjust the value when using !eot to advance the turn via some other script (TurnMarker1, HB's Turn Script, Tracker Jacker, etc), and fixes the number if you don't give it a sign ( so !act 1 10 --test gets turned into !act +1 10 --test ) Code: on('ready',function(){     "use strict";     const checkFormulaOnTurn = () => {         let to=JSON.parse(Campaign().get('turnorder'))||[];         if(to.length && to[0].id==='-1'){             sendChat('',`[[${to[0].pr}+(${to[0].formula||0})]]`,(r)=>{                 to[0].pr=r[0].inlinerolls[0].results.total;                 Campaign().set('turnorder',JSON.stringify(to));             });         }     };     on('chat:message',function(msg){         var args,cmds,who,initial,change,entry;         if('api' === msg.type) {             if(msg.content.match(/^!act\b/) ){                 who=(getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname');                 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';                 change=`${/^[+-]\d/.test(change)?'':'+'}${change}`;                 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));                     if(!playerIsGM(msg.playerid)){                         sendChat('ACT',`/w gm <div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"><div style="background-color: #ffeeee;"><b>${who}</b> added entry for <b>${entry}</b> starting at <b>${initial}</b> and changing by <b>${change}</b>.</div></div>`);                     }                 } else {                     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;">Use <b><pre>!act [formula] [starting value] --[description]</pre></b></div></div>`);                 }             } else if(msg.content.match(/^!eot/i)){                 _.defer(checkFormulaOnTurn);             }         }     }); });
Thanks maybe you can help with the second part I think token mod is yours? !token-mod --ids @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} --set statusmarkers|angel-outfit Again works for me but not players. Here is the whole macro. For me it adds the angel-outfit icon to the tokens and then prints the power card but doesn't work for players. !act -1 10 --@{target|1|character_name} , @{target|2|character_name}, @{target|3|character_name}. Blessed !token-mod --ids @{target|1|token_id} @{target|2|token_id} @{target|3|token_id} --set statusmarkers|angel-outfit !power {{ --corners|10 --format|default --name|Condition --leftsub|@{target|1|character_name}, @{target|2|character_name}, @{target|3|character_name}. ^^ You are Blessed by the Gods. --Blessed:|[+Bless]You bless up to three creatures of your choice within range. Whenever a target makes an Attack roll or a saving throw before the spell ends, the target can roll a d4 and add the number rolled to the Attack roll or saving throw. At Higher Levels: When you cast this spell using a spell slot of 2nd level or higher, you can target one additional creature for each slot level above 1st. }} Thanks The Aaron
1506983950
The Aaron
Pro
API Scripter
Sure, you just need to turn on Players Can IDs in the help, run this: !token-mod --help or just run this: !token-mod --config players-can-ids
Awesome thanks for the help.