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

Page CellWidth

1583711345
Finds
API Scripter
Quick question, I'm looking to set the top/left coordinates of a token adjusting them by a specified amount. I would like to keep this simple using squares as the unit of measure (typically multiplied by 70px) however I'd like to get that value from the page if possible but I couldn't find where that info is stored. Anyone have a simpler solution or know how to get the page CellWidth data?
1583736794
Dumbhuman
Pro
Marketplace Creator
You might want to check out TokenMod.  You could, for instance, set a token to move three grid squres left and two grid squares up by entering the following: !token-mod --set left#-3g top#-2g Quoting from the relevant help section for TokenMod: Numbers Number values can be any floating point number (though most fields will drop the fractional part). Numbers must be given a numeric value. They cannot be blank or a non-numeric string. Available Numbers Properties: left top width height scale It's probably a good idea not to set the location of a token off screen, or the width or height to 0. Placing a token in the top left corner of the map and making it take up a 2x2 grid section: !token-mod --set top|0 left|0 width|140 height|140 You can also apply relative change using + , - , * , and / . This will move each token one unit down, 2 units left, then make it 5 times as wide and half as tall. !token-mod --set top|+70 left|-140 width|*5 height|/2 You can use = to explicity set a value. This is the default behavior, but you might need to use it to move something to a location off the edge using a negative number but not a relative number: !token-mod --set top|=-140 scale is a pseudo field which adjusts both width and height with the same operation. This will scale a token to twice it's current size. !token-mod --set scale|*2 You can follow a number by one of u , g , or s to adjust the scale that the number is applied in. Use u to use a number based on Roll20 Units, which are 70 pixels at 100% zoom. This will set a graphic to 280x140. !token-mod --set width|4u height|2u Use g to use a number based on the current grid size. This will set a token to the middle of the 8th column, 4rd row grid. (.5 offset for half the center) !token-mod --set left|7.5g top|3.5g
1583753782
The Aaron
Roll20 Production Team
API Scripter
If you're wanting to write your own script for it, the information on grid size is in the Page object: &nbsp; <a href="https://wiki.roll20.net/API:Objects#Page" rel="nofollow">https://wiki.roll20.net/API:Objects#Page</a>
1583775265
Finds
API Scripter
Thanks for the reply; yes my question was more along the lines of building my own script. @The Aaron I did find that reference on Page Objects however I didn't see which property reflected page Cell Width As lets say I issue a command to a script which the end result would be to move a token 3 squares (multiplying 3x the 70px) I just can't find where that page information of 70px is stored
1583778511
keithcurtis
Forum Champion
Marketplace Creator
API Scripter
if you mean that 70px value in the middle? That's hard coded, I believe. i.e. that's the screen resolution of one cell.
1583781188
The Aaron
Roll20 Production Team
API Scripter
It's snapping_increment, basically. 70px x snapping_increment = grid cell width. &nbsp;snapping_increment x grid_scale gives you the distance in grid units (often ft).&nbsp; There is a bit of strangeness when the snapping_increment isn't 1 and the grid is off, but you probably won't see that from the API.&nbsp; If you look at TojenMod's source, there's a class called numberOp that does all the math for grid and unit based scales:&nbsp; <a href="https://github.com/shdwjk/Roll20API/blob/6027687c36eaa69989db8b329f28856a4da833e7/TokenMod/TokenMod.js#L148" rel="nofollow">https://github.com/shdwjk/Roll20API/blob/6027687c36eaa69989db8b329f28856a4da833e7/TokenMod/TokenMod.js#L148</a>