#Campaign Macro or user defined function?

1 messages · Page 1 of 1 (latest)

faint narwhal
#

I have a macro defined on a library token. It's serving as a User Defined Function, loaded via onCampaignLoad. It works fine.

The macro needs access to two properties on the token that called it. At the moment I am passing them manually as arguments on each invocation of the function. Is there some way for a called function to access the properties of the token that called it? That would be handy.

odd wharf
#

Doesn't it already do that, though? Or am I completely misunderstanding you?

raw thunder
#

In most cases, lib macros are run using the context of the token that called them. So a lib macro getProperty("strength") will give you the strength of the user's token if called from there.
This context can get lost though as you cascade through macros calling other macros, i.e. nested UDFs.
currentToken() will tell you which token currently has the ball.

#

You can use getProperty("strength", currentToken())

#

This tick box may solve all your problems

faint narwhal
#

Oh. It literally does what I want without any changes at all.

I'm not sure why I assumed that the called macro would not have access to the calling token's properties. But clearly that was a dumb assumption on my part.

Thanks for clearing that up, it's made my code and my life simpler.