#json help

1 messages ยท Page 1 of 1 (latest)

versed crescent
#

I didn't see what I was looking for on the wiki. Is there a "closest" condition?

#
[h:Aura = "light: { value: 1 , category: Special , name: Twilight }"]
[h:Range = "range: { upto: 6 , distancePerCell: 0 , metric: ONE_TWO_ONE , token : "+getSelected()+" }"]

[h:cond = "{ pc:1 , "+Aura+" ,"+Range+" }"]

[NameList = getTokenNames("json" , cond)]
versed crescent
#

Looks like I found a workaround.

#

Is there a way to include the selected token in the search?

languid panther
#

I do not know the cond rules for aura but I think you've got a couple things here.
distancePerCell is not right and the syntax is off I think too. Should be more like this I think?

[h:Range = '"range": { "upto": 6 , "distancePerCell": 0 , "metric": "ONE_TWO_ONE" , "token" : "'+getSelected()+'" }']

[h:cond = '{ "pc":1 , '+Aura+' ,'+Range+' }']

[NameList = getTokenNames("json" , cond)]```
#

This is an example of me searching for a PC token close to another token


[h: AlltokensOnPad = getTokens(",",condition)]```
versed crescent
#

It works fine without the quotations.

languid panther
#

Assuming fixed the distancePerCell typo?

versed crescent
versed crescent
languid panther
#

Not sure tbh

versed crescent
#

I can't really tell what the difference between "from:" and "upto:" is.

languid panther
#

"upto" you mean?

versed crescent
#

Yes thanks

languid panther
#

Like our solar system from venus, upto mars, means you'd find earth ๐Ÿ˜‰

versed crescent
#

It sound like it makes tha area non adjacent.

versed crescent
#

Sometimes I can't brain.

languid panther
#

Just don't go all mathy on me or I'm lost.

#

fwiw the proper way to load the condition var is actually via a json.set just in the use case it's a tad burdensome

#

but i'll have to play around with what I'm doing and not using the quotes ๐Ÿ˜‰

versed crescent
languid panther
#

Ahh, yes, that's right, you can specify each layer in that "layer" section "token,object,hidden,background"

#

'{"layer":["token,object,background"]

versed crescent
#

Do you know how I could get the search parameters to include the selected token?

languid panther
#

Is there only ever one selected token in the use case?

versed crescent
#

Yes, but I just got an error for trying to move more than one token. Oh no!

languid panther
#

I often use listGet(getSelected(),0) but this will only every get the first entry of whatever tokens are selected

versed crescent
#

I fix one thing, and another problem pops up

#

It's like I'm in a Bugs Bunny cartoon.

languid panther
#

If I check the wiki it has the quotes like from my example and I'm thinking that without those you're not going to get the results.

#

is the objective to find how close something is with a light source?

willow tulip
#

What's the goal. Get the nearest token on token layer to selected token?

#

You should also almost always use the json constructors to make your json rather than doing it manually.

versed crescent
#

The goal is to find a token with the aura turned on that the selected token is within range of.

#

Right now it finds them both, but it only keeps the last on in the list.

#

Like it's a variable that keeps changing without getting used first.

#

I ended up fuxing that, though.

#

Now I get an error for having multiple tokens selected.

#

Oh, the goal was to include the token with the aura, which it currently doesn't.

#

I got my initial question answered, btw.