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

Exhaustion Level and Token Marker

Hi y'all great scriptomancers !  Is there a way to have an automation in putting a special token marker whenever there's a event change on the 5e character sheet.  I.E.: If I (or players) set the exhaustion level to any value, then set the corresponding status marker and a corresponding number to a token. It would i guess require a on-change event listener so that when the exhaustion level is different from 0 or null then it ould automatically set a token marker A good addition would be to set a hoverable tooltip copying the effects listed in exhaustion_1 and higher when different from 0 to the token too. I have the theory, and i'm  still totally unable to prgram this haha ! Thanks for any help 
1671645650
The Aaron
Roll20 Production Team
API Scripter
Totally Doable.  This script will do it automatically for the DnD 5e by Roll20 Character Sheet.  It's using the half-haze marker, but you can edit line 2 to set whatever marker you want.  I also added a command that will go through and update all tokens with the current exhaustion level: !update-exhaustion Useful for if the levels were changed while the Mod Sandbox was down, or changed via a script, or you newly linked tokens to characters, etc. Script: on('ready',()=>{ const MARKER = "half-haze"; const AdjustExhaustion = (obj)=>{ if('exhaustion_level'===obj.get('name')){ let level = Math.floor(Math.min(Math.max(Number(obj.get('current')),0),9))||false; let queue = findObjs({type:'graphic',represents:obj.get('characterid')}); const burndown = ()=>{ let g = queue.shift(); if(g){ g.set(`status_${MARKER}`,level); setTimeout(burndown,0); } }; burndown(); } }; on('change:attribute:current',AdjustExhaustion); on('chat:message',msg=>{ if('api'===msg.type && /^!update-exhaustion(\b\s|$)/i.test(msg.content) && playerIsGM(msg.playerid)){ let who = (getObj('player',msg.playerid)||{get:()=>'API'}).get('_displayname'); let queue = findObjs({type:'attribute',name:'exhaustion_level'}); const burndown = ()=>{ let a = queue.shift(); if(a){ AdjustExhaustion(a); setTimeout(burndown,0); } }; burndown(); } }); });
That's perfect !!! it looks so easy, though i know it needs a great brain ! My respects !