Difference between revisions of "Script:ChatSetAttr"
From Roll20 Wiki
(Created page with "{{script overview |name=ChatSetAttr |author={{user profile|726129|Jakob}} |version=0.9 |lastmodified=2016-08-29}} '''ChatSetAttr'' allows you to create, modify, or delete cha...") |
m (→Toggle Buffs) |
||
(44 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{revdate}} | ||
+ | {{mod}} | ||
+ | {{notebox| '''The full documentation is available in the {{repo|Roll20/roll20-api-scripts/blob/master/ChatSetAttr/README.md Readme}}''', and the One-Click Install description. This page is only a short overview(that might not be fully up to date) of the script. | ||
+ | }} | ||
+ | {{main|API:Script Index}} | ||
+ | |||
{{script overview | {{script overview | ||
|name=ChatSetAttr | |name=ChatSetAttr | ||
|author={{user profile|726129|Jakob}} | |author={{user profile|726129|Jakob}} | ||
− | |version= | + | |version=1.10 |
− | |lastmodified= | + | |lastmodified=2020-09-07 |
+ | |conflicts= Possible for other scripts editing character stats}}'''ChatSetAttr''' allows you to create, modify, or delete characters' attributes via chat commands (or macros containing these commands). (Version 1.10 is newer than v1.9 and v.1.8.) | ||
+ | |||
+ | This script is a utility that allows the user to create, modify, or delete character attributes via chat messages or macros. There are several options that determine which attributes are modified, and which characters the attributes are modified for. | ||
+ | |||
+ | The script is called by the command: | ||
+ | |||
+ | * <code>!setattr [--options]</code>, for creating or modifying attributes | ||
+ | ** <code>!modattr [--options]</code>, shorthand for modifying attributes (same as <code>!setattr --mod [--options]</code>) | ||
+ | * <code>!delattr [--options]</code>, for deleting attributes | ||
+ | * '''<code>!setattr-config</code>''' is used posting the '''Global Configs''' to the chat, and to edit them | ||
+ | <br>{{apiboxRec}} | ||
+ | |||
+ | =Documentation= | ||
+ | This is a partial documentation. See the sidebar for general macro creation on roll20, which can be useful with making ChatSetAttr commands. | ||
+ | |||
+ | See '''[https://github.com/Roll20/roll20-api-scripts/tree/master/ChatSetAttr#readme Readme]''' for full documentation. | ||
+ | |||
+ | ==Selecting a target== | ||
+ | One of the following options must be specified; they determine which characters are affected by the script. | ||
+ | |||
+ | * '''<code>--all</code>''' will affect all characters in the game. '''USE WITH CAUTION''' | ||
+ | ** This option will only work for the GM. If you have a large number of characters in your campaign, this will take a while to process all attribute changes. | ||
+ | {{NavMacroDocs}} | ||
+ | * '''<code>--allgm</code>''' will affect all characters which do not have a controlling player set, which typically will be every character that is not a player character. '''USE WITH CAUTION''' | ||
+ | ** This option will only work for the GM. | ||
+ | * '''<code>--charid charid1, charid2, ...</code>''' allows you to supply a list of character ids, and will affect characters whose ids come from this list. | ||
+ | ** Non-GM Players can only affect characters that they control. | ||
+ | * '''<code>--name name1, name2, ...</code>''' allows you to supply a list of character names, and will look for a character with this name to affect. | ||
+ | ** Non-GM Players can only affect characters that they control. | ||
+ | * '''<code>--sel</code>''' will affect all characters that are represented by tokens you have currently selected. | ||
+ | ** '''<code>--charid @{target|character_id}</code>''' works as a substitute. When embedded into other macros, the <code>--sel</code> parameter doesn't seem to work, so the substitute is needed. | ||
+ | |||
+ | ==Examples== | ||
+ | * <code>!setattr --sel --Strength|15</code> will set the Strength attribute for 15 for all selected characters. | ||
+ | * <code>!setattr --name John --HP|17|27 --Dex|10</code> will set HP to 17 out of 27 and Dex to 10 for the character John (only one of them, if more than one character by this name exists). | ||
+ | * <code>!delattr --all --gold</code> will delete the attribute called gold from all characters, if it exists. | ||
+ | * <code>!setattr --sel --mod --Strength|5</code> will increase the Strength attribute of all selected characters by 5, provided that Strength is either empty or has a numerical value - it will fail to have an effect if, for example, Strength has the value 'Very big'. | ||
+ | * <code>!setattr --sel --Ammo|%Ammo_max%</code> will reset the Ammo attribute for the selected characters back to its maximum value. | ||
+ | * If the current value of <code>attr1</code> is 3 and the current value of <code>attr2</code> is 2, <code>!setattr --sel --evaluate --attr3|2*%attr1% + 7 - %attr2%</code> will set the current value of <code>attr3</code> to 11. | ||
+ | |||
+ | ===Inline roll example=== | ||
+ | You can also embed the ChatSetAttr command into normal/existing macros, such as using them with [[Roll Templates]]. You essentially tell the API to start reading any chat macros with {{code|!setattr}}/{{code|!modattr}}/{{code|!delattr}}, and it will do so until it sees {{code|!!!}}. | ||
+ | |||
+ | '''Note:''' it seems <code>--sel</code> parameter doesn't work for inline macros, so you need to use <code>--charid @{target|character_id}</code> instead. | ||
+ | <pre style="overflow:auto;white-space:pre-wrap;" data-language="javascript">&{template:default} {{name=Cthulhu}} !modattr --silent --charid @{target|character_id} --sanity|-{{Sanity damage=[[2d10+2]]}} --corruption|{{Corruption=Corruption increases by [[1]]}}!!! {{description=Text}}</pre> | ||
+ | [[File:Chatsetattr-inline-ex.png|left|thumbnail|350px|Display the result from example(Purple box). The (From ChatSetAttr) part shows what happens if the <code>--silent</code> parameter is removed from the macro.]] | ||
+ | '''Breakdown:''' | ||
+ | * (<code><nowiki>&{template:default} {{name=Cthulhu}}</nowiki></code>) uses the [[Default_Template#Default|default roll template]] to display & structure the roll | ||
+ | * (<code>!modattr</code>) tells to modify existing stats (if no such stats exists, they won't be created) | ||
+ | * (<code>--silent</code>) tells SetChatAttr to not send to chat a summary of stat changes | ||
+ | * (<code>--charid @{target|character_id}</code>) asks to pick target for the roll (The [[token]] must be [[Link Token|linked to a character sheet]] for the stat-changes to work) | ||
+ | * (<code>--sanity|</code>) selects to edit {{code|sanity}} stat for the character | ||
+ | * (<code><nowiki>-{{Sanity damage=[[2d10+2]]}}</nowiki></code>) the <code>-</code> tells to subtract the next number/[[Inline Roll]] from the {{code|sanity}} stat. In this case, the next number is an inline roll({{code|<nowiki>[[2d10+2]]</nowiki>}}) embedded in a Roll Template block {{code|<nowiki>{{ }}</nowiki>}} | ||
+ | * (<code>--corruption|</code>) selects to edit {{code|corruption}} stat for the character | ||
+ | * (<code><nowiki>{{Corruption=Corruption increases by [[1]]}}</nowiki></code>) the API then evaluates the next roll, which is simply a number, and increases the stat with the value | ||
+ | * (<code>!!!</code>) tells API to stops evaluating the roll | ||
+ | * (<code><nowiki>{{description=Text}}</nowiki></code>) rest of Roll Template is ignored by API. | ||
+ | {{clear}} | ||
+ | If a macro had rolls after the (<code>!!!</code>), they wouldn't change any stats on the sheet. | ||
+ | |||
+ | The reason why ChatSetAttr works so well with Roll Templates is because anything written between the Roll Template blocks {{code|<nowiki>{{ }}</nowiki>}} will not show up in the chat: | ||
+ | <pre>&{template:default} {{name=Test Attack}} nothing written here is displayed in the chat {{attack=[[1d20+3]]}}</pre> | ||
+ | |||
+ | Many character sheets with more sophisticated roll templates have specific blocks that isn't shown in the chat either, but might be used for adjusting how/if other sections are displayed. | ||
+ | |||
+ | ==Global Configurations== | ||
+ | There are three global configuration options which can be toggled either on the '''One Click Install'''-page, or by entering <code>!setattr-config</code> in chat. | ||
+ | |||
+ | * <code>playersCanModify</code>, will give players the possibility of modifying characters they don't control | ||
+ | * <code>playersCanEvaluate</code>, will give players the possibility of reading the stats of characters they don't control, with the <code>--evaluate</code> option | ||
+ | * <code>useWorkers</code>, will determine if the script triggers sheet workers on use. Should normally be toggled on. | ||
+ | |||
+ | ==Conflicts== | ||
+ | This script might conflict with other API that edits character stats, but shouldn't be an issue unless some other script is made to automatically edit same stats as ChatSetAttr. If you have an Ammo Tracking script that reduces the ammo spent from the character, it shouldn't be a problem unless you also incorporated CharSetAttr into the diceroll. | ||
+ | |||
+ | =Examples by users= | ||
+ | Add your own, more complete examples here so others can see them. | ||
+ | |||
+ | * [https://app.roll20.net/forum/post/8091866/ogl-sheet-inventory-writer-using-chatsetatt D&D 5E inventory writer] | ||
+ | |||
+ | ==Change one stat on all characters== | ||
+ | [[Stargate#ChatSetAttr]] by [[Anduh|Andreas J.]] | ||
+ | |||
+ | <pre style="overflow:auto;white-space:pre-wrap;" data-language="javascript">!setattr --all --td|d8</pre> | ||
+ | |||
+ | Sets the value of the <code>td</code>-attribute to be <code>d8</code> for all character sheets. (<code>td</code> stands for "Tension Die", and it can have a value between d4 to d12, representing the general tension level of the session, so it's a shared value for all characters) | ||
+ | |||
+ | ==Heal another character== | ||
+ | [[Stargate#ChatSetAttr]] by [[Anduh|Andreas J.]] | ||
+ | |||
+ | Example of ChatSetAttr used inline within a normal char sheet roll. | ||
+ | <pre style="overflow:auto;white-space:pre-wrap;" data-language="javascript"> | ||
+ | &{template:stargate} {{color=green}} {{title=Short Rest}} !modbattr --silent --charid @{target|character_id} --hp|{{Roll=[[@{target|hd}]]}}!!! {{desc=Rolls the Hit Dice and recovers that many Hit Points. }} | ||
+ | </pre> | ||
+ | |||
+ | (Works when saved in a sheet's [[Journal#Attributes_.26_Abilities_Tab|A&A]]-tab, or is rolled for a roll button in a sheet.) This will prompt you to select a token, and then will roll that character's HD, and increase the characters HP by the result. Token must be [[Link Token|linked]] to a character sheet for this to work. | ||
+ | |||
+ | ==Add new thing to Repeating Section== | ||
+ | This is a complete example of how to add a new entry in a [[Repeating Section|repeating section]], along with populating it's stats at the same time. Can be useful as a template to add adding custom items to players quickly. | ||
+ | |||
+ | * The command makes the SetChatAttr message public, and describes the event with a custom description(that the item was picked up from the chest) | ||
+ | * The command adds a new item(Cloak of Excellence, a custom magic item) to a selected character's inventory (Using [[D&D 5E by Roll20]] character sheet). | ||
+ | * The item is equipped, and adds +2 AC & +1 to Saving Throws for the character, and has a custom description. The magic item is essentially a more powerful version of Cloak of Protection | ||
+ | |||
+ | <pre style="overflow:auto;white-space:pre-wrap;"> | ||
+ | !setattr --sel --fb-public --fb-header Aquiring Magic Item --fb-content The Cloak of Excellence from the chest by a character. --repeating_inventory_-CREATE_itemname|Cloak of Excellence --repeating_inventory_-CREATE_itemcount|1 --repeating_inventory_-CREATE_itemweight|3 --repeating_inventory_-CREATE_equipped|1 --repeating_inventory_-CREATE_itemmodifiers|Item Type: Wondrous item, AC +2, Saving Throws +1 --repeating_inventory_-CREATE_itemcontent|(Requires Attunment)A purple cape, that feels heavy to the touch, but light to carry. It has gnomish text embroiled near the collar. | ||
+ | </pre> | ||
+ | |||
+ | == Adjust the number of Uses remaining == | ||
+ | [[Pathfinder Community Sheet|PF Community sheet]]... be sure to use the rowID associated with the repeating ability you want to target. You can adjust the current uses of an ability with chatsetattr using something like; | ||
+ | |||
+ | <pre>!setattr --sel --repeating_ability_-mm2dso76ircbi5dtea3_used|[[?{How many are left?|0}]]</pre> | ||
+ | |||
+ | == Toggle Buffs == | ||
+ | PF Community sheet... | ||
+ | |||
+ | be sure to use the rowID associated with the repeating buff you want to target. | ||
+ | |||
+ | <pre>!setattr --sel --repeating_buff2_-mfyn0yxatk2wbh0km4d_enable_toggle|[[1-@{selected|repeating_buff2_-mfyn0yxatk2wbh0km4d_enable_toggle}]]</pre> | ||
+ | |||
+ | == Toggle Gear == | ||
+ | PF Community sheet... | ||
+ | |||
+ | So you could make an item "DROP PACK" or whatever.., that includes a negative weight and toggle it as Carried or change quantity when you want to "DROP PACK". You could also create a single macro that toggles multiple items as well. | ||
+ | |||
+ | be sure to use the rowID associated with the repeating item you want to target. | ||
+ | |||
+ | Carried/Not Carried: | ||
+ | <pre>!setattr --sel --repeating_item_-njjkfxsxzf7lzfzbibc_location|[[1-@{selected|repeating_item_-njjkfxsxzf7lzfzbibc_location}]]</pre> | ||
+ | Quantity 0/1: | ||
+ | <pre>!setattr --sel --repeating_item_-njjkfxsxzf7lzfzbibc_qty|[[1-@{selected|repeating_item_-njjkfxsxzf7lzfzbibc_qty}]]</pre> | ||
+ | |||
+ | == Roll & spend Character Point == | ||
+ | [[Star Wars D6 Sheet]] by [[Andreas J.]] | ||
+ | |||
+ | Spend a number of Character Points to roll extra dice, and automatically subtract the number from the <code>characterPoints</code> stat. ChatSetAttr is embedded into the original macro used on the sheet. | ||
+ | |||
+ | Three versions of the same macro: | ||
+ | |||
+ | Choose character name(here "Bob" is used) | ||
+ | <pre style="overflow:auto;white-space:pre-wrap;">&{template:black} {{name=Character points roll}} !modattr --silent --name Bob --characterPoints|-[[?{Number of char points to spend on roll|1|2|3|4|5}]] !!! {{Roll=[[?{Number of char points to spend on roll|1|2|3|4|5}d6!cf0cs6]]}}</pre> | ||
+ | |||
+ | Do the roll based on selected token(s): | ||
+ | <pre style="overflow:auto;white-space:pre-wrap;">&{template:black} {{name=Character points roll}} !modattr --silent --charid @{selected|character_id} --characterPoints|-[[?{Number of char points to spend on roll|1|2|3|4|5}]] !!! {{Roll=[[?{Number of char points to spend on roll|1|2|3|4|5}d6!cf0cs6]]}}</pre> | ||
+ | |||
+ | Target token from the map: | ||
+ | <pre style="overflow:auto;white-space:pre-wrap;">&{template:black} {{name=Character points roll}} !modattr --silent --charid @{target|character_id} --characterPoints|-[[?{Number of char points to spend on roll|1|2|3|4|5}]] !!! {{Roll=[[?{Number of char points to spend on roll|1|2|3|4|5}d6!cf0cs6]]}}</pre> | ||
+ | |||
+ | ==Creating multiple new rows in a repeating section== | ||
+ | * {{fpl|10381631/ Creating multiple new rows in a repeating section}} | ||
+ | * Solution might require use of [[Meta-Toolbox#Plugger|Plugger]] API. | ||
+ | |||
+ | =Links= | ||
+ | * {{repo|Roll20/roll20-api-scripts/blob/master/ChatSetAttr/README.md ChatSetAttr README}} | ||
+ | |||
+ | Forum Discussions | ||
+ | * [https://app.roll20.net/forum/post/10874077/chatsetattr-issue chatsetattr issue] relating to repeating sections - May 2022 | ||
+ | * https://app.roll20.net/forum/post/10705702/use-chatsetattr-to-adjust-repeating-inventory Feb 2022 | ||
+ | * {{forum|post/10666893/chatsetattr-help chatsetattr-help}} Feb 2022 | ||
+ | * {{fpl|10029806/ chatsetattr no lower than 0}} (use either [[Script:Fetch|Fetch]] or [[Meta-Toolbox#MathOps|MathOps]] to extend the APIs functionality. April 2021 | ||
+ | * {{fpl|9168494/ ChatSetAttr Issues With Setting Values}} Sept 2020 | ||
+ | * {{forum|post/8002098/slug%7D On how to use the inline roll option}} Dec 2019 | ||
+ | * {{forum|post/8009227/chatsetattr-evaluate-syntax-help/ ChatSetAttr Evaluate Syntax Help}} Dec 2019 | ||
+ | * {{forum|post/8882359/slug%7D Issue with ChatSetAttr and sheetworkers}} (particularly, {{code|attr_}} that are checkboxes) 2019 | ||
+ | * {{fpl|6578447/ (Script Update) ChatSetAttr 1.8 – now with inline command support}} v.1.8 update, 2018-2019 | ||
+ | * {{fpl|3737514/ (Script) ChatSetAttr - set character attributes via chat messages}} Original thread, 2016-2018 | ||
+ | |||
+ | =Related Pages= | ||
+ | * '''[[Complete Guide to Macros & Rolls]]''' | ||
+ | ** {{Text Chat}} - where the roll results appear, & info on the common chat commands | ||
+ | ** [[Dice Reference]] - Comprehensive list of how the Roll20 dice-rolling syntax works, and list the features available | ||
+ | ** [[Order of Operations]] | ||
+ | ** [[Inline Rolls]] | ||
+ | ** [[Macros]] - How to create macros, and other info on how the Roll20 <span style="font-family:Pictos;">q</span>Text Chat works, like referencing stats on character sheets, roll queries, nesting macros & initiative | ||
+ | *** [[Reusing Rolls]] | ||
+ | ** [[Roll Templates]] - a method of formatting roll results in the chat, with some extra functions | ||
+ | ** [[API]]''(Pro Only)'' - API commands can be used in the <span style="font-family:Pictos;">q</span>Text Chat | ||
+ | * '''[[API:Script Index]]''' curated list of other APIs | ||
+ | ** [[Script:Ammo]] - another API used for updating stats, streamlined for handling ammo | ||
+ | ** [[Script:TokenMod]] - API for editing token settings & token bar values | ||
+ | ** [[Script:SelectManager|SelectManager]] - can be used to fix some shortcomings with how token selection work with ChatSetAttr | ||
− | + | [[Category:Featured articles]] | |
+ | [[Category:Character Sheets]] | ||
+ | [[Category:Macros]] | ||
+ | [[Category:API Commands]] |
Latest revision as of 01:21, 21 November 2023
Page Updated: 2023-11-21 |
This is related to Roll20 Mods, which require Pro info from the game's creator.(formerly known as API "Scripts") Main Page: Mod:Use Guide |
The full documentation is available in the Readme, and the One-Click Install description. This page is only a short overview(that might not be fully up to date) of the script. |
Main Page: API:Script Index
Version: 1.10
Last Modified: 2020-09-07
Code: ChatSetAttr
Dependencies: None
Conflicts: Possible for other scripts editing character stats
This script is a utility that allows the user to create, modify, or delete character attributes via chat messages or macros. There are several options that determine which attributes are modified, and which characters the attributes are modified for.
The script is called by the command:
-
!setattr [--options]
, for creating or modifying attributes-
!modattr [--options]
, shorthand for modifying attributes (same as!setattr --mod [--options]
)
-
-
!delattr [--options]
, for deleting attributes -
!setattr-config
is used posting the Global Configs to the chat, and to edit them
Roll20 Mod
Mod Suggestions
- D&D 5E
- Combat
- Character Sheet
- Dynamic Lighting
- Jukebox
- Maps
- Text Chat/Macros
- Tokens
- System Specific
- Mod Guides by Script
Debug
Other
Contents |
[edit] Documentation
This is a partial documentation. See the sidebar for general macro creation on roll20, which can be useful with making ChatSetAttr commands.
See Readme for full documentation.
[edit] Selecting a target
One of the following options must be specified; they determine which characters are affected by the script.
-
--all
will affect all characters in the game. USE WITH CAUTION- This option will only work for the GM. If you have a large number of characters in your campaign, this will take a while to process all attribute changes.
Macro Creation
- Complete Guide to Macros & Rolls
- q Text Chat
- Dice Reference
- Order of Operations
- Macros
- Token Reference
- Character Reference
- Roll Templates
- Roll Table
Advanced
- Formatting
- HTML Replacement
- Chat Menus
- Hidden Rolls
- Advanced Macro Tips
- API Commands
- Char Sheet Creation
- External tools
Misc.
-
--allgm
will affect all characters which do not have a controlling player set, which typically will be every character that is not a player character. USE WITH CAUTION- This option will only work for the GM.
-
--charid charid1, charid2, ...
allows you to supply a list of character ids, and will affect characters whose ids come from this list.- Non-GM Players can only affect characters that they control.
-
--name name1, name2, ...
allows you to supply a list of character names, and will look for a character with this name to affect.- Non-GM Players can only affect characters that they control.
-
--sel
will affect all characters that are represented by tokens you have currently selected.-
--charid @{target|character_id}
works as a substitute. When embedded into other macros, the--sel
parameter doesn't seem to work, so the substitute is needed.
-
[edit] Examples
-
!setattr --sel --Strength|15
will set the Strength attribute for 15 for all selected characters. -
!setattr --name John --HP|17|27 --Dex|10
will set HP to 17 out of 27 and Dex to 10 for the character John (only one of them, if more than one character by this name exists). -
!delattr --all --gold
will delete the attribute called gold from all characters, if it exists. -
!setattr --sel --mod --Strength|5
will increase the Strength attribute of all selected characters by 5, provided that Strength is either empty or has a numerical value - it will fail to have an effect if, for example, Strength has the value 'Very big'. -
!setattr --sel --Ammo|%Ammo_max%
will reset the Ammo attribute for the selected characters back to its maximum value. - If the current value of
attr1
is 3 and the current value ofattr2
is 2,!setattr --sel --evaluate --attr3|2*%attr1% + 7 - %attr2%
will set the current value ofattr3
to 11.
[edit] Inline roll example
You can also embed the ChatSetAttr command into normal/existing macros, such as using them with Roll Templates. You essentially tell the API to start reading any chat macros with !setattr
/!modattr
/!delattr
, and it will do so until it sees !!!
.
Note: it seems --sel
parameter doesn't work for inline macros, so you need to use --charid @{target|character_id}
instead.
&{template:default} {{name=Cthulhu}} !modattr --silent --charid @{target|character_id} --sanity|-{{Sanity damage=[[2d10+2]]}} --corruption|{{Corruption=Corruption increases by [[1]]}}!!! {{description=Text}}
Breakdown:
- (
&{template:default} {{name=Cthulhu}}
) uses the default roll template to display & structure the roll - (
!modattr
) tells to modify existing stats (if no such stats exists, they won't be created) - (
--silent
) tells SetChatAttr to not send to chat a summary of stat changes - (
--charid @{target|character_id}
) asks to pick target for the roll (The token must be linked to a character sheet for the stat-changes to work) - (
--sanity|
) selects to editsanity
stat for the character - (
-{{Sanity damage=[[2d10+2]]}}
) the-
tells to subtract the next number/Inline Roll from thesanity
stat. In this case, the next number is an inline roll([[2d10+2]]
) embedded in a Roll Template block{{ }}
- (
--corruption|
) selects to editcorruption
stat for the character - (
{{Corruption=Corruption increases by [[1]]}}
) the API then evaluates the next roll, which is simply a number, and increases the stat with the value - (
!!!
) tells API to stops evaluating the roll - (
{{description=Text}}
) rest of Roll Template is ignored by API.
If a macro had rolls after the (!!!
), they wouldn't change any stats on the sheet.
The reason why ChatSetAttr works so well with Roll Templates is because anything written between the Roll Template blocks {{ }}
will not show up in the chat:
&{template:default} {{name=Test Attack}} nothing written here is displayed in the chat {{attack=[[1d20+3]]}}
Many character sheets with more sophisticated roll templates have specific blocks that isn't shown in the chat either, but might be used for adjusting how/if other sections are displayed.
[edit] Global Configurations
There are three global configuration options which can be toggled either on the One Click Install-page, or by entering !setattr-config
in chat.
-
playersCanModify
, will give players the possibility of modifying characters they don't control -
playersCanEvaluate
, will give players the possibility of reading the stats of characters they don't control, with the--evaluate
option -
useWorkers
, will determine if the script triggers sheet workers on use. Should normally be toggled on.
[edit] Conflicts
This script might conflict with other API that edits character stats, but shouldn't be an issue unless some other script is made to automatically edit same stats as ChatSetAttr. If you have an Ammo Tracking script that reduces the ammo spent from the character, it shouldn't be a problem unless you also incorporated CharSetAttr into the diceroll.
[edit] Examples by users
Add your own, more complete examples here so others can see them.
[edit] Change one stat on all characters
Stargate#ChatSetAttr by Andreas J.
!setattr --all --td|d8
Sets the value of the td
-attribute to be d8
for all character sheets. (td
stands for "Tension Die", and it can have a value between d4 to d12, representing the general tension level of the session, so it's a shared value for all characters)
[edit] Heal another character
Stargate#ChatSetAttr by Andreas J.
Example of ChatSetAttr used inline within a normal char sheet roll.
&{template:stargate} {{color=green}} {{title=Short Rest}} !modbattr --silent --charid @{target|character_id} --hp|{{Roll=[[@{target|hd}]]}}!!! {{desc=Rolls the Hit Dice and recovers that many Hit Points. }}
(Works when saved in a sheet's A&A-tab, or is rolled for a roll button in a sheet.) This will prompt you to select a token, and then will roll that character's HD, and increase the characters HP by the result. Token must be linked to a character sheet for this to work.
[edit] Add new thing to Repeating Section
This is a complete example of how to add a new entry in a repeating section, along with populating it's stats at the same time. Can be useful as a template to add adding custom items to players quickly.
- The command makes the SetChatAttr message public, and describes the event with a custom description(that the item was picked up from the chest)
- The command adds a new item(Cloak of Excellence, a custom magic item) to a selected character's inventory (Using D&D 5E by Roll20 character sheet).
- The item is equipped, and adds +2 AC & +1 to Saving Throws for the character, and has a custom description. The magic item is essentially a more powerful version of Cloak of Protection
!setattr --sel --fb-public --fb-header Aquiring Magic Item --fb-content The Cloak of Excellence from the chest by a character. --repeating_inventory_-CREATE_itemname|Cloak of Excellence --repeating_inventory_-CREATE_itemcount|1 --repeating_inventory_-CREATE_itemweight|3 --repeating_inventory_-CREATE_equipped|1 --repeating_inventory_-CREATE_itemmodifiers|Item Type: Wondrous item, AC +2, Saving Throws +1 --repeating_inventory_-CREATE_itemcontent|(Requires Attunment)A purple cape, that feels heavy to the touch, but light to carry. It has gnomish text embroiled near the collar.
[edit] Adjust the number of Uses remaining
PF Community sheet... be sure to use the rowID associated with the repeating ability you want to target. You can adjust the current uses of an ability with chatsetattr using something like;
!setattr --sel --repeating_ability_-mm2dso76ircbi5dtea3_used|[[?{How many are left?|0}]]
[edit] Toggle Buffs
PF Community sheet...
be sure to use the rowID associated with the repeating buff you want to target.
!setattr --sel --repeating_buff2_-mfyn0yxatk2wbh0km4d_enable_toggle|[[1-@{selected|repeating_buff2_-mfyn0yxatk2wbh0km4d_enable_toggle}]]
[edit] Toggle Gear
PF Community sheet...
So you could make an item "DROP PACK" or whatever.., that includes a negative weight and toggle it as Carried or change quantity when you want to "DROP PACK". You could also create a single macro that toggles multiple items as well.
be sure to use the rowID associated with the repeating item you want to target.
Carried/Not Carried:
!setattr --sel --repeating_item_-njjkfxsxzf7lzfzbibc_location|[[1-@{selected|repeating_item_-njjkfxsxzf7lzfzbibc_location}]]
Quantity 0/1:
!setattr --sel --repeating_item_-njjkfxsxzf7lzfzbibc_qty|[[1-@{selected|repeating_item_-njjkfxsxzf7lzfzbibc_qty}]]
[edit] Roll & spend Character Point
Star Wars D6 Sheet by Andreas J.
Spend a number of Character Points to roll extra dice, and automatically subtract the number from the characterPoints
stat. ChatSetAttr is embedded into the original macro used on the sheet.
Three versions of the same macro:
Choose character name(here "Bob" is used)
&{template:black} {{name=Character points roll}} !modattr --silent --name Bob --characterPoints|-[[?{Number of char points to spend on roll|1|2|3|4|5}]] !!! {{Roll=[[?{Number of char points to spend on roll|1|2|3|4|5}d6!cf0cs6]]}}
Do the roll based on selected token(s):
&{template:black} {{name=Character points roll}} !modattr --silent --charid @{selected|character_id} --characterPoints|-[[?{Number of char points to spend on roll|1|2|3|4|5}]] !!! {{Roll=[[?{Number of char points to spend on roll|1|2|3|4|5}d6!cf0cs6]]}}
Target token from the map:
&{template:black} {{name=Character points roll}} !modattr --silent --charid @{target|character_id} --characterPoints|-[[?{Number of char points to spend on roll|1|2|3|4|5}]] !!! {{Roll=[[?{Number of char points to spend on roll|1|2|3|4|5}d6!cf0cs6]]}}
[edit] Creating multiple new rows in a repeating section
- Creating multiple new rows in a repeating section(Forum)
- Solution might require use of Plugger API.
[edit] Links
Forum Discussions
- chatsetattr issue relating to repeating sections - May 2022
- https://app.roll20.net/forum/post/10705702/use-chatsetattr-to-adjust-repeating-inventory Feb 2022
- chatsetattr-help(Forum) Feb 2022
- chatsetattr no lower than 0(Forum) (use either Fetch or MathOps to extend the APIs functionality. April 2021
- ChatSetAttr Issues With Setting Values(Forum) Sept 2020
- On how to use the inline roll option(Forum) Dec 2019
- ChatSetAttr Evaluate Syntax Help(Forum) Dec 2019
- Issue with ChatSetAttr and sheetworkers(Forum) (particularly,
attr_
that are checkboxes) 2019 - (Script Update) ChatSetAttr 1.8 – now with inline command support(Forum) v.1.8 update, 2018-2019
- (Script) ChatSetAttr - set character attributes via chat messages(Forum) Original thread, 2016-2018
[edit] Related Pages
- Complete Guide to Macros & Rolls
- q Text Chat - where the roll results appear, & info on the common chat commands
- Dice Reference - Comprehensive list of how the Roll20 dice-rolling syntax works, and list the features available
- Order of Operations
- Inline Rolls
- Macros - How to create macros, and other info on how the Roll20 qText Chat works, like referencing stats on character sheets, roll queries, nesting macros & initiative
- Roll Templates - a method of formatting roll results in the chat, with some extra functions
- API(Pro Only) - API commands can be used in the qText Chat
- API:Script Index curated list of other APIs
- Script:Ammo - another API used for updating stats, streamlined for handling ammo
- Script:TokenMod - API for editing token settings & token bar values
- SelectManager - can be used to fix some shortcomings with how token selection work with ChatSetAttr