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] ChatSetAttr - set character attributes via chat messages

1485551896
Jakob
Sheet Author
API Scripter
Hmm, thanks for reporting that error! I made a silly mistake there that I didn't see in time, sorry! It's fixed in the Github version now, and I've put up a pull request for one-click (but that will take a while).
1485552922
Nibrodooh
Pro
Sheet Author
Thanks for the fix, it's working perfectly. Also, that was an amazingly fast fix, i commend you haha.
1485592995
Jakob
Sheet Author
API Scripter
Nibrodooh said: Thanks for the fix, it's working perfectly. Also, that was an amazingly fast fix, i commend you haha. It was a one-line fix. I'm just a bit dismayed that one-click is stuck with a defective version for at least 2 weeks now. ..
1485702977
Jakob
Sheet Author
API Scripter
Ravenknight said: Hiya, I stole the macro below from someone better attuned to the making of macros for OGL 5ed and it's been working flawlessly until last week or so. Now it just breaks the API sandbox whenever used. Any idea on what I'm doing wrong? !setattr {{ --charid @{selected|character_id} --mod --lvl?{Spell Slot Used|1|2|3|4|5|6|7|8|9}_slots_expended|1 }} See 4 posts back, --charid is broken in the current one-click version, I'm very sorry about it :(. You can do one of three things, either a) replace the second line by --sel or b) install the fixed version from Github (link in the first post) or c) manually switch your one-click version to 1.1.4 (I think) until Roll20 accepts my pull request for the fix.
Thanks a lot Jakob. :)
Hi, I am trying to automate combat using this script in combination with Macro Parameters script (to avoid the target problem, because when I use target and selected in the same macro, it returns an error, as commented before). So the thing is I am trying this: /em @{selected|name} Attacks @{target|name} #MacroPar(@{selected|name},lastdice,[[1d20]]) #MacroPar(@{selected|name},lastdamage,[[{{[[@{selected|lastdice}+@{selected|closeattack}]],0}>@{target|AC}}*(@{selected|damage})]]) #MacroPar(@{target|name},hp,[[@{target|hp} -@{selected|lastdamage}]]) @{selected|name} rolls @{selected|lastdice} vs @{target|name} AC@{target|AC} For @{selected|lastdamage} Damage! And MacroPar does the following !setattr --silent --replace --name ?{name1} --?{att1}|?{value} Everything seems to go well on the chat, but when I check the attributes in the characters, they all are $[[0]] and $[[1]. I am trying the --replace, but it doesnt work in this case. Any idea why? Many thanks for your work!
1486161400

Edited 1486161666
Jakob
Sheet Author
API Scripter
Hey Seregras, what happens is that the inlineroll values appear as $[[0]] in the message text, and a script needs to replace them to get access to the actual values. Macro Parameters doesn't seem to do that, and ChatSetAttr only sees the $[[0]] because the inlineroll data is no longer there at that point. Short of modifying Macro Parameters to replace inlinerolls by their values. I can think of one more possibility - can you try replacing all instances of double inlineroll brackets with their html entities (that is, [ becomes [ and ] becomes ])? No idea if this will haven an effect since I don't know in what manner exactly things are happening, but it just might work.
1486162134
vÍnce
Pro
Sheet Author
Jakob, can CSA adjust character journal permissions?  If not, do you know of a script that can, preferably game wide if possible.  Thanks
1486165590
Jakob
Sheet Author
API Scripter
Vince said: Jakob, can CSA adjust character journal permissions?  If not, do you know of a script that can, preferably game wide if possible.  Thanks No, and no. Maybe there's something by The Aaron? That being said, it's not complicated easy to write.a one-off that can add or remove a specified player to/from permissions for all characters.
1486166149
The Aaron
Pro
API Scripter
TokenMod, when a token represents a character, will adjust the controlledby of the character. 
1486168384

