Making a list of visible Tokens - change for new version

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

Moderators: dorpond, trevor, Azhrei

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
Kallatari
Kobold
Posts: 17
Joined: Fri Apr 26, 2013 9:07 pm

Making a list of visible Tokens - change for new version

Post by Kallatari »

I've just installed version .b91, and it's changed how my attack macro works with respect to selecting a target. Specifically, in version .b89, it only included tokens that were located on the Token layer, but not those in the Hidden, Object, or Background layer. Now, in .b91, it includes all the tokens from all the layers. So every token I've added for furniture is now on the list.. worse, so are the maps in the background. It makes the list unwieldy. I'd like to have it as it was before, so I'm requesting assistance in improving my coding for this.

Please note, I have very limited coding knowledge. Everything I have, I've copied/pasted from elsewhere until something worked... so please have patience if I come back with more questions.

Here's what I have now (the relevant parts, as far as I can tell):

[h: lsVisibleTarget = json.sort(getExposedTokenNames("json"),"a") ]
[h: assert(json.length(lsVisibleTarget), "No visible target", 0)]


and

[h: ok = input(
"junk | <html><b><u>Attacking with "+Attack.Description+"</u></b><br></html> | Attacking with | LABEL | SPAN=true",
"junk | <html><br><u>Target Information and Situation</u><br></html> | Target Information | LABEL | SPAN=true",
"Target.Name |"+json.toList(lsVisibleTarget)+"| Target | LIST",

...<snipped rest as I don't think it's relevant>
) ]
[h: abort (ok) ]};
{}]



Also, another strange issue. Typically (from my use in v .b89) a token doesn't appear on the list until the players have spotted it. So anything behind a vision blocking wall is off the list until the player moves around the corner. Once spotted, it remains on the list even if it later goes behind such a wall. I'm fine with that. Since I put in version .91, for some reason, some tokens that haven't been spotted that are behind walls appear on the list, but others do not. It appears to be limited by range (only the close ones appear), but even then there's a mix of what is spotted or not. Is this a bug?

Thanks in advance

Kallatari

User avatar
wolph42
Winter Wolph
Posts: 9999
Joined: Fri Mar 20, 2009 5:40 am
Location: Netherlands
Contact:

Re: Making a list of visible Tokens - change for new version

Post by wolph42 »

here you go:

Code: Select all

<!-- get all tokens from the token layer and store in json array -->
[h:allToks    = getTokenNames("json",'{layer:["TOKEN"]}')]
<!-- get all exposed tokens from map -->
[h:allExp    = getExposedTokenNames("json")]
<!-- get the intersection of all token layer tokens and all the exposed tokens -->
[h:tokExp    = json.intersection(allToks, allExp)]
 
as for the other issue. You do realise that there are two similar but distinct functions? :
Wiki: getExposedTokenNames()
Wiki: getVisibleTokenNames()

Kallatari
Kobold
Posts: 17
Joined: Fri Apr 26, 2013 9:07 pm

Re: Making a list of visible Tokens - change for new version

Post by Kallatari »

That seems to have worked. Thank you.

Post Reply

Return to “MapTool”