getTokens range with No_Grid question

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

getTokens range with No_Grid question

Post by xavram »

I'm trying to get back all the tokens on the Object layer that are within 500 pixels of the calling token, so my conditional json looks like...

{"range":{"upto":500,"metric":"NO_GRID","token":"0000000095C600855203000000000000"},"layer":"Object"}

However, when I call "getTokens" with this, I get back ALL the tokens on the Object layer, no matter the distance from the calling token. Am I doing this wrong?

User avatar
aliasmask
RPTools Team
Posts: 9029
Joined: Tue Nov 10, 2009 6:11 pm
Location: Bay Area

Re: getTokens range with No_Grid question

Post by aliasmask »

Maybe include distancePerCell parameter because despite having no grid there is a cell size set and perhaps the default is 1.

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

Re: getTokens range with No_Grid question

Post by xavram »

So I tried that both ways but I'm still getting everything on the object layer

Image

The grid is set at 150, so you can see that the cars are clearly more than 50 away from the oil slick. But this (where the distancePerCell is set to 1, 0, or ommitted)...

Code: Select all

	[h: cond = '{ "range": {"upto":50, "distancePerCell " : 0, "metric" : "NO_GRID",  "token":"' + Car + '"}, "layer": "Object"}']
	[h: AllDropped = getTokens("json", cond)]
...is still returning the oil slick, when it should be out of range.

Any other ideas?

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

Re: getTokens range with No_Grid question

Post by xavram »

My other option is just to use this, then do a distance check to each token and if its within 50, then perform the calculations on it. But that's extra work/processing that I had thought "getTokens" would effectively handle for me.

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

Re: getTokens range with No_Grid question

Post by xavram »

Figured out the problem...I had the Pixels per cell set to 150 but NOT the Distance per cell. That was set (for some reason) to 15, so was messing everything up.

getTokens is now working fine!

Post Reply

Return to “Macros”