UDF not working if called without token selected

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

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. :)
Post Reply
Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

UDF not working if called without token selected

Post by Merudo »

EDIT: I had Apply to Selected Token on. Turning it off solved my issue :)

For one of my projects, I'm unable to use a UDF if called from the Campaign view and no token is selected.

I get no error message, no output, no change. It is as if the function was never called.

If I use a regular macro() call instead, everything is peachy.

This seems to apply to every UDF in my current project. However, if I create a new project, the UDF I define work just fine.

Maybe there are some strange configuration issues with my current project?

As is, I'm considering replacing all my UDFs with macro calls to avoid this bug.

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: UDF not working if called without token selected

Post by aliasmask »

If you're not going to select a token to run a UDF, then have the Apply to Selected unchecked. This is true for UDFs and regular macro calls. Apply to Selected requires you have a macro selected, duh ;)

So, as a side note the Impersonated Token may not be the currentToken().

There is one weird thing though about running macros and switchToken(). If a player is logged in as the token name switched to, then it also becomes the impersonated token. Not sure if this happens during the macro or after the macro runs. Just another MT quirk.

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

Re: UDF not working if called without token selected

Post by Full Bleed »

aliasmask wrote:
Mon Jul 01, 2019 7:10 pm
There is one weird thing though about running macros and switchToken(). If a player is logged in as the token name switched to, then it also becomes the impersonated token. Not sure if this happens during the macro or after the macro runs. Just another MT quirk.
I've seen this before (some macros seeming to trigger impersonation)... but wasn't sure what was causing it. So this is new info to me and I might be able to use it trigger impersonation of player tokens when my players login so they don't have to do it manually every time.

I've always lamented not being able to setImpersonate via a macro since impersonation is essential in my framework. But last time I brought this up I ended up getting shot down because, of course, we have Wiki: switchToken() and I'm doing it wrong if I don't just use that... had I understood that better early on I probably would have avoided impersonation completely... it just muddies the water.
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Re: UDF not working if called without token selected

Post by Merudo »

Full Bleed wrote:
Mon Jul 01, 2019 10:03 pm
I've seen this before (some macros seeming to trigger impersonation)... but wasn't sure what was causing it.
I noticed that if you have "Apply to Selected Tokens" enabled, it automatically impersonates the selected token for the duration of the macro. Not so if you have it disabled.

User avatar
aliasmask
RPTools Team
Posts: 9031
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: UDF not working if called without token selected

Post by aliasmask »

Merudo wrote:
Tue Jul 02, 2019 4:23 pm
Full Bleed wrote:
Mon Jul 01, 2019 10:03 pm
I've seen this before (some macros seeming to trigger impersonation)... but wasn't sure what was causing it.
I noticed that if you have "Apply to Selected Tokens" enabled, it automatically impersonates the selected token for the duration of the macro. Not so if you have it disabled.
I would try not to use the language "impersonate". Apply to selected makes the current token the currentToken(). I loops through all the selected tokens and runs the macro for each of them. Impersonation is a chat only thing.

Merudo
Giant
Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Re: UDF not working if called without token selected

Post by Merudo »

aliasmask wrote:
Wed Jul 03, 2019 12:33 am
Merudo wrote:
Tue Jul 02, 2019 4:23 pm
Full Bleed wrote:
Mon Jul 01, 2019 10:03 pm
I've seen this before (some macros seeming to trigger impersonation)... but wasn't sure what was causing it.
I noticed that if you have "Apply to Selected Tokens" enabled, it automatically impersonates the selected token for the duration of the macro. Not so if you have it disabled.
I would try not to use the language "impersonate". Apply to selected makes the current token the currentToken(). I loops through all the selected tokens and runs the macro for each of them. Impersonation is a chat only thing.
I use "impersonation" as what is returned when using the function hasImpersonated() and getImpersonated().

When using getImpersonated() in a macro it returns the impersonated token, unless if you have "Apply to Selected Tokens" enabled in which case getImpersonated() returns the current token... Very nonintuitive to say the least!

Post Reply

Return to “MapTool”