getTokenX/Y bug

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: Azhrei, dorpond, trevor

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
xavram
Dragon
Posts: 808
Joined: Tue Apr 20, 2010 8:22 pm

getTokenX/Y bug

Post by xavram »

[broadcast(getTokenX(1, tokenId) + " vs " + getTokenX(0,tokenId))]
[broadcast(getTokenY(1, tokenId) + " vs " + getTokenY(0,tokenId))]

If you're on a square grid map, you get expected results; if token is in cell 5, 5, you get...
250 vs 5
250 vs 5

But if you're in an Isometric grid...oddness ensues

-50 vs 5
250 vs 5

I move the token down to 8,8, get...
-50 vs 8
400 vs 8

move to 8, 11, gets...
-200 vs 8
475 vs 11

I'm sure this is something to do with Isometric maps, but I can't find any kind of "conversion" that explains it.

xavram
Dragon
Posts: 808
Joined: Tue Apr 20, 2010 8:22 pm

Re: getTokenX/Y bug

Post by xavram »

I had written code to find the center, in pixels, of a token. Works fine with a square grid but is totally wrong now that I'm on an isometric grid.

I don't care if I have to write some kind of "If token is Figure, calc center differently", I just need to have the accurate center of the token.

bubblobill
Cave Troll
Posts: 99
Joined: Sun Jan 24, 2010 3:07 pm

Re: getTokenX/Y bug

Post by bubblobill »

You can use getInfo("map") to get details of the map grid type and dimensions.
It appears you are getting a multiple of "cell offset width".

Code: Select all

{ "player visible": 1, 
"image y scale": 1, 
"grid": { 
	"units per cell": 5, 
	"x offset": 0, 
	"color": "ff000000", 
	"size": 50, 
	"cell width": 100, 
	"y offset": 0, 
	"cell offset height": 0, 
	"second dimension": 0, 
	"type": "Isometric", 
	"cell height": 50, 
	"cell offset width": -50 }, 
"vision type": "off", 
"name": "Grasslands",
"width": 0, 
"image x scale": 1, 
"id": "4F38DB6B630345CB83417028541D499D", 
"creation time": 1588317430510, 
"largest Z order": 0, 
"height": 0 }

Post Reply

Return to “MapTool”