How to obtain "selectedTokens()" but ordered with order of tokens selection

Discuss macro implementations, ask for macro help (to share your creations, see User Creations, probably either Campaign Frameworks or Drop-in Resources).

Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice

Post Reply
Sawejkr
Kobold
Posts: 1
Joined: Sun May 29, 2022 10:11 am

How to obtain "selectedTokens()" but ordered with order of tokens selection

Post by Sawejkr »

Hello, i see the wiki and i found the "getSelectedNames()" function, but this function always return a of all tokens selected ORDERED by name. I tested with differents selects orders, 1 by 1, etc. And always returned the same.
My intention is select first the "attacker" token and second the "defensive" token, and with a macro referencing his weapons and armours and automate calculate damage, etc.
Any else idea has welcome. Many Thanks.

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

Re: How to obtain "selectedTokens()" but ordered with order of tokens selection

Post by wolph42 »

this has been done in the past as well. There are several methods. I guess 'impersonated' vs 'selected' is easiest. The other method is to select the attacker, open form (that has onChangeSelection function embedded) and use that to select the target.

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

Re: How to obtain "selectedTokens()" but ordered with order of tokens selection

Post by Full Bleed »

Sawejkr wrote:
Sun May 29, 2022 10:37 am
Hello, i see the wiki and i found the "getSelectedNames()" function, but this function always return a of all tokens selected ORDERED by name. I tested with differents selects orders, 1 by 1, etc. And always returned the same.
My intention is select first the "attacker" token and second the "defensive" token, and with a macro referencing his weapons and armours and automate calculate damage, etc.
Any else idea has welcome. Many Thanks.
Select both and determine who is the Attacker and who is the Defender based on who has initiative.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Post Reply

Return to “Macros”