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

[Script] Dialog

1617395985

Edited 1620403501
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Dialog 0.0.6 Code is here Dialog  is a script that makes chat a bit more fun and easier to parse, especially for games that don't use voice. It is token-based, either using selected and targeted tokens or specific token IDs. The basic syntax is: !Dialog --id|token_id [--to|token_id] [--type|type] --message --id|token_id :  Required . Specifies the speaker --to|token_id :  Optional . If a recipient is specified, the dialog becomes a whisper. --type|quote|whisper|emote|emote1|emote2|ooc|desc|language :  Optional . This determines the style of the dialog box to display. If not used, the script assumes an in-character quote. Whisper doesn't actually do anything, but is included as an option for making it plain that a whisper is intended. specifying a  --to|token_id  automatically chooses the whisper style. The language type is a bit more complicated and requires some setup, along with a few more macro variations. It is detailed below. --type|emote1  pulls the background color of an emote box from the token's Aura 1 color --type|emote2  pulls the background color of an emote box from the token's Aura 2 color --message : anything placed after  --  that does not match one of the other tags becomes the de facto message. Token Image:  Clicking on the token image will repeat the last configuration. If you sent an emote, it will send another emote, prompting you for the content. If you sent a whisper, it will send a whisper to the person you were whispering to in that dialog. In this way, two characters who have started a whispered conversation can keep it going by just clicking on their token image in chat. Token Image is omitted on the Description style. Button Line:  There is a line of buttons at the bottom of the dialog that you can use to change the type of dialog. This will also set the token image button to repeat that dialog type. There is no "whisper" button for the reasons below. Button Line is omitted on the Description style. Note about whispers:  Because the API cannot issue an @{target} command, you must initiate a whisper using a macro (a sample is provided below). Once it is established, you can use the token image button. Sample Macros Basic quote: !dialog --id|@{selected|token_id} --?{message|message} Start a whisper: !dialog --id|@{selected|token_id} --@{target|token_id} --?{message|message-id|@{selected|token_id} --?{message|message} Basic Emote: !dialog --id|@{selected|token_id} --type|emote --?{message|message} Basic Description: !dialog --id|gm --type|desc --?{Description|Description} Help:  !dialog --help : displays a help box.  !dialog --languagehelp : displays a help box for the language system below. The syntax additions are detailed below, but include:  !dialog --assign character_id character_id  : Assigns a speaker (first id) as a controller of a language (second id). A prebuilt macro is available in language help below.  !dialog --macro : Generates a user macro or action from the selected language tokens  Language The language feature of Dialog is based on the fact that whispers to a shared character will be seen by all players who are listed as controllers of that character. You can create a simple NPC and name it 'Dwarvish' for example and assign control of it to all players in the campaign who speak Dwarvish. While this is an old trick, Dialog makes it easier and more fun to manage language characters and to speak in the languages. The language feature shares many similarities to the whisper function, but with this difference: no matter who is the speaker, the message is sent from the language character. This ensures that there will be no duplicate messages posted and that a language token image is included to identify the language. An announcement box will precede the dialog, indicating who the true speaker of the message is and what language they are speaking. Only the speaker of the language will see the message. Everyone else will only see the announcement, letting them know the speaker and the language, but not the content. What a speaker sees: What a non speaker sees: Any character who can see the translated message can click the "Respond" button, or click the language token image and submit a response. They will be announced as the speaker, and the process continues. Setting up a language character and token I have included a  dropbox link to some basic SRD language token images . You can make your own or search the marketplace for appropriate images. I plan to have a set available shortly. The process is: 1. Create an NPC and give it the name of a language.  At the bare minimum, it must have the GM listed as a controller, or the GM will not be able to read any language messages. 2. Assign a token to the language.  If you wish, you can put a color value into bar 1 in standard format of #000 or #000000. The language dialog box will then display in this color. You must include the #. This color step is optional. 3. Repeat  for every language in the campaign. Helpful Macros Assign control of a language to a character -  For this it would be helpful to create a page with all of your language tokens together. Example: Place the player token on that page, select it and run: !dialog --assign selected|character_id target|character_id ...following the on-screen prompt to select the target language. If you have a need, you can hard code the character ids. Because of the way whispering, control and chat interact in Roll20, languages are player-based, not character based. So a player cannot have full functionality if they are playing multiple characters who all have different language lists. Create a player language macro -  You can make a macro or token action for the player to run that will provide a drop down list of all of the languages they speak and ask them what they wish to say. Simply select all the spoken languages and run: !dialog --macro The chat will give you the code to copy and paste into a macro or action. Here is an example: !dialog --id|?{Select a Language|Celestial,-MYE-9dZmVhBFXoAWN5Q|Elvish,-MYDyOKLJixapf-XRnk7|Dwarvish,-MYDyOFL-COUk0VBsCP2|Goblinish,-MYDyrM4qVx_p97cfY--} --to|@{selected|token_id} --type|language --?{message|message} Again, because of limitations in Roll20, you cannot have a dropdown with only one entry. So a character must have at least two additional languages for this to work correctly. You can always manually edit it down to: !dialog --id|-MYE-9dZmVhBFXoAWN5Q --to|@{selected|token_id} --type|language --?{message|message} If the only language the character knows is "Celestial". Design Considerations Because Common is... common to almost all characters, I have elected not to consider it a language. Use the quote macro from above to speak in Common. I have not tested this for sheets other than the  D&D 5th Edition by Roll20 Sheet, but I don't think there is any coding specific to that sheet. If you play with another sheet and run into issues, let me know. In the case of D&D, some languages are actually the name of the race. Elves speak elvish, but Orcs speak Orc. Since the language is actually a character, it is a good idea to rename such language to something like "Orcish" so the game does not become confused. NPCs do not need to have languages assigned. They are gm controlled and the script realizes this. The gm can decide on an ad hoc basis if an NPC can understand and respond. Almost all of the css that controls the appearance of the boxes, fonts and buttons is in a block of constants near the top of the script, in case anyone wants to tinker with the defaults.
1617395997

Edited 1620404578
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Changelog: 0.0.2 Fixed issue with whispers not whispering to correct characters. 0.0.3. --to and --from fields now both accept "gm" as a value. In this case, a token image is created to represent the GM, you can replace it in the initial declarations at the top of the script if you prefer another image. 0.0.4 added language support 0.0.5 refined language support, bug fixes 0.0.6 added "desc" message type for descriptions 0.0.7 added --emote1 and emote2 to pull optionally background colors from a tokens Aura colors.
1617396004

Edited 1617595511
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Bugs: Whispers do not go reliably to correct characters Planned: Add in support to use for the shared character/token Language trick here . Add the option to put "gm" in the --to| field to allow a gm whisper.
1617396391
Gold
Forum Champion
Thanks Keith! I've been using ColorEmote API (by The Aaron) for a similar effect, not identical. (I use the settings: Short Form ON, Image Size Colossal, Image order preferences 1st Character Avatar, 2nd Token art, 3rd Player avatar.) I'll be testing this... Dialog API script.
1617397486
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Let me know if you think of anything it needs.
1617422778
vÍnce
Pro
Sheet Author
Also use ColorEmote...  This looks like it does what ColorEmote does with a few extra options.  Cool.  
1617596163
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
0.0.3 --to and --from fields now both accept "gm" as a value. In this case, a token image is created to represent the GM, you can replace it in the initial declarations at the top of the script if you prefer another image:
1617602237

Edited 1617603542
vÍnce
Pro
Sheet Author
Started playing around with this a little.  I like it. Maybe I'm misunderstanding how to initiate a whisper(likely, lol)... but I couldn't seem to get the included sample macro for "Start a whisper" to work properly. !dialog --id|@{selected|token_id} --@{target|token_id} --?{message|message-id|@{selected|token_id} --?{message|message} but I believe the macro below is working for me. !dialog --id|@{selected|token_id} --to|@{target|token_id} --?{message|message} Suggestion;  Would it be possible for a gm to default to "--id|gm" if a token is not selected when triggering the script?
1617642366
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Wow, what an egregious typo! Fixed, thanks for the catch. I was probably editing and failed to noticed that I hadn't fully selected the text I was replacing. Yeah, I think that's possible. Well, it's certainly possible. Easy? I'll find out. :) Any ideas how this could be adapted for the shared character language trick? It should work "out of the box" by just whispering to and from the same "Orcish" or "Elvish" token/character. But it might be nice to include some extra ease of use.
1617650943
vÍnce
Pro
Sheet Author
Thanks Keith.  Normally, the language/character trick works based on the sheet controlled by all players that can control (know) that language, right?  I've never assigned a token to a language/character...  How would !dialog handle that without requiring a linked token?  Maybe add a --lang| option that requires that you enter the language/characters name? I would love to see only "gibberish" if the character doesn't know the language spoken. Lol. You asked for suggestions. ;-)
1617654802

