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

Issues with ChatSetAtt not working on some characters.

I have a set of macro buttons that have the following commands: Enlarge Person !token-mod --ids @{target|token_id} --current-page --set scale|2g !setattr --charid @{target|character_id} --strength_bonus|2 --silent !setattr --charid @{target|character_id} --dexterity_bonus|-2 --silent !setattr --charid @{target|character_id} --ac_dodge_bonus|-1 --silent Reduce Person !token-mod --ids @{target|token_id} --current-page --set scale|1g !setattr --charid @{target|character_id} --strength_bonus|0 --silent !setattr --charid @{target|character_id} --dexterity_bonus|0 --silent !setattr --charid @{target|character_id} --ac_dodge_bonus|0 --silent They work on some characters completely, others partially. TokenMod always changes the token size. Charsetatt works on some characters but not others, or only partially. Gregory has the token size doubled, but only the ac_dodge_bonus of -1 is applied. For Octavia the script works fully. The Reduce macro works the same way, for these characters. Can someone explain that?  O.o
1679502364
timmaugh
Pro
API Scripter
You're probably dropping lines from that multi-command macro. You can try using ZeroFrame to batch them up into a single message (that link goes to the batching update, which has a link to the original thread for other functionality). Using ZeroFrame, this would look like: !{{   !token-mod --ids @{target|token_id} --current-page --set scale|2g   !setattr --charid @{target|character_id} --strength_bonus|2 --silent   !setattr --charid @{target|character_id} --dexterity_bonus|-2 --silent   !setattr --charid @{target|character_id} --ac_dodge_bonus|-1 --silent }} ...and... !{{   !token-mod --ids @{target|token_id} --current-page --set scale|1g   !setattr --charid @{target|character_id} --strength_bonus|0 --silent   !setattr --charid @{target|character_id} --dexterity_bonus|0 --silent   !setattr --charid @{target|character_id} --ac_dodge_bonus|0 --silent }} Try that and see if it works better for you.
Wrapping it in ZeroFrame made it not work...at all. It's just one character so far.  I will test it on all of them and see if it's just a few or only one.
Wulfram Kane said: Wrapping it in ZeroFrame made it not work...at all. It's just one character so far.  I will test it on all of them and see if it's just a few or only one. Just to confirm, did you install ZeroFrame and confirm that your Mod sandbox is still running? Otherwise, if the issue is dropping lines from multiple commands, you can reduce your original down to 2 commands (which will be less likely to drop): Enlarge Person !token-mod --ids @{target|token_id} --current-page --set scale|2g !setattr --charid @{target|character_id} --silent --strength_bonus|2 --dexterity_bonus|-2 --ac_dodge_bonus|-1 Reduce Person !token-mod --ids @{target|token_id} --current-page --set scale|1g !setattr --charid @{target|character_id} --silent --strength_bonus|0 --dexterity_bonus|0 --ac_dodge_bonus|0 Or use a multi-line command for ChatSetAttr: Enlarge Person !token-mod --ids @{target|token_id} --current-page --set scale|2g !setattr {{ --charid @{target|character_id} --silent --strength_bonus|2 --dexterity_bonus|-2 --ac_dodge_bonus|-1 }} Reduce Person !token-mod --ids @{target|token_id} --current-page --set scale|1g !setattr {{ --charid @{target|character_id} --silent --strength_bonus|0 --dexterity_bonus|0 --ac_dodge_bonus|0 }}
Zeroframe is installed, the mods are working. I like the idea of reducing multiple lines. The macro works on some characters partially.  I wonder if there is an API interfering with it.  I see the mod for temp str appear on one char, but then disappear.  Only the ac bonus works consistently on all of them.
Which character sheet are you using? It could be that the built-in sheetworkers are automatically reverting back to a default calculated value.
1679513112
timmaugh
Pro
API Scripter
That's weird... I just tried in a new game with only one character installed, and only scripts involved in this command installed (plus my Debug script): TokenMod ChatSetAttr ZeroFrame libInline Debug You could save this little scriptlet in a new tab in your mod deck: on('ready', () => {   on('chat:message', (msg) => {     if('api' !== msg.type) return;       log(msg.content);   }); }); Then run your commands and see what hits your chat.  (Disable the scriptlet after you're done troubleshooting; it might get annoying.) When  you send your ZeroFrame-batched command across with the above scriptlet installed, you should see the initial message hit the log, then individual returns for each of the sub-lines (here, mine is still a four-line command rather than the 2 that Jarren is suggesting): Note this batching won't work with double braces *inside* the batching double-braces (the outer ones), so you can't use the multi-line form Jarren suggested. If you see something like the above, then ZeroFrame is working and the messages are being dispatched. That would point to potentially another script interfering. On that note, what scripts do you have installed?
1679514759
Kraynic
Pro
Sheet Author
On that sheet (Pathfinder by Roll20), the values you are changing can be overwritten by sheetworkers.  Anything that happens to trigger the sheetworkers to recalculate the modifiers to strength and such.  Try manually setting the temp value on the sheet and then triggering a custom buff that affects that same stat/modifier, and you will find the "Temp" field is used as the final output by the sheetworker, and will end up wiping your manual edit.  That has been my experience in the past anyway. My recommendation would be to use the built in buff system to do all the stat changes, and then use the api to apply the token size change.  I think you will run into less problems that way, even if it isn't as convenient.
OK, I found it and fixed it, with your help! Enlarge Person !token-mod --ids @{target|token_id} --current-page --set scale|2g !setattr --charid @{target|character_id} --silent --mod --strength|2 --dexterity|-2 --ac_dodge_bonus|-1 Reduce person !token-mod --ids @{target|token_id} --current-page --set scale|1g !setattr --charid @{target|character_id} --silent --strength|@{target|strength_base} --dexterity|@{target|dexterity_base} --ac_dodge_bonus|0 Next, I think I will make one button to do both of those: get the caster's name, spell name and caster level create a character attribute name- AntoniaWitchEnlargePersonLvl2 get the target check if the target has the character attribute name already alter the token and character sheet as needed - set or restore the token/character attributes if the spell is being removed - delete the attribute if the spell is being cast - add the spell to the tracker with a timer (API script)
I spoke too soon.  I ran into an issue.  Both Jarren and Kraynic mentioned sheetworker scripts undoing temporary API changes to stat changes. I believe that is exactly what is happening.  I change mod strength and it works great, until you enable or disable a buff, and then the stat reverts back to strength_base.  I wonder if I can add a buff and toggle it when a spell is cast, then when the spell ends delete the buff?
1679580040
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Why not just use the API to alter the definition of the buff, rather than mess with creation and deletion?
If I can figure out how, I might do that. At low level in my Rise of the Runelords campaign, I don't really mind having a spellcaster cast a buff on a player and have him/her toggle the buff themselves - there are relatively few spells and a low volume of casting. Later, there are lots of layered spells and it can get unwieldy to manage and track.  Think stoneskin, protection from fire, bless, prayer, bull's strength, enlarge person, etc., etc.  I think it would make my game faster and more enjoyable if a caster can cast preconfigured spells and apply them as buffs, creating them ad hoc and tracking them with added attributes, then removing the spell effects and deleting the created attributes. The way I envision it working, at a basic level, is something like: Antonia, Level 2 Witch, casts Enlarge Person on Gregory: Check to see if an attribute 'Antonia_Enlarge_Person_Lvl_2_target_Gregory (with a value of the duration, eg 20 rounds) exists (If the attribute already exists, reverse the mods to the stats and delete the buff), otherwise: Get target - Gregory Enlarge Gregory token to 2 grid units with TokenMod Create a Buff that enhances str, reduces dex, ac and melee appropriately and toggle it. Add a custom turn with the appropriate name and duration eg Enlarge Person (Antonia->Gregory) for 20 rounds The Next Thing after this would be to make one button with a dropdown to choose a spell, then call that macro to cast it.
How do you turn a Buff on with a macro? I bet you can create one with ChatSetAtt and toggle it.  I just don't know how.  I really need to learn to code.
1679591019
Kraynic
Pro
Sheet Author
I am currently playing in a game with level 14 characters.  In my opinion, it really isn't that big of a deal to have players toggle on and off certain buffs.  At least, I don't have an issue doing so as a player.  If you build them correctly, the sheet will even handle whether they stack or not by buff type (morale, enhancement, etc.).  Resistances are something that aren't going to be automatically applied to anything anyway, since they are just in a text field, so are something that the players need to remember when they are hit by something that would be reduced by that resistance.  No different than barbarian DR as an example.  If you do want to go the route of automating turning the buffs on and off, it is not different than any other repeating section attribute (for the checkbox).  However, you would need to do one of 2 things: Get the unique ID of each buff on each and every sheet and have commands specific to each character sheet to toggle the buffs.  They would be sheet and buff specific, but wouldn't give unexpected results when the order changes due to someone adding self-only class or race buffs and/or changing the order in which the buffs appear. Build toggles based on row number, but make sure that every sheet has the exact same buffs built and that they are all in the same order.  However, if anyone ever changed the order of the buffs on their sheet, then you would start getting the wrong buff being toggled on that sheet. In my opinion, some automation is more work/hassle than it is worth.  I would recommend having the players handle their own buffs and only building things for actions that players can't do on their own (like changing token size).
Thank you, Kraynic, this sounds like the voice of experience!  It's not the answer that I wanted, but it's the answer that I probably needed. I am stubborn, however, and I will probably pursue this until it becomes impractical and then several steps beyond.
1679626442

