token of "name" count

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
User avatar
silbrulf
Cave Troll
Posts: 78
Joined: Sun Apr 22, 2018 5:54 am

token of "name" count

Post by silbrulf »

I know I saw how to do it (think I did do it as an exercise a few weeks ago) but I can't find it now.
How do I set a macro to count how many tokens with a given "thing" (specifically a certain gm name) exist. Not majorly important, but I have a map that needs a set number of three types of token and counting them (they don't appear in a nice pleasing order) is a pain.

I get the feeling I'm going to have one of *those* moments when I see the answer.
Still learning macros, so anything in my code I could do in a simpler way would be appreciated.

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

Re: token of "name" count

Post by wolph42 »

assuming the 'thing' is a token state its something like:

Code: Select all

[h:toks = getTokens(",", json.set("{}","setSTate", "Thing", "layer", json.append("[]","TOKEN","HIDDEN","OBJECT","BACKGROUND")))]
[h:numToks =  listCount(toks)]
[r:"Number of tokens with 'thing': " + numToks]

User avatar
Full Bleed
Demigod
Posts: 4736
Joined: Sun Feb 25, 2007 11:53 am
Location: FL

Re: token of "name" count

Post by Full Bleed »

silbrulf wrote:
Fri Jun 29, 2018 1:06 am
How do I set a macro to count how many tokens with a given "thing" (specifically a certain gm name) exist. Not majorly important, but I have a map that needs a set number of three types of token and counting them (they don't appear in a nice pleasing order) is a pain.
You can Wiki: getTokens() and then loop through the list of tokens (probably using a foreach_(roll_option)) checking each with Wiki: getGMName().
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
silbrulf
Cave Troll
Posts: 78
Joined: Sun Apr 22, 2018 5:54 am

Re: token of "name" count

Post by silbrulf »

@wolph, actually... The thing I was wanting to look for was the "dm name". Either "queen" or "parliament". Then have a frame up that I can refresh for a running count of how many of each are placed. Specifics on the token are less important than having the numbers right.

@full bleed, I know I have used those before somewhere in the tutes... But I can't recall how they work. Ill check the wiki in a few and see...
Still learning macros, so anything in my code I could do in a simpler way would be appreciated.


Post Reply

Return to “MapTool”