#json help
1 messages ยท Page 1 of 1 (latest)
[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)]
Looks like I found a workaround.
Is there a way to include the selected token in the search?
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)]```
It works fine without the quotations.
Assuming fixed the distancePerCell typo?
Without specifying layer, will it search all layers?
Lol yeah.
Not sure tbh
I added from: 0 hoping that would include the selected toked, but it didn't.
I can't really tell what the difference between "from:" and "upto:" is.
"upto" you mean?
Yes thanks
Like our solar system from venus, upto mars, means you'd find earth ๐
It sound like it makes tha area non adjacent.
That's what I thought, but the wording wasn't doing it for me I guess.
Sometimes I can't brain.
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 ๐
Looks like it defaults to the current layer.
Ahh, yes, that's right, you can specify each layer in that "layer" section "token,object,hidden,background"
'{"layer":["token,object,background"]
Do you know how I could get the search parameters to include the selected token?
Is there only ever one selected token in the use case?
Yes, but I just got an error for trying to move more than one token. Oh no!
I often use listGet(getSelected(),0) but this will only every get the first entry of whatever tokens are selected
I fix one thing, and another problem pops up
It's like I'm in a Bugs Bunny cartoon.
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?
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.
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.