Edited 1617655486
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
I think the easiest solution would be to set up an NPC character for each language (to keep the data footprint small), each with a token that indicates the language. Similar to the current trick, but with a default token. Then add a new message type --type|language. This would do several things: 1) it would be styled differently from a whisper and allow continued conversation like a whisper does. 2) I could put in coding that would ensure that the correct speaker was identified, and the --to field would always remain the language when maintaining a conversation. 3) in addition to the whispered language , it could add a non-whispered message: "Bob says something in Orcish" In fact, if I did step 3, I wouldn't even have to have coding in the message to indicate the speaker.: Public: "Bob says something in Orcish" Whispered to all players controlling Orcish: "I surrender!" The macro could be handled like: !dialog --id|@{selected|token_id} --to|?{Pick a language|Orcish,-123abc|Elvish|-456def...} --type|language --?{message|message} You'd just set it up ahead of time. As a potentially amusing note, if you don't know the language, you could still say something in it, but not see any of the responses.
1617656064
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hmm, if there was a default token for each language used, then text and background colors could be pulled from values entered into the token bars (or defaults, if nothing is entered). You might even be able to get away with font-families, with the script providing a default if none is entered, or exists on the user's computer.
1618003395
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Language enhancement is almost done. It just needs a bit more error catching. And maybe the ability to generate a macro from language tokens, for ease of use. Once it is done, players can specify a language to speak in. That Language token/character will whisper a message to them, but still list them as the speaker. Anyone sharing control over the language token can read the whispers and click a respond button. You can use any token for the language's image (such as a MonsterManual token), but I am working on a Marketplace set of language tokens, for extra snazziness.
1618424264

