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

Rollable tables in tooltips

1694963545

Edited 1694963674
I thought a great way to get some background chatter, descriptions and etc. is through Token Tooltips. And I think it would be a cool idea to have tooltips choose an option randomly from a table, so that while players are clicking around on the map they can hover over NPCs having randomly generated conversations.  Haven't found a way to do this, but am curious to know if anyone has made a script which could achieve this.
1694967684
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Jesse! It would be super-easy to do this with the  Token Mod  script: !token-mod --set tooltip|"[[1t[Stock-Phrase-Table]]]" That would generate a phrase from your rollable table and put it into the selected token's tooltip. However, if you had multiple tokens selected, it would generate one phrase and apply it to all tokens. You could set it up so that one command would truly iterate separately for all tokens with the use of a couple more scripts, SelectManager , to iterate for each token, and ApiLogic , to defer the roll until the API needs to use it. !forselected token-mod --set tooltip|"[\[1t[Stock-Phrase-Table]]\]" All of these scripts are available in One Click installation.
So i tried entering both of those in with TokenMod installed and it didn't seem to do anything.   Only gives me that result.
1694973383
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Did you also add  SelectManager , and   ApiLogic? They are needed for the iteration. You might also need the Zero Frame Mod to control which order these two scripts are loaded. I have flagged the author of those scripts, Timmaugh, about this thread, and hopefully he can give some insight. I did test the macro over in my game, and it worked, so there is likely something about the script installs that is the issue. If you want to do independent research, the method for deferring inline rolls (so they roll differently each time the command is executed) is explained here , but the post is describing a situation slightly more complicated than what you are attempting here, involving a macro mule you don't need.
1695001608
timmaugh
Pro
API Scripter
Hey, Jesse... A couple of things jump out at me. First, it looks like you entered the command line Keith provided you right into the tooltip instead of the chat. Commands that begin with a bang ("!") are intended to go through the chat interface so that the scripts can take action. In this case, the idea would be to select the tokens for which you wanted to change the tooltip, then you'd run the command. At the end of it, TokenMod (with the help of the metascripts) would have given all of the selected tokens a new tooltip. To be clear, the tooltip assigned would not change every time a player interacted with the token... but only the next time you changed it -- which you could do manually or by entering the same command line into chat. Now, about the command line itself, Keith reports that it works... I would have to do a bit more testing because I'm not sure that it's supposed to. =D Keith is actually using ZeroFrame deferrals (the backslashes), but I would expect those to have been spent by the time forselected catches the message (it's a bit down in the weeds of the timing of things, but forselected runs at standard-script speed, and by then ZeroFrame and the metascripts are finished). At the very least, I would worry that those ZeroFrame deferrals *could* be spent by the time forselected got a hold of the message, so just to be sure of how things would run, I'd probably approach this command line with forselected deferrals: !forselected(^) token-mod --set tooltip|"[^[^1t[Stock-Phrase-Table]^]^]" forselected deferrals are user-chosen characters in the parentheses immediately following "forselected"... then those characters are used to hide the text formations that would let Roll20 recognize and parse standard syntax -- like inline rolls. SelectManager (which the forselected handle belongs to) will remove the deferral characters from the outbound command line before it dispatches it, so the inline roll will be undetected and unresolved. SelectManager will take that command line and issue it for each individual token; since each command will have an unresolved inline roll, the roll will be made new each time, and an individual result obtained from your table. The above option would only require SelectManager and TokenMod, but the other metascripts you have can still be good solutions for different circumstances. Bonus If you don't want to select the tokens manually, you could add a {&select} statement from SelectManager to obtain them dynamically. You would just need a method of designating them all. For instance, this would get you all npcs: {&select *, +npc} ...or in the full command line: !forselected(^) token-mod --set tooltip|"[^[^1t[Stock-Phrase-Table]^]^]"  {&select *, +npc} That might get more tokens than you want, so you'd perhaps want to identify the "chatty" ones in another way... with a keyword in the gm notes field (like "chatty"): {&select *, +notes ~ chatty} ...or a bar3 value of "chatty": {&select *,+bar3 = chatty} (Note, these should work, but I have gotten a report of a problem with this part of SelectManager, so I'm looking into it. But very shortly, this should be working exactly as described.)
Update: It works! Sort of.  I installed the additional API's and so now an option from the table gets selected and moved into the tooltip, but like Tim said, doesn't change every time.  Will try Tim's bonus method, but i'm wondering if it's possible to run a macro through a tooltip. I figure [[1t[table-name]] in the tooltip could be a simple way to get it to read off the table randomly each time.
1695047520
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
That last method won't work. Rolls are parsed when they are sent to chat. There's nothing that would trigger the roll.  Timmaugh and I have discussed this. Mine seems to work due to also having Zero Frame installed, but does have potential for failure in some circumstances. I'd tend to trust him, since he wrote all of the metascripts.
Ah no worries then. Thanks for the help.