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

Using the Tracker with words instead of numbers

December 15 (7 years ago)
DK Heinrich
Marketplace Creator
Sheet Author
Is there a way to have a macro (or script) that will allow players to put themselves into the tracker with a word next to thier name instead of a number?

I know you can manually change it, but trying to speed up this process.

Reason: Shadow of the Demon Lord uses a very open initiative system - players decide to go FAST (act or move) or SLOW (act and move). Who goes when in each phase is up to the players. Right now we can use 1 for fast and 2 for slow, but if having words populate the tracker it would be that much easier.

December 15 (7 years ago)
The Aaron
Pro
API Scripter
It would be a pretty simple API script. I’ll see if I can throw something together when I’m home...
December 16 (7 years ago)

Edited September 30 (1 year ago)
The Aaron
Pro
API Scripter
Here's a first pass solution.

Use:
!att Text
Adds the selected tokens to the turn order and sets their value to whatever comes after the !att command.  You can select as many as you like and run it.  Players can use it.  It always adds the turns to the top, so you'll have to sort it afterwards.  Also, it doesn't check if a token is in the turn order currently, so you can get duplicate entries.  Hope that helps!

Code  (AddTextTurn):
on('ready', () => {

  const processInlinerolls = (msg) => {
    if(msg.hasOwnProperty('inlinerolls')){
      return msg.inlinerolls
        .reduce((m,v,k) => {
          let ti=v.results.rolls.reduce((m2,v2) => {
            if(v2.hasOwnProperty('table')){
              m2.push(v2.results.reduce((m3,v3) => [...m3,(v3.tableItem||{}).name],[]).join(", "));
            }
            return m2;
          },[]).join(', ');
          return [...m,{k:`$[[${k}]]`, v:(ti.length && ti) || v.results.total || 0}];
        },[])
        .reduce((m,o) => m.replace(o.k,o.v), msg.content);
    } else {
      return msg.content;
    }
  };

  on('chat:message',(msg) => {
    if('api' === msg.type) {
      if(msg.content.match(/^!att\b/) ){
        let who=(getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname');

        let text = processInlinerolls(msg).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, _pageid: t.get('pageid')}))
            .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>`);
        }
      }
    }
  });
});

Edit 2023-09-30: Fixed for breaking changes in TurnOrder.
December 17 (7 years ago)

Edited December 17 (7 years ago)
DK Heinrich
Marketplace Creator
Sheet Author
Installed.
Tested.
Works Perfect!

Thank you sir! 
December 17 (7 years ago)
The Aaron
Pro
API Scripter
Sweet!  Let me know if you need aught else with it.