Hi all maptoolers,
The titles says it all...
I need to count how many "goblins" (the token label) are on the map and compare it to the number of PCs. How can I do that ?
Thanks.
How can count how many tokens have the same GM name on a map ?
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.
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.
Re: How can count how many tokens have the same GM name on a map ?
It's going to involve Wiki: getTokens(), but the details depends on the naming convention and some other things. For example, is it a big map with a lot of different creatures or is just 1 encounter map. Will/Can the creature label have other things like multiple types? What's the reason for getting this number? What about other token states like "dead" or visible to players?
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: How can count how many tokens have the same GM name on a map ?
Okay, so I need to add a little bit of context...aliasmask wrote: ↑Sun Nov 17, 2024 6:04 pmIt's going to involve Wiki: getTokens(), but the details depends on the naming convention and some other things. For example, is it a big map with a lot of different creatures or is just 1 encounter map. Will/Can the creature label have other things like multiple types? What's the reason for getting this number? What about other token states like "dead" or visible to players?
I am a Maptool newbie, trying to produce a framework for 13th Age. In this D&D-like game the Goblin Warriors do more damage when the Goblins (of any kind) outnumber the PCs.
According to the 13th Age rules, the Goblins have a type: Humanoid. So I gave to all my Goblins tokens the label "Goblin".
On a given map, I need to know if the Goblins (excluding the dead ones) outnumber the PCs, to increase the damage of the Goblin Warriors attacks.
Re: How can count how many tokens have the same GM name on a map ?
You could count the goblins in the initiative to generate a bonus for the warriors. This calculation would only happen on the Goblin Warrior token when calculating damage. The pseudo-code would be something like this.
<!-- check goblin warrior bonus damage -->
Am I a goblin warrior
Do I have advantage
getInit List
if PCcount - GoblinCount > 0, then give bonus
<!-- check goblin warrior bonus damage -->
Am I a goblin warrior
Do I have advantage
getInit List
if PCcount - GoblinCount > 0, then give bonus
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools
Re: How can count how many tokens have the same GM name on a map ?
The "goblin" information is the label of the token. How can I get the "GoblinCount" part of your macro?aliasmask wrote: ↑Mon Nov 18, 2024 5:50 amYou could count the goblins in the initiative to generate a bonus for the warriors. This calculation would only happen on the Goblin Warrior token when calculating damage. The pseudo-code would be something like this.
<!-- check goblin warrior bonus damage -->
Am I a goblin warrior
Do I have advantage
getInit List
if PCcount - GoblinCount > 0, then give bonus
I found how to get the PCcount, but I cannot do the same with the label.
Re: How can count how many tokens have the same GM name on a map ?
Code: Select all
[H: tokenIds = json.path.read(getInitiativeList(),"\$..tokenId","ALWAYS_RETURN_LIST,SUPPRESS_EXCEPTIONS")]
[H: goblins = 0]
[H, foreach(tokenId,tokenIds), code: {
[H: switchToken(tokenId)]
[H, if(getTokenLabel() == "goblin"): goblins = goblins +1]
}]
Downloads:
- Notepad++ MapTool addon
- RPEdit details (v1.3)
- Coding Tips: Modularity and Design
- Videos: Macro Writing Tools