Edited 1679626561
timmaugh
Pro
API Scripter
Kraynic said:   However, you would need to do one of 2 things: Get the unique ID of each buff on each and every sheet and have commands specific to each character sheet to toggle the buffs.  They would be sheet and buff specific, but wouldn't give unexpected results when the order changes due to someone adding self-only class or race buffs and/or changing the order in which the buffs appear. Build toggles based on row number, but make sure that every sheet has the exact same buffs built and that they are all in the same order.  However, if anyone ever changed the order of the buffs on their sheet, then you would start getting the wrong buff being toggled on that sheet. I am not familiar with the structure of the sheet, but if the buffs are repeating attributes (which it sounds like), then Fetch offers loose matching by sub-attribute property, and then you can return the ID of the thing you get. Then you would neither have to first find the ID of every buff on every character, nor make sure they were in the same order. Again, I don't know the structure of the sheet, but it would look something like: *(Bob the Destroyerish.buffs.[name='Glitter Bomb'].bufftoggle.name)     ...returns something like: repeating_buffs_-MYmCb5r2v8bsl-IWdaQ_bufftoggle     ...where the name equals "Glitter Bomb" *(Bob the Destroyerish.buffs.[name~Glitter].bufftoggle.name$)     ...returns something like: repeating_buff_$1_bufftoggle     ...where the name includes "Glitter" *(Bob the Destroyerish.buffs.[name~Bomb lvl=2].bufftoggle.row)     ...returns something like: -MYmCb5r2v8bsl-IWdaQ (the id of the repeating row)     ...where the name includes "Bomb" and the lvl is 2 *(Bob the Destroyerish.buffs.[name~Bomb lvl=4].bufftoggle.row$)     ...returns something like: $1     ...where the name includes "Bomb" and the lvl is 4 *(Bob the Destroyerish.buffs.[name='Glitter Bomb' lvl=2].bufftoggle.id[not found])     ...returns something like: -M1234567890abcdef (the id of the attribute named repeating_buffs_ -MYmCb5r2v8bsl-IWdaQ_bufftoggle)     ...where the name is "Glitter Bomb" and the lvl is 2     ...with a default value of "not found" if the attribute doesn't exist One of those formations should get you the information you need to execute a ChatSetAttr manipulation of the toggle without having to know every row id, attribute id, or position. BTW, all of the things that changed between lines are interchangeable... the only thing that distinguished the lines was the thing we asked to return (name, name$, row, row$, or id). The rest (what pattern we are looking for, whether to have a default value, whether we use a character name or a selected or targeted token, etc.) is all up to your need.
Weird.  I can't get anything with Fetch, it just repeats the command. The player name is Dale(greg), the token name is Gregory. I put @(Gregory.tid) in a macro button and test it, the chat outputs @(Gregory.tid) What am I doing wrong?  Fetch is installed, my API Sandbox is fine.
1679686534
GiGs
Pro
Sheet Author
API Scripter
This isn't about Fetch, its about macros in general. Do not use the token name - use the character name.
Tried this...here is a screenshot...
Fetch is installed. Sandbox is OK.
1679689273

