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

[Help][Script] ChatSetAttr is acting real weird.

1663105494

Edited 1663113452
Hi folks, I've been working on my campaign, setting up macros and scripts for my players to use. One of the scripts I've installed is ChatSetAttr, and it's worked wonderfully so far, but there's one  character with one  specific attribute that's just acting up and I can't for the life of me figure out why. I was hoping someone else here might've encountered the same issue or is able to help me troubleshoot the cause. The character in question has a magical item that gains 1 charge after each attack he makes, which he can spend on effects. In his macro'd attacks, I've added... !modbattr --silent --charid -Mw-28cIKLIcOgEKhd6H --repeating_resource_$1_resource_left|+1 !!! ...in order to keep track of the number of charges he has. I've also added an activation macro to the character that'll post in chat what action he uses the charges on, and resets the number of charges to 1 when he uses it. It looks like this. !setattr --silent --charid -Mw-28cIKLIcOgEKhd6H --repeating_resource_$1_resource_left|1 !!! The thing is, whenever the first line of code is run, it also adds 6 to his passive_wisdom  score for some reason. Whenever the second line of code is run, it also sets his passive_wisdom  to 1 . I've used the exact same  code for other characters without having any issues, so I started troubleshooting in an attempt to fix it. In one of my many attempts, I noticed that if I added another set of repeating resources, changed the code to $2 instead of $1, and ran it again, then it worked without messing with passive_wisdom . The issue only appears when repeating_resource_$1_resource_left or  right  is used to track the charges. Now, an easy solution would be to just not use that resource line, skipping it all together for the character. But I'd really prefer to find a solution to the problem, so if I run into it again in the future, I know how to fix it. Edit: We're playing D&D, using the 5e OGL sheet. Figured providing the full code ahead of time for both causations might help anyone who wishes to help. Activating the item: &{template:desc} {{desc=Adrian activated the ?{Which ability?|Bonus to Attack,bonus to Attack|Bonus to Damage,bonus to Damage} ability of Vengeance! **?{Number of charges?|1|2|3|4|5|6|7|8|9}** charges expended}} !setattr --silent --charid -Mw-28cIKLIcOgEKhd6H --repeating_resource_$1_resource_left|1 !!! !token-mod --ids -Mw-28cIKLIcOgEKhd6H --current_page --set bar2_value|1 Adding charges on attacks: !modbattr --silent --charid -Mw-28cIKLIcOgEKhd6H --repeating_resource_$1_resource_left|+1 !!! !token-mod --ids -Mw-28cIKLIcOgEKhd6H --current_page --set bar2_value|+1 Any help is appreciated! Thanks in advance, - Jakob F.
I think I figured it out, but would still appreciate a confirmation. When I don't have both ChatSetAttr and TokenMod in the macro, it works as intended. But as soon as I have both it breaks something  in the api and/or character sheet. Can anyone confirm?
1663118140
timmaugh
Pro
API Scripter
I haven't noticed a problem like this, Jakob, but as a start, I don't think your ChatSetAttr call needs the trailing triple-bangs. That's for if you have it embedded in another command line (like a roll template) and you want it to still be detected and run. In your case, your CSA call is on a new line, so it will effectively be a new message already. Also, what is the purpose of the token-mod line? You explained that the charges are on the $1 resource, which you're altering using the CSA line. So what is bar2 used for, and why do you need to alter it with Token-Mod? And, finally, you said that you didn't have this trouble on other characters... but you also mention that using resource $1 is the problem. So... have you tried tracking a resource on $1 for a different character? Do you get the same result?
1663119693

Edited 1663119891
Oosh
Sheet Author
API Scripter
edit - niiiiinjaaaaa'd, probably should've hit the 'submit' button half an hour ago instead of leaving the post sitting there while I had a philosophical experience with caffeine.... Those macros all work as expected for me - I'd probably delete the problem row and add it back in, and see if that helps. Also, what do you have bar2 linked to? You also don't need to be using !!! there - that's specifically for using CSA in the middle of a roll template and grabbing the displayed inline rolls, you don't need to terminate lines with it normally. It's probably not doing anything bad by being there, but you never know. Apart from a one-in-a-bajillionty-trillion chance of the two attributes having had a UID collision, I can't think of any way a static attribute could have become tangled with a repeating row. You could also check the passive perception modifier, @{selected|passiveperceptionmod}, both before and after PP gets messed up by the macro. edit2- you can also check for a collision by running this script on sandbox startup (as unlikely as it seems, I guess it's possible) on('ready', () => { const charId = `-Mw-28cIKLIcOgEKhd6H`, char = getObj('character', charId), attrs = findObjs({ type: 'attribute', characterid: charId }), ids = attrs.reduce((out, a) => /(resource_left$|^passive)/.test(a.get('name')) ? [ ...out, [ a.get('name'), a.id ] ] : out, []) sendChat('attrIds', `/w gm &{template:default} {{name=checkIds ${char.get('name')}}} ${ids.map(id => `{{${id[0]}=${id[1]}}}`)}`); });
1663174751

Edited 1663175312
timmaugh I haven't noticed a problem like this, Jakob, but as a start, I don't think your ChatSetAttr call needs the trailing triple-bangs. That's for if you have it embedded in another command line (like a roll template) and you want it to still be detected and run. In your case, your CSA call is on a new line, so it will effectively be a new message already. Oosh You also don't need to be using !!! there - that's specifically for using CSA in the middle of a roll template and grabbing the displayed inline rolls, you don't need to terminate lines with it normally. It's  probably  not doing anything bad by being there, but you never know. Ah. I saw a video about the script where he said it had to be used with the script. Probably misunderstood that it was only required when used in another command line. Will update accordingly! :) timmaugh Also, what is the purpose of the token-mod line? You explained that the charges are on the $1 resource, which you're altering using the CSA line. So what is bar2 used for, and why do you need to alter it with Token-Mod? Oosh Also, what do you have bar2 linked to? I use bar2 on the characters token, so the player can more easily check how many charges he's at. As far as I've been able to find in other posts, it's impossible to link a repeating resource to a bar. Is that incorrect? By the gods, it's an issue with token-mod, not ChatSetAttr. I never (don't ask me why, I don't have an answer) thought to test with only one of them... I apologize for that. Should've spent maybe just 5 minutes of my 4 hour troubleshooting trying that.  I think I know why it bugs then. Bar2 was previously set to track their passive wisdom for my ease. It's now set to none , but it seems like that the token hasn't forgotten that it was once tracking passive wisdom there. I tried to set it to temporary hit points , save the token settings, then set it to none , and now the temporary hit points are also changed when I run the !token-mod  command. The easy solution would be to just redo the token then, right? And be careful not to modify the attribute that represents a bar except for hit points, which'll always be in the bar assigned to it.   Edit: Tried that, still changes passive wisdom for the character. I'm not sure what to do now.
1663177314
Oosh
Sheet Author
API Scripter
That's an interesting interaction... from the sounds of it, token bars aren't de-linking the attribute when you switch them to 'none'. Definitely a bug, but not sure if it's new or not. Good investigative work though - it's probably related to the other bar linking issues folk have been having with Wildshape, and other token bar interactions. This is definitely a Roll20 issue - Aaron can potentially come up with a temporary workaround for TokenMod, but that isn't where the problem lies.
That explains it then. It's good to know! Do you know if the developers have given a timeline for the fix? Thanks for the help though. Glad to know what's going on, even if there's nothing I can do about it for now :)