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

Token Tooltip

I love the token tooltip functionality to add quick notes to tokens without having to open the tokens sheet.  However, this is a problem if players are mousing over dark areas of the map and happen to hover over a token they cant see.  BOOM...there's a shiny tooltip for them to see and the surprise is ruined.  We need a way to show the tooltip only to the GM if we want.
1635912284
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Until such a feature is offered, the best you can do is put such tokens on the gm layer. As long as you are on  the gm layer, only you can read them.
Ehh....I just scrapped the tooltips.  It's a bit of a pain to go back and forth to different layers when its not necessary.  Seems like this would be an easy implement.  Very similar to the presently available feature of making token names, bars visible to players, GM.  I know these guys are busy, but it's a nice feature that suffers from a single flaw.
1635971967

Edited 1635972081
Finderski
Pro
Sheet Author
Compendium Curator
Can tool tips contain "links" to attributes? For example, can we @ an attribute and have the value of that attribute appear in the Tooltip? Edit: Nope... :(
1635983487
Andrew R.
Pro
Sheet Author
No, but I used TokenMod to put a tooltip on my monster tokens to ease my 13th Age Glorantha game. I posted it in the TokenMod thread this week. 
1636142004
David M.
Pro
API Scripter
Finderski, this sounded like a fun project so I took a swing at it. This script ties the token tooltip to one or more character attributes and updates the tooltip when attributes are changed or added. How it works: Add a line in the gmnotes field of a token that represents a character. It should be its own line, with a format like this: tooltip: someValue where someValue is a string that contains one or more references to an attribute that exists on that character. Examples: tooltip: @{myAttr}                    //will add the value of the "myAttr" attribute to the tooltip tooltip: hp:@{hp}/@{hp|max}            //if hp were current=7 and max=22, the tooltip would read "hp:7/22". Note everything but the attributes are just treated as text Since the gmnotes of the token is used, you could have multiple tokens representing the same character display different tooltips. Note 1: If the script is unable to find the [case-sensitive] attribute listed in gmnotes, it will display "undefined" in the place of the attribute in the tooltip string. E.g. if you wrote "tooltip: hp:@{hp}/@hp|maxgfkj}"  it would result in a tooltip of "hp:7/undefined" Note 2: the script currently only updates the tooltip when attributes are changed or added. The easiest way to trigger the initial update is if you have a linked token bar value. Change it once and back again to trigger the tooltip. I should probably put in a manual command, but it's really just a proof-of-concept script at the moment.  Note 3:  the script registers itself to the ChatSetAttr and token-mod scripts, so changes made to attributes or linked bar values from either of these scripts will trigger the tooltip update. If these scripts are not installed, you will get a chat message when the sandbox loads and tooltips will only update when manually changed. Note 4:  the api does not alter the "show tooltip" checkbox, but will honor whatever setting the token has Note 5:  In my admittedly minimal testing, I haven't noticed an uptick in lag when creating characters, etc., but this is entirely possible. This is the first time I have done anything with attribute events. There could also be horrible conflicts that have yet to be discovered. If you start noticing issues, just delete it and burn it with fire! Here's the script: const ToolTipAttr = (() => { const scriptName = "ToolTipAttr"; const version = '0.1'; const checkInstall = () => { log(scriptName + ' v' + version + ' initialized.'); }; const handleAttrChange = function(obj, prev) { const decodeUnicode = (str) => str.replace(/%u[0-9a-fA-F]{2,4}/g, (m) => String.fromCharCode(parseInt(m.slice(2), 16))); let charID = obj.get('_characterid'); let char = getObj('character', charID); if (char) { let toks = findObjs({ _type: 'graphic', represents: charID }); if (toks.length > 0) { let attrs = findObjs({ _type: 'attribute', _characterid: charID }); if (attrs) { toks.forEach (tok => { let gmNotes = unescape(decodeUnicode(tok.get('gmnotes'))); let notesArr = gmNotes.split('</p>').map(e => e.replace('<p>','')); if (notesArr) { let tooltipLine = notesArr.filter(s => s.toLowerCase().includes('tooltip:'))[0]; if (tooltipLine) { let placeholderArr = tooltipLine.match(/@{(.*?)}/g); //returns array [@{attr1}, @{attr2}...] let tooltipStr = tooltipLine.split('tooltip:')[1].trim(); //returns the structure of the text to be in tooltip, with placeholders e.g. "@{hp} / @{hp|max}" let attrNames = tooltipStr.match(/(?<=\{).+?(?=\})/g); //returns an array of attributeNames between {}, e.g. [hp, hp|max] if(attrNames) { attrNames.forEach((name, i) => { let currentOrMax = 'current'; if (name.toLowerCase().indexOf('|max') > 0) { name = name.toLowerCase().split('|max')[0]; currentOrMax = 'max'; } let attribute = attrs.filter(a => a.get('name')===name); if (attribute.length > 0) { tooltipStr = tooltipStr.replace(placeholderArr[i], attribute[0].get(currentOrMax) || 'undefined'); } else { tooltipStr = tooltipStr.replace(placeholderArr[i], 'undefined'); } }); tok.set('tooltip', tooltipStr); } else { tok.set('tooltip', 'undefined'); } } } }); } } } } const registerEventHandlers = () => { //manual change of attribute on('change:attribute', handleAttrChange); on('add:attribute', handleAttrChange); //register this script to ChatSetAttr try { ChatSetAttr.registerObserver('change', handleAttrChange); } catch (error) { sendChat(scriptName, `/w gm Unable to register ${scriptName} to ChatSetAttr. Install ChatSetAttr for full functionality`); } //register this script to TokenMod to handle linked bars/attributes if('undefined' !== typeof TokenMod && TokenMod.ObserveTokenChange){ TokenMod.ObserveTokenChange(function(obj,prev){ let attr; if(obj.get('bar1_value') !== prev.bar1_value && obj.get('bar1_link') !== '') { attr = getObj('attribute', obj.get('bar1_link')); } else if(obj.get('bar2_value') !== prev.bar2_value && obj.get('bar2_link') !== '') { attr = getObj('attribute', obj.get('bar2_link')); } else if(obj.get('bar3_value') !== prev.bar3_value && obj.get('bar3_link') !== '') { attr = getObj('attribute', obj.get('bar3_link')); } if (attr) { handleAttrChange(attr, {}) } }); } else { sendChat(scriptName, `/w gm Unable to register ${scriptName} to Token-mod. Install Token-mod for full functionality`); } }; on('ready', () => { checkInstall(); registerEventHandlers(); }); })();
1636153638

Edited 1636153939
vÍnce
Pro
Sheet Author
@David Just did a real quick test and I can't seem to get any output... ;-( Installed the script and it shows it's running in the api log, used a linked token, enabled show tooltip,added a line to the token's gmnotes, "tooltip: hp:@{hp}/@{hp|max}"   hp is linked already and works accordingly and I've changed values to trigger/initiate. Hovering over token doesn't show anything though. No api log errors posted. I can type something in the tooltip and see it on hover, so it seems the tooltip is working. Are there any dependency scripts needed?  Thoughts? TIA
1636156405
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
What a cool idea!
1636171140
Finderski
Pro
Sheet Author
Compendium Curator
What keithcurtis said...thanks. I'll give this a go... :)
1636176173

Edited 1636176407
David M.
Pro
API Scripter
EDIT, I just noticed the "selected" in your gm notes. Try just using @{hp}, etc. Also, make sure the "show tooltip" checkbox is manually checked. As written, an attribute (any attribute) needs to be changed (or added) to trigger the tooltip generation. I should probably have put a token change (tooltip property) trigger in there as well so that the tooltip would immediately "link" :/ I can mess with it some more tomorrow pm (EST)
1636178727
vÍnce
Pro
Sheet Author
David M. said: EDIT, I just noticed the "selected" in your gm notes. Try just using @{hp}, etc. Also, make sure the "show tooltip" checkbox is manually checked. As written, an attribute (any attribute) needs to be changed (or added) to trigger the tooltip generation. I should probably have put a token change (tooltip property) trigger in there as well so that the tooltip would immediately "link" :/ I can mess with it some more tomorrow pm (EST) Thanks David. My bad. I actually added "selected|" trying different things to get it to trigger.  It's still plays dead for me with or without "|selected". Show Tooltip box was manually checked.  Not sure if it matters; tested with FF on the Dev No worries. 
1636181535
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
For some synergy with Supernotes, which can also make heavy use of the token gmnotes field, be aware that the latest version will automatically hide anything from someone other than the GM if it is below a line that is exactly five dashes. So a note field that said: Public info that you want anyone to be able to read More public info ----- Gm secret notes tooltip: someValue Will not display anything below the dashes if a player calls the note. In case this functionality is needed for a particular use case.
1636195017

Edited 1636195033
David M.
Pro
API Scripter
Vince, I am able to replicate the non-functionality on the Dev server. After a bit of console logging in a Dev game, it looks like the script does all of the proper parsing and such, but fails silently at the last step of setting the tooltip. It appears that the new "tooltip" property of the token has not been exposed to the api in the Dev server. To further test, I manually made a tooltip and logged all the token properties in the api console. "tooltip" is not there.  Let me know if you have any issues on the Prod server, though.
1636213421
vÍnce
Pro
Sheet Author
David M. said: Vince, I am able to replicate the non-functionality on the Dev server. After a bit of console logging in a Dev game, it looks like the script does all of the proper parsing and such, but fails silently at the last step of setting the tooltip. It appears that the new "tooltip" property of the token has not been exposed to the api in the Dev server. To further test, I manually made a tooltip and logged all the token properties in the api console. "tooltip" is not there.  Let me know if you have any issues on the Prod server, though. I thought this might be the case.  Thanks David.  I'll move this over to Prod and I'm sure I won't have any issues.  Looking forward to putting this script into action! <soapbox> One would hope that the "DEVELOPERS" server would match Production's base functionality for testing purposes, but alas, IME, the Dev has been unreliable as a testing environment... Ugh.  It's no wonder that many of the updates first tested on the Dev and are later pushed to Production suddenly have BIG issues and must be rolled back or given "hot mess fix".  ;-( </soapbox>
keithcurtis said: Until such a feature is offered, the best you can do is put such tokens on the gm layer. As long as you are on  the gm layer, only you can read them. One thing I would like to add is that primarily (I am assuming) is that this feature is aimed for DM's so how comes if you have a token on the GM layer with a tool tip, its only viewable when on the GM Layer. Really there needs to be a Player/GM Tool tip option
1637351897
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Unfortunately, the feedback thread was closed. My suspicion is that this feature was a side project that got installed but is not due for updates. But that's just a personal guess.
keithcurtis said: Unfortunately, the feedback thread was closed. My suspicion is that this feature was a side project that got installed but is not due for updates. But that's just a personal guess. Shame.  Where do we get to make these feedback suggestions?
<a href="https://app.roll20.net/forum/post/10421785/tooltips-can-now-be-added-to-tokens-slash-cards" rel="nofollow">https://app.roll20.net/forum/post/10421785/tooltips-can-now-be-added-to-tokens-slash-cards</a> <a href="https://app.roll20.net/forum/category/385189" rel="nofollow">https://app.roll20.net/forum/category/385189</a>
keithcurtis said: Unfortunately, the feedback thread was closed. My suspicion is that this feature was a side project that got installed but is not due for updates. But that's just a personal guess. Looks like there were plenty of requests for the "DM only" function.&nbsp; Would be great if they implement it.
Shane B. said: keithcurtis said: Unfortunately, the feedback thread was closed. My suspicion is that this feature was a side project that got installed but is not due for updates. But that's just a personal guess. Looks like there were plenty of requests for the "DM only" function.&nbsp; Would be great if they implement it. They really should. I understand with a pro membership you can do quite s bit, but for us plus plebians we can only beg and hope.
1637552209
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
There are some issues with Tooltips that Pros would like to see resolved too (scripting deficiencies), believe me. :)