Thanks for sharing this tool! I did encounter one issue that I doubt most will have: If I had a variable with a valid tooltip name and referenced it in text it'd try to change the variable name in the text.
E.g.
inline_tooltip_data ("elf"....
default male_elf_name = "Cedric"
player "So you're [male_elf_name]?" <---- Will try to replace elf with {a=tooltip:elf}elf{/a}
My fix was to change test_surrounding_index() to check for a smaller list of punctuation instead of all of string.punctuation.
define accepted_punctuation = "!\"#$%&'()*+,-./:;<=>?@\\^`~"
Viewing post in Ren'Py Inline Tooltips comments
Hiya, sorry for such a late reply but thanks for pointing this out! I have updated the file to apply substitutions of variables before it applies the tooltips which should also address this problem for anyone who downloads it in the future - and allows variables to also benefit from the tooltips as well. I really appreciate the report!
I'm glad to see you're still working on this, as it's fantastic. I'm not sure if you already covered this, but another issue I've been bashing my head against is keeping it from replacing correct keys in nvl choice menu (and possibly the normal menu, who knows).
It wouldn't be so bad if it wasn't a bit janky (hovering over the key in a choice button doesn't always show the tooltip), but I'd still prefer it not to replace keywords found in the nvl choice menu.
Any idea on how I could go about this? Thanks!
I've been bashing my head up against the wall trying to get it to work with choices too haha, then trying to exclude certain menus, but I can't quite figure it out.
As a work around, I've updated the file with a text tag you can use to exclude the individual keywords from the tooltip system. So if you update inline_tooltip.rpy, hopefully you can just:
menu:
"Something something {notooltip}elf{/notooltip} blah blah":to have certain phrases excluded in menus. A hacky work around, but it does work in my testing. Hopefully this works alright for your purposes, even if its a pain to markup.
Ah I see! Well, this works perfectly as a workaround, so I'm more than happy. Thank you so very much. I didn't want to bother you and tried to fix it myself, but I'm only good at scavenging others' code and smacking it a few times using minor changes at the very best, lol.
Thanks a ton again! I'll edit my post and report back after some quick tests.
EDIT:
It seems to throw an error with other text tags in the menu option like bold tags, but works otherwise. I tossed the error in another post if it helps.
I figured out the problem, been tinkering for a solution. It doesn't seem to like escape characters such as [[ which allows you to use brackets in strings.
Edit:
Got it to work. I just commented out
text = renpy.substitute(text)
inside replace_tooltip(). It's still ignoring pieces surrounded by the new tag, correctly displaying the usual tooltips, and no longer throwing an error for [[. Not sure if this will bite my arse down the line but it seems to be working great for the moment.
Sorry for the trouble and thank you for all your help and work!