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

ChatSetAttr and resources

I want to have a script that increments or decrements a resource on the 5E OGL sheet but based on the name of the resource. That is to say, the name I give it and not the name that it internally thinks it is. For example, suppose I have a resource named "Foo" and it happens to be @{repeating_resource_right_name} internally (at least that's what is displayed when I hover the mouse over the resource name). I'd like to do something like: !setattr --modb --sel  --Foo|-1 But that doesn't work as expected. I get a message saying that Foo is being set to 0 (it was 1) but when I look on the character sheet, the number hasn't changed in the resource box so I'm assuming that I'm creating and affecting some random new attribute called Foo. The reason for my wanting to do this is that the resource could be anywhere on the character's sheet. For instance, on one character it could be the first box on the first row but on another it could be the second resource on the third row. I want to have one macro, not one for each character. So, the question is, is there some way to access the repeating resources by their given name? In the ChatSetAttr help file, I see an example: !setattr --sel --Ammo|%Ammo_max%   and Ammo is one of the repeating resources on one of the character's sheets so I don't know why what I tried with Foo doesn't work. Can someone tell me what I'm doing wrong? Or at least tell me what will work? Thanks.
1649259783
GiGs
Pro
Sheet Author
API Scripter
You have to use the attribute name on the sheet - so !setattr --modb --sel  --repeating_resource_right_name|-1 If different players are using a different attribute, you cant use chatSetAttr or Ammo (or you need a different macro for each character). The easiest solution here is to tell players they have to use the same resource box across all character sheets - then you can use one chetSetAttr or Ammo command.
That is a repeating row, and you are calling the name field and not its actual attributes.   repeating_resource_$0_resource_right = the current value repeating_resource_$0_resource_right|max = the max value repeating_resource_$0_resource_right_name == its name This is assuming 5e by roll20 sheet.   Caveats: The first two boxes are not repeating rows, they are class_resource and other_resource.   The first repeating row is the second row down(typically the first ones you create yourself) and are numbered with a 0 not a 1 in the syntax above.   Here is a macro I made that I use to decrement/increment various things on a character sheet.  However I could not figure out how to ignore nonexistant values so this macro only works on sheets where there are 4 rows of repeating attributes all set to stuff OR 0/0 Empty.  If you set the empty boxes to the same thing then the default template detects duplicates and combines them all into one entry instead of a shit ton of errors.  The single most favorite thing about this macro is how you can have roll20 do the math for you on money changes.   /w @{selected|character_name} &{template:default} {{name=Character Manager}} {{name=@{selected|character_name}'s Character Manager}} {{Temp HP=**@{selected|hp_temp}** | [Set New value](!setattr --sel --hp_temp|?{New Value?})}} {{HP= @{selected|hp} / @{selected|hp|max}}} {{Hit Dice=@{selected|hit_dice}/@{selected|hit_dice|max}|[Expend](!modbattr --sel --hit_dice|-1)|[Refund](!modbattr --sel --hit_dice|+1)}} {{Level 1=@{selected|lvl1_slots_expended}/@{selected|lvl1_slots_total}|[Expend](!modbattr --sel --lvl1_slots_expended|-1)|[Refund](!modbattr --sel --lvl1_slots_expended|+1)}} {{Level 2=@{selected|lvl2_slots_expended}/@{selected|lvl2_slots_total}|[Expend](!modbattr --sel --lvl2_slots_expended|-1)|[Refund](!modbattr --sel --lvl2_slots_expended|+1)}} {{Level 3=@{selected|lvl3_slots_expended}/@{selected|lvl3_slots_total}|[Expend](!modbattr --sel --lvl3_slots_expended|-1)|[Refund](!modbattr --sel --lvl3_slots_expended|+1)}} {{Level 4=@{selected|lvl4_slots_expended}/@{selected|lvl4_slots_total}|[Expend](!modbattr --sel --lvl4_slots_expended|-1)|[Refund](!modbattr --sel --lvl4_slots_expended|+1)}} {{Level 5=@{selected|lvl5_slots_expended}/@{selected|lvl5_slots_total}|[Expend](!modbattr --sel --lvl5_slots_expended|-1)|[Refund](!modbattr --sel --lvl5_slots_expended|+1)}} {{Level 6=@{selected|lvl6_slots_expended}/@{selected|lvl6_slots_total}|[Expend](!modbattr --sel --lvl6_slots_expended|-1)|[Refund](!modbattr --sel --lvl6_slots_expended|+1)}} {{Level 7=@{selected|lvl7_slots_expended}/@{selected|lvl7_slots_total}|[Expend](!modbattr --sel --lvl7_slots_expended|-1)|[Refund](!modbattr --sel --lvl7_slots_expended|+1)}} {{Level 8=@{selected|lvl8_slots_expended}/@{selected|lvl8_slots_total}|[Expend](!modbattr --sel --lvl8_slots_expended|-1)|[Refund](!modbattr --sel --lvl8_slots_expended|+1)}} {{Level 9=@{selected|lvl9_slots_expended}/@{selected|lvl9_slots_total}|[Expend](!modbattr --sel --lvl9_slots_expended|-1)|[Refund](!modbattr --sel --lvl9_slots_expended|+1)}} {{@{selected|class_resource_name}=@{selected|class_resource}/@{selected|class_resource|max}|[Expend](!modbattr --sel --class_resource|-1)|[Refund](!modbattr --sel --class_resource|+1)}} {{@{selected|other_resource_name}=@{selected|other_resource}/@{selected|other_resource|max}|[Expend](!modbattr --sel --other_resource|-1)|[Refund](!modbattr --sel --other_resource|+1)}} {{@{selected|repeating_resource_$0_resource_left_name}=@{selected|repeating_resource_$0_resource_left}/@{selected|repeating_resource_$0_resource_left|max}|[Expend](!modbattr --sel --repeating_resource_$0_resource_left|-1)|[Refund](!modbattr --sel --repeating_resource_$0_resource_left|+1)}} {{@{selected|repeating_resource_$1_resource_left_name}=@{selected|repeating_resource_$1_resource_left}/@{selected|repeating_resource_$1_resource_left|max}|[Expend](!modbattr --sel --repeating_resource_$1_resource_left|-1)|[Refund](!modbattr --sel --repeating_resource_$1_resource_left|+1)}} {{@{selected|repeating_resource_$2_resource_left_name}=@{selected|repeating_resource_$2_resource_left}/@{selected|repeating_resource_$2_resource_left|max}|[Expend](!modbattr --sel --repeating_resource_$2_resource_left|-1)|[Refund](!modbattr --sel --repeating_resource_$2_resource_left|+1)}} {{@{selected|repeating_resource_$3_resource_left_name}=@{selected|repeating_resource_$3_resource_left}/@{selected|repeating_resource_$3_resource_left|max}|[Expend](!modbattr --sel --repeating_resource_$3_resource_left|-1)|[Refund](!modbattr --sel --repeating_resource_$3_resource_left|+1)}} {{@{selected|repeating_resource_$0_resource_right_name}=@{selected|repeating_resource_$0_resource_right}/@{selected|repeating_resource_$0_resource_right|max}|[Expend](!modbattr --sel --repeating_resource_$0_resource_right|-1)|[Refund](!modbattr --sel --repeating_resource_$0_resource_right|+1)}} {{@{selected|repeating_resource_$1_resource_right_name}=@{selected|repeating_resource_$1_resource_right}/@{selected|repeating_resource_$1_resource_right|max}|[Expend](!modbattr --sel --repeating_resource_$1_resource_right|-1)|[Refund](!modbattr --sel --repeating_resource_$1_resource_right|+1)}} {{@{selected|repeating_resource_$2_resource_right_name}=@{selected|repeating_resource_$2_resource_right}/@{selected|repeating_resource_$2_resource_right|max}|[Expend](!modbattr --sel --repeating_resource_$2_resource_right|-1)|[Refund](!modbattr --sel --repeating_resource_$2_resource_right|+1)}} {{@{selected|repeating_resource_$3_resource_right_name}=@{selected|repeating_resource_$3_resource_right}/@{selected|repeating_resource_$3_resource_right|max}|[Expend](!modbattr --sel --repeating_resource_$3_resource_right|-1)|[Refund](!modbattr --sel --repeating_resource_$3_resource_right|+1)}} {{Platinum= **@{selected|pp}** [Subtract](!modattr --sel --pp|-?{Just the Number.|0})|[Add](!modattr --sel --pp|+?{Just the Number.|0})}} {{Gold= **@{selected|gp}** [Subtract](!modattr --sel --gp|-?{Just the Number.|0})|[Add](!modattr --sel --gp|+?{Just the Number.|0})}} {{Silver= **@{selected|sp}** [Subtract](!modattr --sel --sp|-?{Just the Number.|0})|[Add](!modattr --sel --sp|+?{Just the Number.|0})}} {{Copper= **@{selected|cp}** [Subtract](!modattr --sel --cp|-?{Just the Number.|0})|[Add](!modattr --sel --cp|+?{Just the Number.|0})}}
1649288126

Edited 1649288165
Oosh
Sheet Author
API Scripter
There's a script over here that does exactly that for the 5e sheet. I can't remember what stage it was at, but it should work. Down the bottom of the thread Tim says he added that functionality to APILogic - if you have that installed, it would save using a specialised script, but I'm not 100% sure on the command you'd need to be sending. If you do grab findResource, it's on pasteBin so make sure you grab the raw text as the prettified stuff at the top sometimes looks like it's had the apostrophes messed with. I think it's just the syntax highlighting that's messed up, not corrupt text, but not 100% sure. I mean.... why even have Javascript syntax highlighting as an option if you can't handle backticks & quotes? Idiocy.... /rant