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

Using tokenMod macro's in a custom character sheet button? Doesn't work?

1693367462
Daniel S.
Pro
Marketplace Creator
Sheet Author
I've been attempting to replicate an existing macro I have that works beautifully, into a button existing on the character sheet. I find it's much easier to use that way, and easier to explain to players to use. However, it doesn't seem to do anything. I'm trying to get bar1 to subtract a value equal to the value in one of the repeating rows from the sheet. In this case that value is "cutattack". This is the code in the sheet                  value='&{template:dodas1} {{name=@{character_name} @{weapon} }} {{attack=[[2d6 + @{cutattack}]] [[2d6 + @{cutattack}]][[2d6 + @{cutattack}]]}} {{Base Damage= @{cutdamage} swing or shoot}} {{Extra Dmg Dice= [1](~repeating_weapons_1d6extradamageswing) [2](~repeating_weapons_2d6extradamageswing) [3](~repeating_weapons_3d6extradamageswing) [4](~repeating_weapons_4d6extradamageswing) [5](~repeating_weapons_5d6extradamageswing) }} {{Notes=@{other}}} !token-mod --set bar1_value|[[ @{selected|bar1} - @{cutattack}]] ' In the VTT, when I press up to see the code, it clearly registers the correct number  from the sheet in the final @{cutattack} value dispayed. But it does not change the bar. For reference, here is the macro button that works fine and subtracts from bar1.                       '&{template:dodas1} {{name=@{selected|character_name} @{selected|repeating_weapons_$0_weapon} }} {{attack= +[[?{Roll modifier|0}]] = [[2d6 + ?{Roll modifier|0}]] [[2d6 + ?{Roll modifier|0}]] [[2d6 + ?{Roll modifier|0}]] }} {{Base Damage=@{selected|repeating_weapons_$0_cutdamage} swing or shoot}} {{Base Damage= @{selected|repeating_weapons_$0_cutdamage} swing or shoot}} {{Roll Dmg Dice= [1](~selected|repeating_weapons_$0_1d6extradamage) [2](~selected|repeating_weapons_$0_2d6extradamage) [3](~selected|repeating_weapons_$0_3d6extradamage) [4](~selected|repeating_weapons_$0_4d6extradamage) [5](~selected|repeating_weapons_$0_5d6extradamage) }} {{Notes=@{selected|repeating_weapons_$0_other}}} ' !token-mod --set bar1_value|[[ @{selected|bar1} - ?{Roll modifier|0}]] Wondering if you just can't use token mode inside the character sheet? Or if there's some other way around things? Maybe is there some javascript possible to implement to have a macro inside the sheet code that changes bar values? Thanks!!
1693367981
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Hi Daniel! Without diving too deep into the code, the first thing I notice is that the top macro does not have a return before the token mod command. The parser won't recognize an API command that begins in the middle of a text string.
1693368903
Daniel S.
Pro
Marketplace Creator
Sheet Author
I tried giving the token mode line it's own line in the code, if that's what you meant. Now the token mod line just shows up in chat at the end of the table template, but still no change in the token bar.
1693369091

Edited 1693369137
Daniel S.
Pro
Marketplace Creator
Sheet Author
After some more twiddling, I found the solution! Thanks so much for the feedback! It turns out, I had some beautifying in the character sheet code, so the button macro was indented. This carried over into the macro in Roll20. Removing the spacing in the sheet, so that the button and token mode command start at the beginning of the line, resolved the issue and it works now. Awesome!