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 .
Advertisement Create a free account Compendium in Game, Join Today

ChatSetAttr

1577115638
Tealk
Pro
Sheet Author
Hi, how to use the inline command? I would like to put "!setattr --all --silent --edge|@{edge}" and "Group has now @{edge} Edge" in one roll button.
1577117168
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
You would need to put it on two lines in an Action or a Macro: !setattr --all --silent --edge|@{edge} Group has now @{edge} Edge The problem is, I don't know if the report part will be accurate. in the order of operations, the attribute call @{edge} resolves first, so it might be the same throughout. Technically, they are two separate commands, but I don't know if there is enough time between the two events. Also, I believe --all does all characters in the game, not just the group. You might want --sel here, to just get the characters of selected tokens. And you are reporting for a group, but @{edge} will only report for one character. As written, this will only report for a single character, and only if run as a token action (there is no character identifier to indicate which  character's edge you want reported.) Finally, I don't know what this is supposed to do. If the character has an edge attribute, this looks like it will set it to it's existing value, which is no change.
1577118579

Edited 1577119473
Tealk
Pro
Sheet Author
I've had it that way until now and would like to add the output. <button type="roll" name="roll_edgeRoll" value="!setattr --all --silent --edge|@{edge}">Edge</button> But that's exactly what I want to achieve, I have an edge pool that the whole group uses and I want to synchronize it with the button. good that you can use \n to create a new line :D //Edit Oh I just noticed that users are not allowed to access the API at all, only the GM? :'(
1577123676
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Player access is a config setting on chatsetattr. Where is @edge stored, if it is a group attribute? Also, it looks like you are building this into the character sheet by the look of your posted code. That's out of my wheelhouse. I've never looked into sheet building.
1577126705

Edited 1577126937
Tealk
Pro
Sheet Author
an attribute in the player's char sheet, every player has this field. I wanted to achieve that a player, who has used up edge, takes it off with himself and then transfers it to all players with the button
1577129656
GiGs
Pro
Sheet Author
API Scripter
Some thing keith mentioned above bears repeating: The --all command means apply this to  all characters  in the campaign. Every single one. all Pcs, all npcs, all monsters. You probably dont want to use that. The command you have set up will overwrite the edge attribute of other characters, with the edge of the current one. So let's say Bob has edge 3, and Lea has 1. Lea uses this command: now Bob and Lea both have 1 edge. If its a communal pool, i guess that makes sense - but there's no spending of edge here. i think you need to go back to basics and think what you need to do: You need an attribute that is shared by the entire group When anyone spends a point from this attribute, it goes down for everyone You need to restrict the attribute changes to just the characters in this group - maybe thats not an issue? There are some problems for incorporating this in a character sheet: Is this sheet just for your own group, or are you planning to share it with others? if sharing, API Scripts are only for campaigns with a Pro level GM, so it cant be used by a lot of users and isnt really appropriate unless this part is made optional (the rolls dependent on scripts are hidden, for instance). Limiting the attribute changes to just the pcs is impossible from a character sheet, without further set up: you need some way of identifying the characters, which cannot be done automatically from the character sheet alone. An attribute that holds a manually created list of character names is one way to do it for instance. Or maybe you dont care that it gets added to npc sheets if they will never use it. If you dont care that it will change every character, and just intend it for your own groups use, a better way would probably be <button type="roll" name="roll_edgeRoll" value="!modattr --all --edge|-1">Edge</button> This way it reduces the edge attribute by one for everyone and reports that it has been reduced. Or you could do  <button type="roll" name="roll_edgeRoll" value="&{template:default}{{name=@{character_name} spends Edge!}} \n!modattr --silent --all --edge|-1 ">Edge</button> The \n there is a linebreak, ensuring the script command is on its own line. This might not be necessary with chatsetattr, not sure.
1577130553

Edited 1577132778
Tealk
Pro
Sheet Author
GiGs said: The command you have set up will overwrite the edge attribute of other characters, with the edge of the current one. So let's say Bob has edge 3, and Lea has 1. Lea uses this command: now Bob and Lea both have 1 edge. If its a communal pool, i guess that makes sense - but there's no spending of edge here. thanks for your explanations Yes all lose edge at the same time, there is only one shared edge pool. It can also be that more than one edge is needed at a time. it's an own set of rules that i'm writing right now, because i can only lead online rounds i started to build a character sheet right away. yes I noticed that with the pro but as long as there is a text message that should not be a problem because then everyone gets it and can enter it by hand. the rolls dependent on scripts are hidden, for instance how can you do that? is there a question if you are pro user? Or maybe you dont care that it gets added to npc sheets if they will never use it. it would also be possible to make a checkbox which is activated if the character sheet is owned by an npc GiGs  said: <button type="roll" name="roll_edgeRoll" value="&{template:default}{{name=@{character_name} spends Edge!}} \n!modattr --silent --all --edge|-1 ">Edge</button> The \n there is a linebreak, ensuring the script command is on its own line. This might not be necessary with chatsetattr, not sure. line break is not necessary in the template
1577130829

Edited 1577134013
Tealk
Pro
Sheet Author
currently i use the following combination: <button type="roll" name="roll_edgeRoll" value="!setattr --all --silent --edge|?{Modifier?|+/-} \n [[@{edge} ?{Modifier?|+/-}]] Edge">Edge</button> <input type="number" name="attr_edge" value="4" /> the user enters the new edge number in the input field and then presses the button so when I use the button as a gm it all works when a player uses the button the following message appears: (From ChatSetAttr): Errors No target characters. You need to supply one of --all, --allgm, --sel, --allplayers, --charid, or --name.
1577136286
GiGs
Pro
Sheet Author
API Scripter
Tealk said: currently i use the following combination: <button type="roll" name="roll_edgeRoll" value="!setattr --all --silent --edge|?{Modifier?|+/-} \n [[@{edge} ?{Modifier?|+/-}]] Edge">Edge</button> <input type="number" name="attr_edge" value="4" /> the user enters the new edge number in the input field and then presses the button so when I use the button as a gm it all works when a player uses the button the following message appears: (From ChatSetAttr): Errors No target characters. You need to supply one of --all, --allgm, --sel, --allplayers, --charid, or --name. It turns out players cant use --all. From the chatsetAttrs ducumentation: --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. It looks like the only way to do this would be to use --sel (pretty risky for a character sheet macro, since there's no guarantee players will remember or even be able to select all pc tokens), or to use --name and list all the pc characters.
1577136478
GiGs
Pro
Sheet Author
API Scripter
Tealk said: the rolls dependent on scripts are hidden, for instance how can you do that? is there a question if you are pro user? I'm referring to use CSS to hide elements of the character sheet. You could have a checkbox in a settings section, "Do you have chatsetattr installed?" and if that box is unticked, hide the button above, and if ticked, reveal it. Check out the CSS Wizardry page on the wiki for examples of things like this.
1577137687
Tealk
Pro
Sheet Author
GiGs said: I'm referring to use CSS to hide elements of the character sheet. You could have a checkbox in a settings section, "Do you have chatsetattr installed?" and if that box is unticked, hide the button above, and if ticked, reveal it. Check out the CSS Wizardry page on the wiki for examples of things like this. That's what you mean, I thought there was a way to read which apis was activated It looks like the only way to do this would be to use --sel (pretty risky for a character sheet macro, since there's no guarantee players will remember or even be able to select all pc tokens), or to use --name and list all the pc characters. but then the user would have to enter all usernames manually? Or is there a way to read out all names and automate that?
1577137985
GiGs
Pro
Sheet Author
API Scripter
Tealk said: GiGs said: I'm referring to use CSS to hide elements of the character sheet. You could have a checkbox in a settings section, "Do you have chatsetattr installed?" and if that box is unticked, hide the button above, and if ticked, reveal it. Check out the CSS Wizardry page on the wiki for examples of things like this. That's what you mean, I thought there was a way to read which apis was activated It looks like the only way to do this would be to use --sel (pretty risky for a character sheet macro, since there's no guarantee players will remember or even be able to select all pc tokens), or to use --name and list all the pc characters. but then the user would have to enter all usernames manually? Or is there a way to read out all names and automate that? There's no non-script way. A custom script could identify them in a variety of ways, with different degrees of usefulness, but there's no way to do this natively in a character sheet. Honestly, for a feature like this, I think you'd be better off making it a script. One of the various experience scripts could be hijacked for the purpose. They have ways of letting the GM identify the pcs, and store a total shared by all the pcs (experience => edge). You could create a macro that lets players spend edge and report the edge remaining. It wouldnt be a complex script. I think I have one I could dig up and tweak it for this purpose, if you'd like that.
1577138730
Tealk
Pro
Sheet Author
GiGs said: . It wouldnt be a complex script. I think I have one I could dig up and tweak it for this purpose, if you'd like that. I am unfortunately not very well in JS, it would be great if you could help me, thank you very much :D
1577141780
GiGs
Pro
Sheet Author
API Scripter
Tealk said: GiGs said: . It wouldnt be a complex script. I think I have one I could dig up and tweak it for this purpose, if you'd like that. I am unfortunately not very well in JS, it would be great if you could help me, thank you very much :D I just realised you could use the already-existing Ammo script for this. Create a character, call it Group, and create an attribute on it called edge. Give it an initial score. Then set up the sheet as being editable by all characters, but visible to none, and then any player can use ammo script to spend points of edge. !ammo @{Group|character_id} Edge -1 Edge The above could be used to spend edge. Use this to add points of edge !ammo @{Group|character_id} Edge ?{Add Edge?|1} Edge It's not perfect, but it's simple. I'll dig up my script later.
1577142196
Tealk
Pro
Sheet Author
GiGs said: I just realised you could use the already-existing Ammo script for this. Create a character, call it Group, and create an attribute on it called edge. Give it an initial score. Then set up the sheet as being editable by all characters, but visible to none, and then any player can use ammo script to spend points of edge. !ammo @{Group|character_id} Edge -1 Edge The above could be used to spend edge. Use this to add points of edge !ammo @{Group|character_id} Edge ?{Add Edge?|1} Edge It's not perfect, but it's simple. I'll dig up my script later. Thanks a really good idea
1577142612
Tealk
Pro
Sheet Author
What I am missing on the ammo scirpt is a display of the current edge.
1577144963
Kraynic
Pro
Sheet Author
It should print out how what the edge value is after it has been altered, is it not doing that?  If you mean a constant place players can see, you could give that sheet a token and have edge displayed in one of the bubbles.
1577190939
Tealk
Pro
Sheet Author
Kraynic said: If you mean a constant place players can see, you could give that sheet a token and have edge displayed in one of the bubbles. Yes exactly but it would be great if the place was in the character sheet of the player, looks more elegant.