Edited 1679697734
timmaugh
Pro
API Scripter
So, as a metascript, Fetch requires the command start as a bangsy message. That means that in a command intended for the Script Moderator, the Fetch construction would resolve. This (starting with a bang): !@(Gregory.tid) ...would become... !-M1234567890abcdef (or something similar). But that message is still, from there, going to go through the stack of scripts you have installed (and not hit the chat -- ie, you're not going to see the output). So you could use it in a TokenMod call: !token-mod --ids @(Gregory.tid) --set bar1|+1 If you want to *see* what Fetch returns (for instance, to make sure it's finding what you want it to find), you need a way to view the end result. You could do that with TokenMod and write the return into a bar, the tool tip, etc., or you could use ChatSetAttr and write it to an attribute. Or, you could do like I do and use the {&simple} construct from ZeroFrame. That will take the end result of the metascript processing and send it through a new chat message (this one intended to hit the chat output). So you could do something like: !The value is @(Gregor.tid) {&simple} Or, if you had a bunch of info you wanted to return, you could put it in a roll template: !&{template:default}{{name=Data for Gregory}}{{Token ID=@(Gregory.tid)}}{{Position=(@(Gregory.top),@(Gregory.left))}} {&simple} Once you're sure you're getting a return from Fetch, then you can start to try the constructions that will return a repeating item (those are a bit more complex). But, to GiGs' point, when you're returning *character* level information (like a repeating attribute), use the CHARACTER name. Most of the time, the token name and character name are the same, but in the cases where they are NOT the same, you'll need to use the character's name to get a character attribute.
1679691581

Edited 1679697611
timmaugh
Pro
API Scripter
If you have trouble identifying the list and the sub attribute you need to return, you can use In spector to drill down. Easiest way is to select the token, and run: !inspect --selected Then click on the link beside the token ID. When you get the panel of information for the token, pull down to the represents property and click on the link next to the ID there. Now you will be looking at the character. As a bottom of that panel will be a button to show the repeating lists. Find the appropriate buffs list, and then find the sub attribute for the toggle that you need to actually switch. You will see the name and from there you can break down the fetch construction.
<prostrates himself, salaams frantically) /em I'm not worthy, I'm not worthy!!