#Tooltip Formatting
1 messages · Page 1 of 1 (latest)
Um, vaguely familiar? LOL. But I need to do it for like 100+ spells, so I would need something that I could basically drop it into (hopefully with minimal editing) and then be able to re-paste it as a tool-tip.
Well you can write a macro that will do it for you once you figure out how to make it look good
Hmm, okay. I could probably try to ask ChatGPT to help with the basic CSS/HTML and adjust as needed, so that sounds doable.
Basically you wrap the entire tooltip in <html></html>, sections are <div></div>, tables are <table> and then <tr> for rows and <td> for cells within the row, and close everything with </whatever>
I was originally hoping Word could process the text and then I could paste from there into a the Tooltip and have it look decent, but it didn't do much at all for that.
You define styles like <div style="width:300px; font-size:2em;"> etc
There's a page on the wiki that tells you the most common style parameters that are accepted
Awesome! That's a start, thank you!
Chatgpt could probably get you most of the way there
Then, once you know what it will look like, you'll want to create a macro creating macro that takes data and then outputs them in the fields, and then builds the tooltip for you according to whatever scheme
You can do those purple lines by making a <div> with a top border
I'm not sure what font that is, you'll want to be careful that you don't specify a font that your users might not have or it will look potentially bad
If any of the tooltips need images, that's pretty straightforward as well, the images just need to be on some map as tokens and you just need to know the asset id
I'm guessing shape-shifts and magic are green bc they are some kind of link? That might be harder
Easy to do links that output in the chat but I've never tried that in a macro tooltip
Probably outside of your scope, but I've been using overlays and frames to create hotbars for player classes. The contents of most spell and ability tooltips are stored in a large JSON Object inside of a libtoken's properties, and all images are stored in tables, which the JSON refers to.
I originally made each ability their own macro, but that quickly grew into an absurdly large panel.
The JSON would look something like this:
As for the green links, I imagine you could implement a 'Keyword' search that would automatically replace the word with a link to a specific page.
Just wrapping an <a> element around it with a title would allow a mouseover to provide more detail.
Well but the issue is it would be difficult to click on bc the tooltip shows up when you mouse over the button, and you could do a long delay but that would be annoying
True, frames and overlays would be better suited for browsing
Is the text hardcoded into the tooltip, or can it pull it from some other source, like a table or properties?
`<html>
<div style="
background-color: #dbc385;
width: 300px;
border: 1px solid #dbc385;
border-style: inset;
padding: 0px;
margin: 0px;
">
<div style="
background-color: #FAF9F8;
width: 100%;
border: 5px solid #002a17;
padding: 5px;
margin: 1px;
">
<table style="width:100%;font-size:16pt;font-family:Arial;margin:0px;padding:0px;">
<tr>
<td><strong>Daze</td></strong>
<td style="text-align:right"><b>Cantrip 1</b></td>
</tr></table>
<div style="border-top:2px solid black;padding: 3px 0px 0px 0px;width: 300px;">
<table border="0", bgcolor="#5a0308", style="font-size:13pt;font-family:Century Gothic;font-weight:bold;border-spacing:0px">
<td style="border:3px solid #d9c484;"><font color="white"> Cantrip </font> </td>
<td style="border:3px solid #d9c484;"><font color="white"> Enchantment </font> </td>
<td style="border:3px solid #d9c484;"><font color="white"> Mental </font> </td>
<td style="border:3px solid #d9c484;"><font color="white"> Nonlethal </font> </td>
</table>
<b>Traditions</b> arcane, divine, occult<br>
<b>Cast</b> <img height=13 width=20 src="asset://6d8ac5fce8e04fc97996d921acea5499" /> somatic, verbal<br>
<b>Range</b> 60 feet; <b>Targets</b> 1 creature <br>
<b>Defense</b> Will; <b>Duration</b> 1 round</div><div style="border-top:1px solid black;">
You cloud the target's mind and daze it with a mental jolt. The jolt deals <b>2d4 mental damage</b> with a basic Will save. If the target critically fails the save, it is also <u>stunned 1</u>.<hr />
<b>Heightened (+1)</b> The damage increases by 1d4.
</html>`
It could pull it from somewhere else but I just have it hardcoded in. I have a macro that makes new spells and one of the things it does is make the button
It's very similar to what is output in chat when you push the button, except that there it does the calculations for damage etc.
Yes, I have my buttons doing the same thing, where they take the token's properties (WIS, INT, etc.) and adjust the spell's description accoridngly. Makes it wonky to just paste that in as a a tooltip, though, as it's interpreted a lot differently versus raw MT script.
And those look feaking amazing, btw. 🙂
If you want it to take token properties, you have to do it slightly differently. The whole tooltip has to be string inside {""} and then you can concatenate in whatever variables. I do this for monster abilities so I can turn on the optional "proficiency without level" setting and immediately change all the tooltips accordingly
All that was super impressive, and maybe when I'm more confident I'll endeavor a project like that. But for now, I'm stoked I figured out a lazy way to use @wanton cloud's https://discord.com/channels/296230822262865920/1393552072560873494 Lib by calling a macro with the spell's name and it pops up a frame with what I need to see. It doesn't mimic the DDB layout or anything, but meets my immediate needs.
Just had to add a conditional so that the frame doesn't pop-up if a token is selected, so that I can still easily "cast" by clicking the button, as needed.
Thanks again for showing me how cool it can get with some time/effort (and more CSS/HTML savvy). 🙂
Can you send me an example of what you mean by this? I'm not sure if I just need {" to open and then "} at end, or if there is a macro command (code?) needed to wrap it.
Like let's say you want it to show some saving throw or something and there's a variable called spellDC on the token. Then the tooltip could be {"blah blah blah, save vs DC "+spellDC+". Blah blah blah blah."}
Copy, thanks!
I should make a video of that lib because it's meant to be used as a spell book for the player tokens. It will keep track of spells you have in your book, spells you have prepared, lets you create macro to share or place directly on a token, etc (not that you have to use it this way but it could be used more 🙂 )
That's pretty great. Do the little dots at the left that you can toggle indicate whether it's actually prepared or not?
So would that be similar to how I would want to do something like have a condition run to determine whether the tooltip should continue to the <html> portion or abort and not show the remainder of a tooltip?
Since the following doesn't work (just makes it show the entire tooltip as a huge, ugly text field):
[h,if(getSelected() != ""): abort(0)]
<html>
<style>
.blah blah blah
</style>
<body>
Bladh blah blah
</body>
</html>
Also tried this:
[r: hmtl = "<html> blah blah blah </html>"
But still just dumps entire code block as plain, raw text as the tooltip output.
That one should work… For Swing to process text as html, it must start with exactly six literal characters: <html>. Anything else will be raw text. That’s why tour post from yesterday didn’t work: the <html> was on a new line after the close bracket, which means it has a \n in front of it.
So I’m surprised you hat your html var assignment doesn’t work, unless it has some whitespace in front of it when substituted. I’ll go back and check the code you pasted, but I’m on my phone so it’s kinda hard to read…
I don’t see where you posted any code that uses the html var, so I can’t investigate further. 🫤
I wasn't thinking it needed any code for the tootlip output, as the [r:] should already display the output, no? Was thinking it wouldn't actually need to be called if it was already displayed. Maybe there's a better way I could do that?
I guess I theortically should be able to just use an [h: for the conditional to avoid any output, ala:
[h,if(getSelected() != ""): abort(0)]
And then roll into the output without the variable:
[r:"<html>
<head>
<style>... ... ...
Which I actually just tried and it's still just outputting as a big chunk of raw text to the tooltip window (so, same result as if it was in a variable declaration).
Let me rephrase what I wrote above. Any whitespace prior to the <html> will cause it to be treated as raw text. So if you have a line like, [h: “this is a test”] which is then followed by another line, such as [h: “this is another test”], you now have a newline character between those two commands. That newline character, referred to as \n, will be in front of any output that the rest of the macro produces. If you want that output to be treated as HTML, you need to remove the leading whitespace.
Note that you wouldn’t see that leading whitespace when it is output to the chat window, for example, because the chat window is always HTML and whitespace between and around most HTML elements is ignored when it’s rendered to the screen.
In your last example, try removing the newline character between the [h, if…] statement and the following [r: …] statement. Put them on the same line and the newline character goes away.
I don’t work with tooltips much, but any time I try to build HTML, I generally put it into a variable and then clean up the whitespace before I output the variable. (This also lets me display the HTML itself by replacing all occurrences of < with < so that it displays properly when rendered.)
Hmm, still trying to get it to work. Got rid of all the white spaces, but still not getting the html to display as actual html, just raw text. The conditional is doing "something," though, as when I have a token selected the display is different (still just raw text, but the tooltip output window size is different).
Is your campaign small enough to share? I’d be happy to take a look…
Definitely not, but I feel like I could easily replicate in a fresh one. I'll try to do that this evening and post.