foreach issue

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
User avatar
mfrizzell
Dragon
Posts: 762
Joined: Sat Feb 13, 2010 2:35 am
Location: California

foreach issue

Post by mfrizzell »

I'm curious to know why the following code display once for each token selected not just once at the end of the macro. Any help would be appreciated.

Code: Select all

<!-- Passive Perception Check -->
[h: dudesToCheck = getSelected()]
[h: PassiveList = " "]
[FOREACH(dude, dudesToCheck, "<br>"), CODE:
{
[h: switchToken(dude)]
[h: WisMod = getProperty("mlf.WisdomMoD")]
[h: ProfBonus = getProperty("mlf.ProficiencyBonus")]
[h: TotalPassive = 10 + WisMod + ProfBonus]
[h: name = getProperty("mlf.Name")]
[h: PassiveList = setStrProp(PassiveList, name, TotalPassive)]
}]
[r: PassiveList]
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."

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

Re: foreach issue

Post by Full Bleed »

mfrizzell wrote:I'm curious to know why the following code display once for each token selected not just once at the end of the macro.
Do you have "Apply to Selected Tokens" selected in the macro?
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
mfrizzell
Dragon
Posts: 762
Joined: Sat Feb 13, 2010 2:35 am
Location: California

Re: foreach issue

Post by mfrizzell »

Yep, that was it thanks. I've been away from macro writing for a couple of years and finding that I've forgotten quite a few things.
DCI/RPGA# 7208328396 Skype ID mfrizzell77
Characters:
Strabor - Dwarf Avenger 5th Level
Tikkanan - Human Warlock 2nd Level
----------------------------------------------------
"People are more violently opposed to fur than leather because it's safer to harass rich women than motorcycle gangs."

Post Reply

Return to “Macros”