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

Add text to existing tooltip

Hi, I'm looking at a macro for being able to add text to existing tooltip text rather than over writing the current tooltip text and struggling to think of a way to make this happen eg current tooltip text is "Confused" and I'd like to add "speed -20" for tooltip to read "Confused, speed -20" If this can also be reversed through another macro to get the tooltip back to "Confused" Open to any method of achieving this Many Thanks
1715093434
timmaugh
Pro
API Scripter
You can use a combination of TokenMod and the metascript toolbox to do this... The basic command to append ", speed -20" to the tooltip of the selected token would be: !token-mod --set tooltip|"@(selected.tooltip), speed -20" If you want to first save the existing value of the tooltip, you can do that in a ChatSetAttr call, again using metascripts: !setattr --sel --BaseTooltip|@(selected.tooltip) --silent If the goal is to record the original tooltip, the ChatSetAttr command will obviously need to be run before the TokenMod command line (which would alter the tooltip). Both of the above commands would require the token to be selected, and the ChatSetAttr command line also requires that the token represents a character (since it's modifying an attribute on the character sheet). There might be a time when you need to handle the same process for a token that doesn't represent a character, and/or a time when you don't want to select the token, first. We can do both of those things. No Character Sheet If you're not sure whether the token will have a character sheet attached, you can create a new character called " TooltipMule ", and track the original tooltip for multiple tokens on that sheet !setattr --name TooltipMule --@(selected.token_id)BaseTooltip|@(selected.tooltip)|@(selected.token_name) --silent That would place an attribute on the sheet named for the token's ID plus "BaseTooltip". We have to track it by token ID since each token can have different tooltips, so for our own use (looking at the character sheet with human eyes), we also store the token's name in the "max" value of the attribute. Different Ways of Designating Token You can select a token virtually using SelectManager's {&select} tag. This would mean that you wouldn't have to actually select the token on the VTT. You can do this by name: {&select Bob the Hirsute} ...or by a Roll20 targeting statement: {&select @{target|Choose Token|token_id} } ...or a query: {&select ?{Choose token|Bob|Kraang|Actual Cannibal} } Lots of different ways you can go about getting the right token. If you want to go this route instead of actually physically selecting the token, you just have to append the above syntax tags to the command line... for example: !token-mod --set tooltip|"@(selected.tooltip), speed -20"  {&select Bob the Hirsute} Using a Query for New Tooltip Content If you want to use one command to add to the tooltip, without having to worry about having to set up different command lines for specific text you want to append to the tooltip (ie, one for "speed -10", one for "speed -20", etc.), then  you probably want a query: !token-mod --set tooltip|"@(selected.tooltip), ?{New tooltip content}"  {&select Bob the Hirsute} Conditionally Storing the Current Tooltip If you might apply multiple new snippets to the tooltip, you might only want to store the original tooltip the first time. You don't want to incrementally store "Confused," when you add ", speed -20", but then store "Confused, speed -20" when you add ", temp hp +5". To conditionally run the ChatSetAttr storage command, you can use APILogic (part of the metascript toolbox): !{&if ?{Store current tooltip?|Yes|No} = Yes} setattr --name TooltipMule --@(selected.token_id)BaseTooltip|@(selected.tooltip)|@(selected.token_name) --silent  {&select Bob the Hirsute} {&end} That command uses the TooltipMule character, and adds a {&select} tag to virtually select a token. As you can see, all of these parts are interchangeable. Restoring the Original Tooltip Finally, when  you're ready to restore the original tooltip, you'll use TokenMod again. As before, you can use a {&select} tag to virtually select the token. Then you just have to make sure that you get the original tooltip from wherever you stored it. Here is an example of restoring it from the BaseTooltip attribute on the associated character sheet (while assuming that the token is actually selected on the VTT -- so no {&select} tag required): !token-mod --set tooltip|"@(selected.BaseTooltip)" ...and here is an example of getting it from the TooltipMule character: !token-mod --set tooltip|"@(TooltipMule.@(selected.token_id)BaseTooltip)" Batching Commands To avoid the line-drop bug (where lines of a multi-command macro are randomly dropped and not executed), you can use ZeroFrame batching. That might require small tweaks to the lines, and it might also provide small efficiencies in eliminating repeated verbiage. Since the possible set of ways that you could proceed on this project starts to multiply, it's too much to go into in a post that is already long. If you are worried about dropped lines (having the ChatSetAttr not run to store the original tooltip, but then having TokenMod line modify the tooltip anyway), then choose which of the above approaches would suit you best and post back with your command lines. I can help with the alterations to put them into a single batch command.
Timmaugh, Thanks for the above. I'll try things out over the next couple of days and will let you know how I get on.
Timmaugh, The first command you offered ( !token-mod --set tooltip|"@(selected.tooltip), speed -20" ) was really simple and effective as it allows to continually add further conditions or effects to the tooltip. When I need to remove any I clear the tooltip with  !token-mod --set tooltip| and quick re apply any items I want to retain. Really appreciate your help on this one