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

Help : Create and edit value of custom tracker values using API or Sheetworkers.

Hello everyone. I resumed progress on a homebrew initiative system, and for making it easy to use for my players, I would like to know if it is possible to create custom item and update this value using API, or a sheetwrker if possible. I know that you can't usually create tracker items because they are linked to a token and not a sheet, but it seems that custom tracker items, that are linked to nothing, will do the trick, as long as no 2 characters have the same name. I will then be able to access and update these tracker items using something close to @{tracker|@character_name} (with the trick that makes it work : <a href="https://app.roll20.net/forum/post/5718527/read-a-tokens-initiative-without-api" rel="nofollow">https://app.roll20.net/forum/post/5718527/read-a-tokens-initiative-without-api</a>) I am looking for these 2 functionalities : - !createcustomitem Peter : Create a custom tracker item named "Peter" - (Optional) !setcustomitem Peter 5 : Set custom item Peter to 5 (but I can do without this one) I tried using TurnTracker1 (I thought it could create custom items using !act), but it seems I can't get it to work correctly. Any suggestion for getting these 2 functionnalities by any mean possible ? I will make my own API script if it is what I have to do (though I have just learned how to do sheetworkers, so it will be hard), but I am hoping that this already exists somewhere.
1597499845
The Aaron
Roll20 Production Team
API Scripter
I have a script for this called AddCustomTurn. I can't find a link to it from my phone, but I'll post it when I get back to my computer.&nbsp;
1597500596
The Aaron
Roll20 Production Team
API Scripter
Found the post:&nbsp; <a href="https://app.roll20.net/forum/permalink/3346527/" rel="nofollow">https://app.roll20.net/forum/permalink/3346527/</a>
Oh so that's what it was. I misunderstood and thought it was a functionality of turn Tracker, my bad. It seems like it will fit my needs perfectly, thanks !
1597506506
The Aaron
Roll20 Production Team
API Scripter
I have another one that creates custom turns on the GM layer so they aren't visible to players, if you need that functionality.&nbsp;
1597508106

Edited 1597544874
The generated initiative will usually be for the players. Buuut GM custom turns would be great for ennemies if you have the script available. (Something like !actnpc) Right now I have slightly modified the code using my javascript "skills" so that when an item already exists, it updates the item rather than create a new one with the same name on('ready',() =&gt; { const checkFormulaOnTurn = () =&gt; { let to=JSON.parse(Campaign().get('turnorder')||'[]'); if(to.length &amp;&amp; to[0].id==='-1'){ sendChat('',`[[${to[0].pr}+(${to[0].formula||0})]]`,(r)=&gt;{ to[0].pr=r[0].inlinerolls[0].results.total; Campaign().set('turnorder',JSON.stringify(to)); }); } }; on('chat:message',(msg) =&gt; { if('api' === msg.type) { if(msg.content.match(/^!act\b/) ){ let who=(getObj('player',msg.playerid)||{get:()=&gt;'API'}).get('_displayname'); if(_.has(msg,'inlinerolls')){ msg.content = _.chain(msg.inlinerolls) .reduce((m,v,k) =&gt; { let ti=_.reduce(v.results.rolls,(m2,v2) =&gt; { if(_.has(v2,'table')){ m2.push(_.reduce(v2.results,(m3,v3) =&gt; { m3.push(v3.tableItem.name); return m3; },[]).join(', ')); } return m2; },[]).join(', '); m['$[['+k+']]']= (ti.length &amp;&amp; ti) || v.results.total || 0; return m; },{}) .reduce((m,v,k) =&gt; { return m.replace(k,v); },msg.content) .value(); } let args = msg.content .replace(/&lt;br\/&gt;\n/g, ' ') .replace(/(\{\{(.*?)\}\})/g," $2 ") .split(/\s+--/); let cmds=args.shift().split(/\s+/); let change=parseFloat(cmds[1]); change = Number.isNaN(change) ? '+1' : change; change = `${/^[+-]\d/.test(change)?'':'+'}${change}`; let initial = parseFloat(cmds[2])||0; let myvar = parseFloat(cmds[3])||0; let entry = args.join(' '); let replace_index = -1; let old_val = 0; let i1 = parseInt(initial, 10); let new_val = i1; if(entry.length){ let to=JSON.parse(Campaign().get('turnorder')||'[]'); to.forEach(function (item, index) { log(item); if (item["custom"]===entry) { replace_index=index; } if (item["custom"]==="") { //matchingTokens = filterObjs(function(obj) { // return ((obj.get("id")===item["id"]) &amp;&amp; (obj.get("_subtype")==="token")); //}); //log(matchingTokens); matchingTokens = findObjs({ _id: item["id"], _type: "graphic", _subtype: "token", }); if (matchingTokens.length) { replace_index=index; } } }); if (replace_index == -1) { to.unshift({ id: "-1", pr: initial, custom: entry, formula: change }); } else { var i2 = parseInt(to[replace_index]["pr"],10); old_val = i2; new_item = to[replace_index]; if (myvar != 0) { new_val = i1+i2; } new_item["pr"] = new_val; to[replace_index] = new_item } Campaign().set('turnorder',JSON.stringify(to)); if(!playerIsGM(msg.playerid)){ sendChat('ACT',`/w gm &lt;div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"&gt;&lt;div style="background-color: #ffeeee;"&gt;&lt;b&gt;${who}&lt;/b&gt; sur &lt;b&gt;${entry}&lt;/b&gt; : &lt;b&gt;${old_val}&lt;/b&gt; devient &lt;b&gt;${new_val}&lt;/b&gt;.&lt;/div&gt;&lt;/div&gt;`); } } else { sendChat('ACT',`/w "${who}" &lt;div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"&gt;&lt;div style="background-color: #ffeeee;"&gt;Use &lt;b&gt;&lt;pre&gt;!act [formula] [starting value] --[description]&lt;/pre&gt;&lt;/b&gt;&lt;/div&gt;&lt;/div&gt;`); } } else if(msg.content.match(/^!eot/i)){ _.defer(checkFormulaOnTurn); } } }); }); Small edit : I glanced at the AICT script, but the token generation doesn't seem to work ? Second edit : Updated my script to match what I currently use. Now it also updates if a tracker was created using a token.
I can say that ACT and AICT are very useful to me in my game. :-) The Aaron said: I have another one that creates custom turns on the GM layer so they aren't visible to players, if you need that functionality.&nbsp; &lt;hopeful&gt;Any more thoughts on combining them into a single script?&lt;/hopeful&gt;