Call macro on gaining initiative

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
Xenuite
Cave Troll
Posts: 27
Joined: Sun Nov 08, 2009 8:37 am

Call macro on gaining initiative

Post by Xenuite »

I've tried a couple of different iterations of this, none of which have worked.

When a token gains initiative, I want it to check that token for a specific state. If that state is active ("1") on the token that has initiative, I then want the macro to call another macro stored on the Lib:Token with the token that has initiative as the focus.

Code: Select all

[h:nextInitiative()]
[h:InitToken=getInitiativeToken()]
[h,token(InitToken),code:{
     [h,if(getState("Dying")==1),code:{
          [token(InitToken),macro("setDeathSaves@Lib:Token"):""]
     }]
}]
This is the current iteration, though I've tried several, even using selectTokens() to select the token I want to execute the macro on, and nothing sticks. The called macro runs, but with no token or the wrong token in focus.

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

Re: Call macro on gaining initiative

Post by Full Bleed »

This works for me:

Code: Select all

[h: nextInitiative()]
[h: InitToken = getInitiativeToken()]
[h, token(InitToken), CODE:
	{
		[h, if(state.Dying == 1), CODE:
			{
				[MACRO("setDeathSaves@Lib:Token"):""]
			}
		]
	}
]
Make sure "Apply to Selected Tokens" is unchecked.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Xenuite
Cave Troll
Posts: 27
Joined: Sun Nov 08, 2009 8:37 am

Re: Call macro on gaining initiative

Post by Xenuite »

Unfortunately, this still isn't working for me.

It tries to run the setDeathSaves@Lib:Token macro, but returns an unresolved value for DeathSaves, which is a json array on the PC token that has two values, one for successes, and one for failures. For reference, here's the macro it's calling.

Code: Select all

[h:status=input(
"success|0,1,2,3|Successes|RADIO|ORIENT=H SELECT="+json.get(DeathSaves,0),
"failure|0,1,2,3|Failures|RADIO|ORIENT=H SELECT="+json.get(DeathSaves,1)
)]
[h:abort(status)]
[h:DeathSaves=json.set(DeathSaves,0,success)]
[h:DeathSaves=json.set(DeathSaves,1,failure)]
[h,if(json.get(DeathSaves,0)==3),code:{
[h:setState("Stable",1)]
[h:setState("Dying",0)]
};{
[h:setState("Stable",0)]
[h,if(HitPoints==0):setState("Dying",1)]
}]
[h,if(json.get(DeathSaves,1)==3),code:{
[h:setState("Dead",1)]
[h:setState("Dying",0)]
};{
[h:setState("Dead",0)]
[h,if(HitPoints==0):setState("Dying",1)]
}]
[macro("characterSheet@Lib:Token"):""]

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

Re: Call macro on gaining initiative

Post by Full Bleed »

Xenuite wrote:Unfortunately, this still isn't working for me.
Well, it is doing what you asked. You're just not passing along the information you need to the setDeathSaves macro.
It tries to run the setDeathSaves@Lib:Token macro, but returns an unresolved value for DeathSaves, which is a json array on the PC token that has two values, one for successes, and one for failures. For reference, here's the macro it's calling.
Look at [macro:] and send DeathSaves as a macro argument.
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”