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] Copying Attribute between two tokens or characters

Hello,
Is the en API script to copy a set of attributes from a character to another ?

April 03 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

You should be able to it with chatSetAttr. It's in the one-click installer.

Yes i use it quite a lot, but i don't know how to copy an attributes from a character to another with it. 

April 04 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

You can use attribute calls just like in any macro @{selected|attribute-name} or whatever, and have that as the value that is being written to the new sheet.

Yes i do that for a lot of macro.
But is this possible to have a macro like this ?

!setattr --sel --weapon_damage|@{target|weapon_damage} 
Because if i use "target" the script does not work.

April 04 (4 years ago)

Edited April 07 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

I cant test it right now, but try coercing that into a number:

!setattr --sel --weapon_damage|[[@{target|weapon_damage}]]

If the weapon_damage is an autocalc attribute it probably won't work.

Hmmm ok, maybe there is a script to link an attribut between two character sheet ?

April 07 (4 years ago)

Edited April 07 (4 years ago)
Dumbhuman
Pro
Marketplace Creator


Darshyne said:

Yes i do that for a lot of macro.
But is this possible to have a macro like this ?

!setattr --sel --weapon_damage|@{target|weapon_damage} 
Because if i use "target" the script does not work.

The reason the script isn't working with target as you're using it is because --sel won't work in that scenario.  As soon as you're using target, you lose the selection on the original token.  Instead you'll have to use --charid to identify the character whose attributes are being changed.  You can either hardcode that value into a command or use target twice to provide it as in the example below:

!setattr --charid @{target|Copying To|character_id} --weapon_damage|@{target|Copying From|weapon_damage}

The "Copying To" and "Copying From" sections are just naming the targets so that you're clicking them in the proper order, but you can change those names to whatever makes sense to you.

Thank you it's working nice! I just have to delete "|Copying From" otherwise it do not work.

April 07 (4 years ago)
GiGs
Pro
Sheet Author
API Scripter

Well spotted KC.

Darshyne, be careful there. If you are using target with two different characters, you need that middle label. It doesnt have ti to be Copying From, it can be anything, but it needs to be different from the first one. You could use

@{target|destination|character_id}

and

@{target|source|character_id}

but it's best to have something in there, to distinguish the two characters.

April 07 (4 years ago)
Dumbhuman
Pro
Marketplace Creator


Darshyne said:

Thank you it's working nice! I just have to delete "|Copying From" otherwise it do not work.

Strange that Copying To doesn't present a problem then.  Maybe try just "To" and "From"?  As long as it works and you know which order to click on the tokens though, hopefully it's good enough.


My bad, it's ok ;)