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 to copy a value

Hello, This seems like it should be fairly simple but I'm stumped! Any help is welcome. I have 2 tokens, ids are -ORzDcN_9lq8G40BtRF_  and   -ORzDiK1FBXQ6_5IUSPz What tokenmod command can I use to copy the bar1 value from the second to the first token (using hardcoded ids). Thanks :)
1749166032
Andrew R.
Pro
Sheet Author
You could do that with ScriptCards, of course, and you can use Fetch from the MetaScript Toolbox to read the values from the second token. Tokenmod only writes the values, it doesn’t read them. 
1749183028
timmaugh
Forum Champion
API Scripter
Andrew is correct about some script solutions, but you might be able to do it even short of that. Certain properties are available via Roll20 syntax... like bar values: @{selected|bar1} @{target|bar1} You CANNOT get a bar value from Roll20 syntax when using a name, however: @{Ruby|bar1} NOTE: This DOESN'T work ...because you could have any number of tokens on the board representing the character "Ruby." Back to the Roll20 formations that work... while you can use both the @{selected} and @{target} syntax in the same command line (and they will both resolve to values), when you use an @{target} construction in the command line you lose all of your selected tokens for the purpose of the message. Your @{selected} constructions will resolve but there will be no selected tokens when the message reaches TokenMod... which normally wants to operate on the SELECTED token. But you can work around this a bit. Option 1 TokenMod also allows you to designate the IDs of tokens to work on (instead of looking for selected tokens, it will work on the ids provided). If a non-GM wants to do this, you have to configure a setting in TokenMod, but otherwise GMs can do this natively. So one option is you can use the --ids argument for the receiving token, and use @{target} syntax to get the values you want. Let's say you wanted to copy the bar1 current and max values from one token to the other: !token-mod --ids  @{selected|token_id} --set bar1|@{target|Pick Source|bar1}|@{target|Pick Source|bar1|max} Or, if you didn't want to have to select the destination token every time (to use the @{selected} syntax), you could use the hard-coded token id instead: !token-mod --ids  -ORzDcN_9lq8G40BtRF_ --set bar1|@{target|Pick Source|bar1}|@{target|Pick Source|bar1|max} Option 2 The MetascriptToolbox will work in the TokenMod command and do things for you, including letting you designate a token to "virtually select". The token isn't *actually* selected on your board, but the message (and TokenMod) will act as if it is. Then, instead of using the --ids argument for TokenMod, you could use an {&select} formation instead: {&select @{selected|token_id} } ...or, again using the hard-coded id: {&select  -ORzDcN_9lq8G40BtRF_ } That command line would look like: !token-mod --set bar1|@{target|Pick Source|bar1}|@{target|Pick Source|bar1|max}  {&select  -ORzDcN_9lq8G40BtRF_ } ...and doesn't require any TokenMod configuration to allow players to use IDs. Option 3 Use the Metascript Toolbox, but use Fetch to read the values for you while you keep the destination token selected: !token-mod  --set bar1|@( -ORzDiK1FBXQ6_5IUSPz. bar1)|@( -ORzDiK1FBXQ6_5IUSPz. bar1_max) Although, if those tokens have names and they are *uniquely* named on the current page of your game, then you could use their names, instead, to make it more readable: !token-mod  --set bar1|@(Julius Squeezer . bar1)|@( Julius Squeezer. bar1_max) Bonus If you don't want to have to select the recipient, you can combine the above Fetch constructions to get the token_id of the recipient by name, and use it in a {&select} tag from the previous option to arrive at a command that is pretty hands of. Go Forth There are more ways to set this up using the Toolbox, and that doesn't even get to the capacity to do this with ScriptCards that Andrew mentioned... so there are a lot of options to do what you're looking to do! If one of these doesn't work, post back with more specifics and we can get you sorted.
1749212105

Edited 1749212209
Thank you both. After a bit of fiddling around I've managed to do what I was trying to achieve using your 'Option 3' and 'Bonus' option. Aim Recreate this puzzle -&nbsp; <a href="https://www.jaapsch.net/puzzles/circle.htm" rel="nofollow">https://www.jaapsch.net/puzzles/circle.htm</a> &nbsp; Proof of Concept I had expected the macro to run one line at a time and so, I would need to use Bar1 &amp; Bar2 as a buffer to transfer the current side between the multi-sided tokens. Then I'd need to tackle nested macros or similar to force the steps in sequence. Luckily, i t turns out that it runs all at once, so I could swap round the sides in one go. One oddity is that if you fetch the currentside of a token, it indexes it starting with 0, but when you set the currentside, it indexes starting with 1. Solution Macro: West !token-mod {&amp;select Wedge-A} --set currentside|{&amp;math @(Wedge-D.currentside) +1} !token-mod {&amp;select Wedge-B} --set currentside|{&amp;math @(Wedge-A.currentside) +1} !token-mod {&amp;select Wedge-C} --set currentside|{&amp;math @(Wedge-B.currentside) +1} !token-mod {&amp;select Wedge-D} --set currentside|{&amp;math @(Wedge-C.currentside) +1} Example Starting Position Example: Solved Position &nbsp; Next Steps It's good enough to stick in a game as a quick puzzle as it is, but I'll probably replace the images to something a bit more thematic. I don't think the orientation of any of the wedges can be switched round and there is no limit to the number of sides the tokens can have, so it should be possible to turn it into a puzzle to construct an image.
1749260143
timmaugh
Forum Champion
API Scripter
Interesting!
1749309506
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
Yes, Interesting! This particular puzzle is also used in Baldur's Gate 3.
A word of warning -&nbsp; If you spam click the macro, at least one of the tokens will go out of sync and have the wrong side. Also, don't 'undo' (ctrl-z). That will also break it. In short, it's 'good enough' for a quick puzzle but don't rely on it. &nbsp;