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

TokenMod: Referencing current height, width, or scale?

Hello! I use a lot of visuals in my Roll20 games, often putting multiple images adjacent to each other on a black background. Unfortunately, my brain demands symmetry, so Tokenmod has helped with these: !token-mod --set height| 300 width| 400 Followed by something like: !token-mod --set top|[[( 300 /2)+10 ]] left|[[( 400 /2)+10]] Unfortunately, not all of my images are sized the same. For the first step, I obviously use: !token-mod --set scale|2 But for the second step, it would be nice to just use: !token-mod --set top|[[( @{selected|height} /2)+10]] top|[[( @{selected|width} /2)+10]] Unfortunately, that produces a syntax error, but that's not my problem. I can't get the height or width to read at all . I was attempting to match height of one token to another token like so: !token-mod --set height|@{target|height} '''Note: I know this will cause the selected image to become warped, but... one problem at a time. The error received was: "No attribute was found for targeted token by the name of height." I cannot find anything in the help document on referencing those attributes. Is this possible with TokenMod? Thank you!
Unfortunately token attributes are not able to be referenced (with a few exceptions such as token_name, bar1, bar2, bar3) without using a Mod script.  So when you use @{selected|height}, Roll20 is looking for an attribute  named 'height'  on a linked character sheet. TokenMod can divide by a number, or add to a number, but I don't believe you can do both in a single operation, and TokenMod doesn't have any way of allowing you to reference the image height or width.  You can use Fetch to get the image properties of a token with @(selected.height) and @(selected.width), but I'm getting a syntax error when trying to use them. (It seems that TokenMod doesn't like the Fetch construction inside double brackets, but that's as far as I've gotten so far.) !token-mod --set top|[[ @(selected.height) /2+10]] left|[[ @(selected.width) /2+10]] Hopefully someone else can jump in and give a little more advice, but I wanted to at least let you know that your initial attempt was not going to be successful without additional script. I'm also a little confused about what you want the end result to do. Are you trying to center the image on the page? Or line up images so that they are in a row with a 10px space between them?
1687558045
timmaugh
Pro
API Scripter
Jarren has it mostly right... The only thing is that since Fetch runs as a metascript (which is still in the script timing, just FIRST in that timing), it runs *after* Roll20 has done roll parsing... So that inline roll would fail. To get around that, install ZeroFrame as well. ZeroFrame let's you defer inline rolls. The number of backslashes are the number of deferrals (ie, how many things are waiting on other things, and how many cycles will that take to resolve). In this case, only one deferral is necessary: [\][\]@(selected.height)/2+10\]\] I'm away from my computer right now, but if this isn't clear enough, I can give a better example later.
Sorry not to reply sooner, thank you both for the responses.  I'm also a little confused about what you want the end result to do. Are you trying to center the image on the page? Or line up images so that they are in a row with a 10px space between them? The latter; line up images in a row with 10px space between them.  I can give Fetch and ZeroFrame a try, though I suppose it's a little involved just to appeal to my compulsive desire for alignment and consistency. Appreciate the help!
Dr. VB said: Sorry not to reply sooner, thank you both for the responses.  I'm also a little confused about what you want the end result to do. Are you trying to center the image on the page? Or line up images so that they are in a row with a 10px space between them? The latter; line up images in a row with 10px space between them.  I can give Fetch and ZeroFrame a try, though I suppose it's a little involved just to appeal to my compulsive desire for alignment and consistency. Appreciate the help! Ah then that command is not going to work. It is referencing the dimensional size height/width of the selected token, not it’s position. But I’m pretty sure you’ll be able to use Fetch to get the ‘top’ and ‘left’ from the selected token, and then add 10 to the width to move it into a horizontal alignment with a 10px space.