
Here is a script that will build chat menus for any sheet, if the sheet designer made sure to give each button a unique name. (The script code is in the second post.)
I've only tested it on the Pathfinder by Roll20 sheet, and my own homebrew sheet, but in principle it should work for any sheet if the buttons are named properly.
It uses the standard default roll template for now, but i have ideas on how to support individual sheet's rolltemplates. Here's an example output:
The script is in the next post. Here's how you use it:
An Example Command
!chatmenu @{selected|character_id} @{selected|character_name}'s Chat Menu --title:Weapons --repeating_weapons|weaponName|btnWeapon --title:Skills --Acrobatics|Bluff|Climb|Diplomacy|Tumbling
Beginning The Command
!chatmenu id header
!chatmenu @{selected|character_id} @{selected|character_name}'s Chat Menu
You must supply an id - selected is a good way to get it.
chatmenu, id, and header must be separated by spaces, but header can contain spaces. In the above example, the menu will have as header: @{selected|character_name}'s Chat Menu
Title
You can supply a title, in the format
--title:A title
--title:Weapons
--title:Social Skills
When you supply a title, you create a menu group, that contains everything following, up to the next title. In the screenshot above, Attacks, Abilities, Spells, and skills were created using a title.
It must begin with --title: and anything after that becomes the title, up to the next --.
Repeating Sets
You can include one or more repeating sets. The menu will generate a button for every item in the set.
--repeating_section|label|button
--repeating_weapons|weaponName|btnWeapon
Any section beginning with --repeating_ will be treated as repeating section.
The label is the name of the attribute in the repeating set that contains the item's name.
The button is the name of the button, without the roll_ part.
You can find the name of a button by dragging it to your macro bar. It'll look something like this:
You just need the bit I've highlighted above.
Active / Prepared
You can include an optional 4th parameter, like so
--repeating_spells|spellname|btnspell|prepared
This must be the name of an attribute used to show whether an item is equipped, a spell isn't prepared, or similar. the attribute will be checked, and if it doesnt exist or has a value of 0, the item wont be displayed.
Other Attributes
You can also include lists of attributes that aren't in repeating sets. If you have a section that starts with -- and isnt a repeating section or a title, it will be treated as a list of attributes.
Use this format:
--Acrobatics|Bluff|Climb|Diplomacy|Tumbling
--Acrobatics,skill_acrobatics|Bluff,skill_bluff|Climb,skill_climb|Diplomacy,skill_diplomacy|Tumbling,skill_tumbling
.If the button name and label are the same, you can write it once (as in the first example).
If button name and label are different, you need to separate them with a comma.
You can include a third parameter for checking whether an item is prepared, active, equipped, etc. If so, you must include both label and buttom even if they are named the same:
--title:Weapons --Pistol,pistol,pistol_equipped|Rifle,rifle,rifle_equipped|Sword,sword,sword_equipped
This isn't likely to be needed very often - its usually a feature of repeating sets. But some sheets do this, so it's there if you need it.
Attribute Values instead of Buttons
Sometimes you want a button to show descriptions, like say the text of a feat, or description of a spell.
Normally when you create an attribute, it is in this format:
Languages,languages|
If you put an ! sign on the end of button name, it wont look for a button, it will instead look for the named attribute, and create a button to display its contents.
Languages,languages!|
This might not look as pretty, but it works.
Maximum Flexibility
You can include any number of attribute lists, repeating set groups, and titles, and arrange them however you like. They'll be printed in the order they are listed in the command you send.
Here's a large example tested on the Pathfinder by Roll20 sheet (linebreaks included for readability - remove those if you use it):!chatmenu @{selected|character_id} @{selected|character_name} Action Menu --title:Attacks --repeating_attacks|atkname|fullattack --title:Abilities --repeating_spell-like|spelldisplay|spell --title:Spells --repeating_spell-0|spelldisplay|spell|spellprepared --repeating_spell-1|spelldisplay|spell|spellprepared --repeating_spell-2|spelldisplay|spell|spellprepared --repeating_spell-3|spelldisplay|spell|spellprepared --repeating_spell-4|spelldisplay|spell|spellprepared --repeating_spell-5|spelldisplay|spell|spellprepared --repeating_spell-6|spelldisplay|spell|spellprepared --repeating_spell-7|spelldisplay|spell|spellprepared --repeating_spell-8|spelldisplay|spell|spellprepared --repeating_spell-9|spelldisplay|spell|spellprepared --title:Skills --Appraise,appraise|Bluff,Bluff|Climb,climb|Craft,craft|Diplomacy,diplomacyNote the spells are all lumped into one group. Ideally you'd separate them by titles showing spell level, but I wanted to show how you can group different sets under one title.
Also the spells have a 4th parameter: with this version, spells will only be shown if they are prepared.
Roll Template Support
You can enter the rolltemplate for your sheet. I've only tested this with pathfinder, so it's likely not very robust. Let me know of any problems. Syntax is mostly the same as before.
You start with the command and header, like so
!chatmenu @{selected|character_id} header text
But now you can include the full text of a rolltemplate in the header text. So for the pathfinder sheet you might have
!chatmenu @{selected|character_id} {template:pc}{{charname=@{selected|character_name}}} {{type=ability}} {{smallname=ACTIONS}} {{showchar=[1]}} {{descflag=1}} {{desc=CHATMENU}}
Notice that last entry: CHATMENU.
If the header text contains that, thats where the menu buttons will be grouped, in a single rolltemplate section.
If no CHATMENU is included, it will work like the default rolltemplate, and create a separate rolltemplate section for each group, with a title equal to the group name.
Important
Use the Rolltemplate code as normal, but
- Drop the initial & before &{template
- if the template has any inline rolls [[ ]] convert them to single brackets [ ] (so they aren't processed before the script gets them)
So for pathfinder, the code is normally as below.
&{template:pc}{{charname=@{selected|character_name}}} {{type=ability}} {{smallname=ACTIONS}} {{showchar=[[1]]}} {{descflag=1}} {{desc=CHATMENU}} {{desc= whatever you want here }}
For this script, that becomes: (notice the {template missing its usual &, and showchar brackets cropping from [[1]] to [1]
!chatmenu @{selected|character_id} {template:pc}{{charname=@{selected|character_name}}} {{type=ability}} {{smallname=ACTIONS}} {{showchar=[1]}} {{descflag=1}} {{desc=CHATMENU}} --title:Attacks --repeating_attacks|atkname|fullattack
Here's what the pathfinder sheet looks like:
Filtering
When adding a menu button rule, you can add rules to test, and only show those buttons that pass.
Say you have a list of feats and only want to show the combat ones:
-title:Feats --repeating_feats|name|feat|type=combat
Or you have equipment and only want to show the ones that are equipped (own 1 or more), and have magic in the name.
-title:Magic Gear --repeating_gear|name|desc!|name=magic|count>0
This is for a hypothetical sheet which has a desc field, and a quantity field. The ! after the desc field means its not a button. See above.
You can include any number of tests. The rules are:
- = (an equals sign): tests if the attribute being tested is equal to the given value. If its a text field, it accepts partial matches (so if you supply a test of "=comb" it will match "combat").
- ! (exclamation mark, not equal to): the reverse of the above. For numbers, it tests if the value is different. (!0 is not equal to zero, handy). Go text, it checks if the test is NOT included in the attribute value. spellname!detect will exclude any spells with detect in their name, for instance.
- > (at least equal): checks if the attribute's value is at least equal to the given match value. Only for numbers. So >0 will include all numbers 0 or greater. >10 includes all numbers 10 or greater.
- < (less than): Less than. <10 will only show values 9 and below.
- No Symbol: if you just include an attribute to test, but enter no comparison, it is treated as !0. You are looking for any attribute value that exists and is not equal to 0 or "". This is handy for showing prepared spells, active powers or gear, and the like.
Notice the behaviour of > and < is slightly different. > includes the number supplied, and < doesnt. I think this is the most likely needed behaviour, let me know if this is wrong.
Minor Bits: Separators, Extra Text
Along with --title and the various --attributes there are other parameters:
Separator
--separator:|
By default, the buttons in the chat menu are separated by spaces. You can pick a different separator.
If you want to use a multi-character separator, that ends on a space, use a second : to end the separator. Like so:
--separator: | :
Footer
You can add another section (bare text, another rolltemplate section, etc) and this will be added to end of the menu.
--footer:{{end=some end text}}
--footer:some end text
Note that you dont usually need this. You can include extra text in the initial declaration before titles, separators etc, like so:
!chatmenu @{selected|character_id} {template:npcaction}{{rname=@{selected|character_name}}} {{description=CHATMENU}} {{name=@{selected|npc_type} @{selected|race} @{selected|class_display}}}
The generated button menu will appear wherever you place the CHATMENU text, and it doesnt have to be at the end of the rolltemplate.
Please Test With Your Favourite Sheet
There are a LOT of sheets and I can't test them all.
If you test this script and it has problems, please report back with the sheet you tried it on, and the commands you used that didnt work or caused crashes.