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

(Fix of The Aaron's GM Notes) Players can now only whisper themselves the token's GM Notes

I spent most of today puzzling over how to change GM Notes to allow players to send token descriptions to themselves in chat, but not to everyone (it can be really spammy). I did a lot of google searching but couldn't find the code for how to do it so pieced it together myself. I know this is a very simple change for some of you who know Javascript, but it really stumped me for a while. I figured I would share it in case anyone else is ever searching in the future. Thank you to The Aaron for writing this script in the first place! Just add this to the end of the code Aaron shared (mind your brackets and parenthesis): else if('api' === msg.type && cmdRegex.test(msg.content) && !playerIsGM(msg.playerid) ){ let match=msg.content.match(cmdRegex), output = match[1].length ? ("/w \"" + msg.who + "\" ") : '', regex; _.chain(msg.selected) .map( s => getObj('graphic',s._id)) .reject(_.isUndefined) .reject((o)=>o.get('gmnotes').length===0) .each( o => { if(regex){ let lines = _.filter( getLines(decodeURIComponent(decodeUnicode(o.get('gmnotes')))), (l) => regex.test(l.replace(/<[^>]*>/g,'')) ).join('<br>'); sendChat(o.get('name'), `${output}${lines}`); } else { sendChat(o.get('name'), `${output}${decodeURIComponent(decodeUnicode(o.get('gmnotes')))}`); } }); } Now when players type !wgmnote or press the Macro button for it, the GM Notes always go to them and don't clutter the chat. If you don't care about preventing non-GM players from send the notes to everyone, you could just remove the playerIsGM condition from the original script, and change the output to send to msg.who instead of the /w gm that is currently there.  Not directly related to the script, but in terms of how I used this: I built an interactive world map that gives players different access to location information. I created a map pin token for each location on the world map, and gave players control of the token according to whether or not their character was familiar with it. Players who don't have control of the token can see it on the map, but they can't select it to trigger the GM Notes script. This can quickly get confusing with a lot of pins, so I added a small aura to all pins and set the permissions of the aura to Edit only. Setting the aura to Edit means players will see an aura around any tokens they can control, and differentiate between pins where they can view the information and pins they don't have access to. Then players simply select a token they have access to and type !wgmnote or press the Macro button for it, and they are sent the GM Notes by whisper in chat.  I also used The Aaron's MapLock script to prevent people from accidentally moving the tokens to the wrong place (important on a map). I think this is a pretty nice use of it (thanks to Xiphias for the initial clues about this use case). Hope it helps someone else. :)
1587949388
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
You might find something useful in my branch of that script, Supernotes .