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

Adding a string of characters to the tracker

1558263262

Edited 1558263282
David
Sheet Author
Is there a way of using &{tracker} to add a string e.g. "6/12" to the tracker without it converting it to a numeric value ?  If there is an API script that would do it could someone point me to it.
1558276363
The Aaron
Roll20 Production Team
API Scripter
This should work: !att 6/12 Code: on('ready', () => { on('chat:message',(msg) => { let args,cmds,who,initial,change,entry; if('api' === msg.type) { if(msg.content.match(/^!att\b/) ){ who=(getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); if(_.has(msg,'inlinerolls')){ msg.content = _.chain(msg.inlinerolls) .reduce(function(m,v,k){ let 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(); } let text = msg.content.split(/\s+/).slice(1).join(' '); if(text){ let turns = _.chain(msg.selected) .map((o)=>getObj('graphic',o._id)) .reject(_.isUndefined) .map((t)=>({id: t.id, pr: text})) .value(); if(turns.length){ let to=turns.concat(JSON.parse(Campaign().get('turnorder'))||[]); Campaign().set('turnorder',JSON.stringify(to)); } else { sendChat('ATT',`/w "${who}" <div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"><div style="background-color: #ffeeee;">Nothing selected capable of having a turn.</div></div>`); } } else { sendChat('ATT',`/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 ${'&'+'lt'+';'}text${'&'+'gt'+';'}</pre> -- add turns for selected tokens with the supplied text as the value of their turn.</b></div></div>`); } } } }); });
1558277180
David
Sheet Author
Yes that worked. Thank you you saved me a lot of SAN points.
1558277641
The Aaron
Roll20 Production Team
API Scripter
No problem! =D
1558277688
David
Sheet Author
It adds a new entry. Anyway it can replace the existing one?
1558278769
David
Sheet Author
I just found your noturn script I can use that. 
1558282046
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I don't know what forumla you are using, but if you want to use a slash without making it a division sign, you could always try a solidus:    ∕ 
1558282719

Edited 1558283603
David
Sheet Author
keithcurtis said: I don't know what forumla you are using, but if you want to use a slash without making it a division sign, you could always try a solidus:    ∕  I am not using a formula it is effectively a piece of text  &{tracker} will only pass valid results from the the die roller to the turn tracker.
1558298906
The Aaron
Roll20 Production Team
API Scripter
Here's an updated version that has the optional command !rtt to replace existing rolls: !rtt 6/12 on('ready', () => { on('chat:message',(msg) => { if('api' === msg.type) { if(msg.content.match(/^![ar]tt\b/) ){ let who=(getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let replace=/^!rtt/.test(msg.content); if(_.has(msg,'inlinerolls')){ msg.content = _.chain(msg.inlinerolls) .reduce(function(m,v,k){ let 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(); } let text = msg.content.split(/\s+/).slice(1).join(' '); if(text){ let turns = (msg.selected||[]) .map((o)=>getObj('graphic',o._id)) .filter( o=> undefined !== o) .map((t)=>({id: t.id, pr: text})); let ids = turns.map(t=>t.id); if(turns.length){ let oldTo = (JSON.parse(Campaign().get('turnorder'))||[]).filter(t=>(replace ? !ids.includes(t.id) : true )); let to=turns.concat(oldTo); Campaign().set('turnorder',JSON.stringify(to)); } else { sendChat('ATT',`/w "${who}" <div style="padding:1px 3px;border: 1px solid #8B4513;background: #eeffee; color: #8B4513; font-size: 80%;"><div style="background-color: #ffeeee;">Nothing selected capable of having a turn.</div></div>`); } } else { sendChat('ATT',`/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 ${'&'+'lt'+';'}text${'&'+'gt'+';'}</pre> -- add turns for selected tokens with the supplied text as the value of their turn.</b></div></div>`); } } } }); });
1558301247

Edited 1558340380
David
Sheet Author
Cheers Aaron much appreciated.
1558307221
The Aaron
Roll20 Production Team
API Scripter
No problem!