Edited 1618427901
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Added to the top post, but put here to flag the thread with new content: Language The language feature of Dialog is based on the fact that whispers to a shared character will be seen by all players who are listed as controllers of that character. You can create a simple NPC and name it 'Dwarvish' for example and assign control of it to all players in the campaign who speak Dwarvish. While this is an old trick, Dialog makes it easier and more fun to manage language characters and to speak in the languages. The language feature shares many similarities to the whisper function, but with this difference: no matter who is the speaker, the message is sent from the language character. This ensures that there will be no duplicate messages posted and that a language token image is included to identify the language. An announcement box will precede the dialog, indicating who the true speaker of the message is and what language they are speaking. Only the speaker of the language will see the message. Everyone else will only see the announcement, letting them know the speaker and the language, but not the content. What a speaker sees: What a non speaker sees: Any character who can see the translated message can click the "Respond" button, or click the language token image and submit a response. They will be announced as the speaker, and the process continues. Setting up a language character and token I have included a  dropbox link to some basic SRD language token images . You can make your own or search the marketplace for appropriate images. I plan to have a set available shortly. The process is: 1. Create an NPC and give it the name of a language.  At the bare minimum, it must have the GM listed as a controller, or the GM will not be able to read any language messages. 2. Assign a token to the language.  If you wish, you can put a color value into bar 1 in standard format of #000 or #000000. The language dialog box will then display in this color. You must include the #. This color step is optional. 3. Repeat  for every language in the campaign. Helpful Macros Assign control of a language to a character -  For this it would be helpful to create a page with all of your language tokens together. Example: Place the player token on that page, select it and run: !dialog --assign selected|character_id target|character_id ...following the on-screen prompt to select the target language. If you have a need, you can hard code the character ids. Because of the way whispering, control and chat interact in Roll20, languages are player-based, not character based. So a player cannot have full functionality if they are playing multiple characters who all have different language lists. Create a player language macro -  You can make a macro or token action for the player to run that will provide a drop down list of all of the languages they speak and ask them what they wish to say. Simply select all the spoken languages and run: !dialog --macro The chat will give you the code to copy and paste into a macro or action. Here is an example: !dialog --id|?{Select a Language|Celestial,-MYE-9dZmVhBFXoAWN5Q|Elvish,-MYDyOKLJixapf-XRnk7|Dwarvish,-MYDyOFL-COUk0VBsCP2|Goblinish,-MYDyrM4qVx_p97cfY--} --to|@{selected|token_id} --type|language --?{message|message} Again, because of limitations in Roll20, you cannot have a dropdown with only one entry. So a character must have at least two additional languages for this to work correctly. You can always manually edit it down to: !dialog --id|-MYE-9dZmVhBFXoAWN5Q --to|@{selected|token_id} --type|language --?{message|message} If the only language the character knows is "Celestial". Design Considerations Because Common is... common to almost all characters, I have elected not to consider it a language. Use the quote macro from above to speak in Common. I have not tested this for sheets other than the  D&D 5th Edition by Roll20 Sheet, but I don't think there is any coding specific to that sheet. If you play with another sheet and run into issues, let me know. In the case of D&D, some languages are actually the name of the race. Elves speak elvish, but Orcs speak Orc. Since the language is actually a character, it is a good idea to rename such language to something like "Orcish" so the game does not become confused. NPCs do not need to have languages assigned. They are gm controlled and the script realizes this. The gm can decide on an ad hoc basis if an NPC can understand and respond. Almost all of the css that controls the appearance of the boxes, fonts and buttons is in a block of constants near the top of the script, in case anyone wants to tinker with the defaults.
Would it be possible to add support for GMs using /desc as well? I think this would be nice for play-by-post style games.
1618499782
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Absolutely. I had a feeling I was forgetting a chat mode.
1618504496

