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 .
×

TokenMod: Reusing Attributes

1595708109

Edited 1595708240
I am trying to implement a hiding action for enemy characters using TokenMod. The macro I've got set up rolls Stealth for the token and stows that value in bar3. It works well enough, but I would like to have some way for my players to tell whether their perception allows them to see the hiding enemy or not. I realize that I could expose the bar to the players but for readability I would prefer to handle it another way, with the DC for the enemy's stealth clearly visible to the players. One that came to mind was creating custom status markers and setting them like set statusmarkers|="hidden{bar3_value}", or setting name|"DC{bar3_value}" and making the nameplate visible to the players. I have tried to achieve this three ways: By setting bar_value using token-mod, and trying in the same --set or subsequent --set operations to access that 'bar3_value' variable. Can't figure out whether that's possible, or what the syntax would be. By running a follow-up command to simply --set name|@{selected|bar3}. That will always give the value that bar3 was prior  to running the macro, but not the updated value. Using !delay and then running the --set name, but it seems that compatibility with token-mod has been broken for some time. Any ideas on how I can achieve this? Below is the macro code I'm playing with: !token-mod {{ --set statusmarkers|=ninja-mask bar3_value|[[1d20+@{selected|npcd_stealth}]] --set name|"DC{bar3_value}" # This variable does not get expanded the way that it does in the --report string below and sets the name to the raw string # @{selected|bar3} comes closer but provides the bar3 value from prior to macro run --report gm|"{represents} Stealth roll: {bar3_value}" }} I just need some way to access that variable, but I'm not sure whether it's a problem with my syntax or the name field simply doesn't support that expansion in the token-mod script. I appreciate any guidance!
1595725121
The Aaron
Roll20 Production Team
API Scripter
Unfortunately, that's not easily possible with TokenMod.  It's a good idea to extend the same formatting options in reporting to other text fields, and I'll add that to my board. In the mean time, here's a short little script that does all the things you want, with the added benefit of individual rolls for each creature and creature type: !sb3n code: on('ready',()=>{ on('chat:message',msg=>{ if('api'===msg.type && /^!sb3n(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let notes = []; (msg.selected || []) .map(o=>getObj('graphic',o._id)) .filter(g=>undefined !== g) .map(o=>({token: o, character: getObj('character',o.get('represents'))})) .filter(o=>undefined !== o.character) .forEach(o=>{ let sb = randomInteger(20) + (parseInt(getAttrByName(o.character.id,'npcd_stealth'))||0); o.token.set({ showname: true, showplayers_name: true, bar3_value: sb, name: `DC${sb}`, statusmarkers: 'ninja-mask' }); notes.push(`${o.character.get('name')} Stealth roll: ${sb}`); }); sendChat('',`/w "${who}" <div><ul>${notes.map(n=>`<li>${n}</li>`).join('')}</ul></div>`); } }); }); Output:
Haha Aaron, thanks so much for the assist! This is excellent. I really appreciate your help here and, of course, all of your other contributions to this community. Cheers and thank you again!
1595775083
The Aaron
Roll20 Production Team
API Scripter
No problem. =D