Edited 1486168862
vÍnce
Pro
Sheet Author
The Aaron said: TokenMod, when a token represents a character, will adjust the controlledby of the character.  This would be before a token has been linked...  We allow people to import their sheets to the PF beta game for testing and it would be very convenient to just run a script and assign "All players" to "All the Players" that have imported their sheets.   ;-)  M=Normally we look to see if a users name is in the player's name field/attribute and I'll assign specific permission to that player, if not assigning All players works just as well. Jakob said: Vince said: Jakob, can CSA adjust character journal permissions?  If not, do you know of a script that can, preferably game wide if possible.  Thanks No, and no. Maybe there's something by The Aaron? That being said, it's not complicated easy to write.a one-off that can add or remove a specified player to/from permissions for all characters. If it's not too hard... Not sure if anyone else would find it useful, but I would be much appreciated if such a script was written.  ;-)
1486220171

Edited 1486220209
I think if a Character has 'All Players' permissions before Vaulting over, those permissions are kept... Not 100% sure.
1486252107
The Aaron
Pro
API Scripter
They do. I use this for spell template characters I pull into a game.  I could write you a script that that makes all characters always have all permission. 
1486283720
vÍnce
Pro
Sheet Author
The Aaron said: They do. I use this for spell template characters I pull into a game.  I could write you a script that that makes all characters always have all permissio I think that would work fine Aaron.  Is it possible to place such a script in the api so that it automatically assigns all permission without GM interaction?
1486366949

Edited 1486367016
Using 1.2.1 from GitHub (e.g. !setattr --name Test --hello|world) throws this error: ReferenceError: sendChatMessage is not defined ReferenceError: sendChatMessage is not defined at _.each._.each._.chain.map.sendFeedback (apiscript.js:585:4) at dWork (apiscript.js:362:29) at _.each._.each.delayedSetAttributes (apiscript.js:365:4) at _.each._.each._.chain.map._.chain.filter.charIDList (apiscript.js:682:7) at eval (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:65:16) at Object.publish (eval at <anonymous> (/home/node/d20-api-server/api.js:146:34), <anonymous>:70:8) at /home/node/d20-api-server/api.js:1494:12 at /home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:560 at hc (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:39:147) at Kd (/home/node/d20-api-server/node_modules/firebase/lib/firebase-node.js:93:546) (Indeed, I cannot find where sendChatMessage() is defined... 1.2 on GitHub works fine.)
1486367333
Jakob
Sheet Author
API Scripter
That's because I defined sendChatMess s age! Fixed, thanks Silvyre.
You're welllcome!
1486382040
Jakob
Sheet Author
API Scripter
Silvyre said: You're welllcome! :). Since I never properly announced it: 1.2.1 Changed all messages sent to have the 'noarchive' flag, hence they will no longer appear in the chat log (now possible since noarchive has been fixed!).
1486517264

Edited 1486519002
Ravenknight
KS Backer
Hi Jakob. Another problem. I've noticed that I can't no longer use ChatSetAttr when a target is involved. This used to work perfectly before the latest updates. With a specified target: Without: Using the macro:  !setattr {{ --sel --mod --class_resource|-1 }} Together with powercards.  This issue happens when I combine ChatSetAttr with any macro using @{target|token_name}
1486534411
Jakob
Sheet Author
API Scripter
Indeed, that's the one disadvantage of --sel vs --charid @{selected|character_id} (short explanation: roll20 clears your selection if a message contains a target statement). You'll have to try fixes b,c, or maybe use --name @{selected|character_name} ?
Try putting the !setattr command first. Perhaps it will pull the selected information before you hit any target information.
1486535492
Jakob
Sheet Author
API Scripter
SkyCaptainXIII said: Try putting the !setattr command first. Perhaps it will pull the selected information before you hit any target information. I think the whole message is only sent after the target has been clicked, at which point it is too late.
Jakob said: SkyCaptainXIII said: Try putting the !setattr command first. Perhaps it will pull the selected information before you hit any target information. I think the whole message is only sent after the target has been clicked, at which point it is too late. @{selected|token_name} @{target|token_name} Just put this in chat and it works. It pulls the token name from the selected token first and then triggers the target selection.
1486536055
Jakob
Sheet Author
API Scripter
Yes, because roll20 puts the selected information in first. This it why it works with --charid (in any order). But if you looked at that message as an API event, the msg.selected property would be empty.
Jakob said: Yes, because roll20 puts the selected information in first. This it why it works with --charid (in any order). But if you looked at that message as an API event, the msg.selected property would be empty. Ah, that's why. I don't use msg.selected I think for just that reason.
1486546173
Jakob
Sheet Author
API Scripter
SkyCaptainXIII said: Jakob said: Yes, because roll20 puts the selected information in first. This it why it works with --charid (in any order). But if you looked at that message as an API event, the msg.selected property would be empty. Ah, that's why. I don't use msg.selected I think for just that reason. It does have one huge advantage in that it can handle multiple tokens, whereas @{selected} will just pick one of the selected tokens.
1486547784

