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

Shaped Sheet- question on manipulating available uses via macro

What is the process to have a macro to add one use to a character trait? If the API is able to reduce the uses available it has to reduce the available usage count it should be able to raise it as well.
1478353697
Jakob
Sheet Author
API Scripter
Gary W. said: What is the process to have a macro to add one use to a character trait? If the API is able to reduce the uses available it has to reduce the available usage count it should be able to raise it as well. As far as I know, there is no functionality in the companion script to modify uses of a trait directly apart from reducing it by 1 if cast and resetting it on a rest. If you want to modify uses via macro, you have to use a separate script like  Ammo or  ChatSetAttr .
1478450292
Kryx
Pro
Sheet Author
API Scripter
Jakob is correct, you'd have to use something like ChatSetAttr for this. What is it for?
I am a big fan of spending time setting up the campaign before we play, so that the rules and mechanics slip into the background. Shaped Sheet has proven to be a huge part of being able to do this. What I am looking to do is set up a macro where the bard grants insight to a player through a macro, which gives the player 1 bardic inspiration use. Easy to track the loss on the bards sheet- but having trouble automating the inspired player
1478458725
Kryx
Pro
Sheet Author
API Scripter
Ah, ya, that may be problematic to automate.
1478461811

Edited 1478461937
Silvyre
Forum Champion
As a stopgap, you could give the bard a TokenMod macro that adds a status marker to a targeted Token. e.g. !token-mod --set statusmarkers|strong:1 --ids @{target|Inspiring who?|token_id}
1478510377
Jakob
Sheet Author
API Scripter
Hmm, TokenMod has an option allowing players to manipulate tokens they do not own by ID. I could add a similar option for ChatSetAttr, if I figure out how the GlobalConfig stuff works. But I believe that a statusmarker is a better choice for this use case.
Thank you for all the responses-  I think I will give each character a new trait called Bardic Inspiration with a max of 1 usage. Every character will have it in the same spot on the trait/feature list. So long as ChatSetAttr lets me refer to that trait as $1 it should work, right?
1478527632

Edited 1478538172
Jakob
Sheet Author
API Scripter
Gary W. said: Thank you for all the responses-  I think I will give each character a new trait called Bardic Inspiration with a max of 1 usage. Every character will have it in the same spot on the trait/feature list. So long as ChatSetAttr lets me refer to that trait as $1 it should work, right? Kind of . There's 2 problems: 1) But note Edit 2 below for a more elegant solution.  ChatSetAttr doesn't know if your traits have been reordered. So it really needs to be the second (- first is $0) trait created  on that character, not the second trait in the current list, for it to refer to the correct trait with $1 (sorry, technical limitation, API does not know the row number). You will need to delete all current traits (save 1), add your inspiration trait, then re-add the rest. 2) Currently, ChatSetAttr does not allow your players to modify attributes on characters they do not control. I'll add a setting for this to ChatSetAttr, but for now, you can take the current Github code and just replace the checkPermissions function (lines 420-437) by checkPermissions = function (list, errors, playerid) { let control, character, remove = []; _.each(list, function (id, k) { character = getObj('character', id); if (!character) { errors.push(`Invalid character id ${id}.`); remove.push(k); } }); _.each(remove.reverse(), i => list.splice(i,1)); return list; }, Then something like !setattr --mod --charid @{target|character_id} --repeating_trait_$0_uses|1 should work. EDIT: In fact you better just use !setattr --charid @{target|character_id} --repeating_trait_$0_uses|1 without the --mod, since you just want to set uses to 1. EDIT 2: You don't need to change all the traits to be in spot 1. Indeed, you can also create an extra attribute (say inspiration_id) on every PC that just holds the repeating row id of the bardic inspiration trait, e.g. -KncB78ShdcB6sdGcb2E. Then you could do it with !setattr --charid @{target|character_id} --repeating_trait_@{target|inspiration_id}_uses|1