Edited 1618504533
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Updated. It was an easy addition. Basic Description: !dialog --id|gm --type|desc --?{Description|Description} Description mode omits the token image and the button line, to keep it in line with the "anonymous" nature of /desc. Code repo and top post have been updated.
Great!
Love this script, keith! Would it be possible to include an option for the emote function to pull an associated color from the token (say Aura 1 or Aura 2) to use as the background for the emote? That type of visual contrast would help my group and me. I get why other modes (whisper, quote) have fixed colors. But emote, it seems to me, needs a bit of customization. Thank you for this lovely script!
1619815073
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Let me give some thought as to the best way to implement this, but I think it's possible.
keithcurtis said: Let me give some thought as to the best way to implement this, but I think it's possible. Great, thank you for considering this request.
1620403363

Edited 1620403849
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Code has been updated . --type|emote  works as before --type|emote1  pulls the background color of an emote box from the token's Aura 1 color --type|emote2  pulls the background color of an emote box from the token's Aura 2 color Give it a try and let me know if it gives you any issues.
1620404409
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Just discovered that I needed to account for the new code in the repeat buttons. It's a little complicated. If you are repeating an emote, it will respect the emote / emote1 / emote2 commands. But if instigating from another type of dialog (say, going from a dialog or ooc to a remote), it will default to the default emote style. The script has no way of knowing an individual user's preference.
keithcurtis said: Just discovered that I needed to account for the new code in the repeat buttons. It's a little complicated. If you are repeating an emote, it will respect the emote / emote1 / emote2 commands. But if instigating from another type of dialog (say, going from a dialog or ooc to a remote), it will default to the default emote style. The script has no way of knowing an individual user's preference. Heh, was just coming on here to comment about the repeat buttons. The emote2/1 behavior works great, but when you click the emote button from the buttons under the character, it defaults to the standard emote without aura1 or aura2.  Edit: I don't know how complicated or feasible it would be to have a prefs menu, where you could permanently set what type of emote is triggered? And could accommodate other options in future? Just a thought.
1620405783

Edited 1620405873
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
So far, the script doesn't take any advantage of the state variable (the persistent code that would allow that sort of customization). That's a bit more complicated a change than this was, but it does offer some possibilities. If you want to hard code it for the time being, change line 420: let emoteCommand = `!dialog --id|${fromID} --type|emote --?{Emote|Emote}`; to  let emoteCommand = `!dialog --id|${fromID} --type|emote1 --?{Emote|Emote}`; or  emote2 , your preference.
keithcurtis said: So far, the script doesn't take any advantage of the state variable (the persistent code that would allow that sort of customization). That's a bit more complicated a change than this was, but it does offer some possibilities. If you want to hard code it for the time being, change line 420: let emoteCommand = `!dialog --id|${fromID} --type|emote --?{Emote|Emote}`; to  let emoteCommand = `!dialog --id|${fromID} --type|emote1 --?{Emote|Emote}`; or  emote2 , your preference. Ah, thanks for the hard code help. I'll change that for now so my players don't get confused. :) Really looking forward to how this script develops, keith! Lots of possibilities. Would love to see more customization options for how it looks (borders, shadow, font, etc.). But it's already great.
1620421683

Edited 1620421768
timmaugh
Pro
API Scripter
...Here he comes, sweeping in with the meta-script interaction no one asked for... =D If you have the meta-toolbox script " Fetch " installed, you can change the noted line to this: let emoteCommand = `!dialog --id|${fromID} --type|emote@(${fromID}.emotetype) --?{Emote|Emote}`; That inserts a Fetch construction to look for a character attribute named "emotetype". If you want to use the default coloring, either don't have the attribute or have it be empty. (Without a default value supplied for the Fetch, it will return a 0 length string if it doesn't detect the attribute/thing you're asking for, leaving you just with the word "emote" in that position.) If you want aura1, put a 1 in the attribute. For aura2, a 2. That way, if people want to customize their own character's coloration, they can just add this attribute to their sheet and put in the appropriate value.
1620423197
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Jay R. said: Ah, thanks for the hard code help. I'll change that for now so my players don't get confused. :) Really looking forward to how this script develops, keith! Lots of possibilities. Would love to see more customization options for how it looks (borders, shadow, font, etc.). But it's already great. I put about 90% of the css declarations for boxes, fonts etc. up at the top of the script in a big block. Feel free to experiment. :)
1620423229
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
timmaugh said: ...Here he comes, sweeping in with the meta-script interaction no one asked for... =D Nobody expects the Metamancer!
1624577991
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Keeping this thread alive, since I have some changes coming up.