Edited 1486547920
Ravenknight
KS Backer
Jakob said: Indeed, that's the one disadvantage of --sel vs --charid @{selected|character_id} (short explanation: roll20 clears your selection if a message contains a target statement). You'll have to try fixes b,c, or maybe use --name @{selected|character_name} ? Never mind - I'm an idiot. Thanks. :)
1486548023

Edited 1486548093
Jakob
Sheet Author
API Scripter
Ravenknight said: Jakob said: Indeed, that's the one disadvantage of --sel vs --charid @{selected|character_id} (short explanation: roll20 clears your selection if a message contains a target statement). You'll have to try fixes b,c, or maybe use --name @{selected|character_name} ? No luck for me, I'm afraid. I'm already using version 1.21 so it looks like I'm stuck with 1.14. But if you use 1.2.1, then --charid works! (Unfortunately, the limitation for --sel combined with @{target|...} is inherent to Roll20). EDIT: everything's solved, cool :).
This is from the Shaped Companion thread, but thought I should move it over here.  I'm trying to get the correct api command to set all npc tokens to 1. Automatically revert (dis)advantage 2. Automatically expend spell resources 3. Show Character Name on roll templates From what you gave me on the other thread, I've got this much so far: !setattr --auto_revert_advantage|1 --automatically_expend_spell_resources|1 --allgm However, for the Show Character name element, when I inspect it, I can find the name (show_character_name), but I can't find the "value."  It's not a checkbox but a drop down toggle for "yes" or "no"  The line, when I inspect it, looks like this: <select class="sheet-no-shrink" name="attr_show_character_name" dir="rtl"></select> How would I put this in the above macro?
1488468280
Jakob
Sheet Author
API Scripter
Ah, selects work a bit differently. You'll have to expand the select, then you can see something like this: <select name="attr_output_option"> <option value="" data-i18n="PUBLIC_FOR_ALL" selected="selected">Public for all to see</option> <option value="/w GM" data-i18n="WHISPERED_TO_GM">Whispered to the GM</option> <option value="?{Output|Public,|Whisper,/w GM }" data-i18n="CHOOSE_WHEN_ROLLING">Choose when rolling</option> </select> You can take the values from within the <option> elements.
Well, I'm a little out of my depth here - let me paste a screenshot of what I see when I expand the select: So it looks like I need to take the value "{{show_character_name=1}}" ?  So if I put it together with my previous efforts, I should use: !setattr --auto_revert_advantage|1 --automatically_expend_spell_resources|1 --show_character_name|{{show_character_name=1}} --allgm Is that right?
1488479947
Jakob
Sheet Author
API Scripter
That's right! :)
Hey, it worked!  Thanks for your help.
Thank you so much! This is a godsend for my Mutant Chronicles game as NPC's have different stats than PCs not covered by the character sheet. Thank you so much!
Hello,  Can someone explain to me why this command: !setattr --sel --replace --DmgMult|(1+0.1*`{TarukajaMod})*(1-(0.1*(floor(`{target\|Vi}/10)))-(0.1*`{target\|RakukajaMod})) Only registers the first backlash in the line, and treats the other one normally? What I end up getting in the attribute is (1+0.1*`{TarukajaMod})*(1-(0.1*(floor(`{target\|Vi}/10)))-(0.1*`{target\  And then in the max value I get RakukajaMod}))
1490683330

Edited 1490684449
Jakob
Sheet Author
API Scripter
Erl K. said: Hello,  Can someone explain to me why this command: !setattr --sel --replace --DmgMult|(1+0.1*`{TarukajaMod})*(1-(0.1*(floor(`{target\|Vi}/10)))-(0.1*`{target\|RakukajaMod})) Only registers the first backlash in the line, and treats the other one normally? What I end up getting in the attribute is (1+0.1*`{TarukajaMod})*(1-(0.1*(floor(`{target\|Vi}/10)))-(0.1*`{target\  And then in the max value I get RakukajaMod})) Oh no, regular expressions misbehaving! I'll investigate. EDIT: I think I know what the problem is. I will remodel the way I deal with the splitting to fix it.
1490686302
Jakob
Sheet Author
API Scripter
Okay, the problem should be fixed, Erl.
Jakob said: Okay, the problem should be fixed, Erl. Thanks! That was much faster than I hoped for.
Does this work on the Shaped sheet for Traits? Also can I use it to expend spell slots/points? I've been trying everything to set the trait attributes with this and it says it's setting it to 0 but it's not doing anything. Maybe I'm doing something wrong but I can get it to work with equipment no problem.
1491330584
Jakob
Sheet Author
API Scripter
Jerry F. said: Does this work on the Shaped sheet for Traits? Also can I use it to expend spell slots/points? I've been trying everything to set the trait attributes with this and it says it's setting it to 0 but it's not doing anything. Maybe I'm doing something wrong but I can get it to work with equipment no problem. Yes. What are you trying to do respectively entering (and isn't that covered by the companion script, except for spell points?) ?
Jakob said: Jerry F. said: Does this work on the Shaped sheet for Traits? Also can I use it to expend spell slots/points? I've been trying everything to set the trait attributes with this and it says it's setting it to 0 but it's not doing anything. Maybe I'm doing something wrong but I can get it to work with equipment no problem. Yes. What are you trying to do respectively entering (and isn't that covered by the companion script, except for spell points?) ? I use chatsetattr to adj spell slots for sorcery points and vice versa. 
I love this script! A few requests, if possible: !modbattr as shorthand for !setattr --modb --silente to suppress both output and error messages Thanks for all your hard work!
Would anybody happen to know the command to set a drop down menu in shaped sheet? I have figured out that the check boxes are a simple 0 or 1, but cannot figure out how to set critical_damage which gives a list of 3 options when selected. I tried entering 2 (I want critical damage maximized) but that didn't work. Also tried the text of the option with and without quotes without it working
1492104834
Jakob
Sheet Author
API Scripter
Silvyre said: I love this script! A few requests, if possible: !modbattr as shorthand for !setattr --modb --silente to suppress both output and error messages Thanks for all your hard work! Thanks! I can implement those, both are easy to do. Though --silente is terrible from a linguistic perspective - I'll have to think about an alternative name that feels better for me. Gary W. said: Would anybody happen to know the command to set a drop down menu in shaped sheet? I have figured out that the check boxes are a simple 0 or 1, but cannot figure out how to set critical_damage which gives a list of 3 options when selected. I tried entering 2 (I want critical damage maximized) but that didn't work. Also tried the text of the option with and without quotes without it working That's what you see in the dev tools when you right click -> inspect the select for the critical damage. The <option> elements are all the options for the select, and the stuff inside value="..." is what you want to set your attribute to. For maximized critical damage, you would enter --critical_damage_houserule|CRITICAL_DAMAGE_IS_MAXIMIZED Does that make sense?
Very much so- thanks!
Jakob said: Silvyre said: I love this script! A few requests, if possible: !modbattr as shorthand for !setattr --modb --silente to suppress both output and error messages Thanks for all your hard work! Thanks! I can implement those, both are easy to do. Though --silente is terrible from a linguistic perspective - I'll have to think about an alternative name that feels better for me. You already have --silent.... quest that means you need to work off the suppress aspect.  How about -squash   :)
1492132348
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
--mute
1492197975
Jakob
Sheet Author
API Scripter
keithcurtis said: --mute Oh, I like that. 1.3 !modbattr is now a shorthand for !setattr --modb --mute will disable all chat output. Implies --silent.
Awesome, thanks!