moving a token on background layer

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
xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

moving a token on background layer

Post by xavram »

I added a macro to a token on the Background layer, like so...

Code: Select all

[h : tokenX = getTokenX(0)]
[h : tokenY = getTokenY(0)]
[h : moveToken(tokenX+1,tokenY, 0)]
I THOUGHT what this would do, when clicked, would be to move that token 1 grid cell over on the x coordinate. Instead, I just get an error.

   Error in body of roll.       Statement options (if any): h       Statement Body : tokenX = getTokenX(0)

What gives? I've tried with Apply to Selected Tokens checked on and off, same error.

This seems relatively straightforward so puzzled at what the issue is

User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Re: moving a token on background layer

Post by Jagged »

That error message isn't very helpful, is it?

I suspect what you need to do is uncheck the "Allow Players to Edit Macro" option.

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: moving a token on background layer

Post by xavram »

It was unchecked, but I tried it both ways, same error.

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

Re: moving a token on background layer

Post by aliasmask »

For whatever reason, there doesn't seem to be a currentToken(). You should output currentToken() just before that line.

Code: Select all

[H: broadcast("Current Token: "+currentToken())]
Also, when you start MapTool with the launcher you can check under the Advanced tab "Macro Handling". Then when you get the error you can check .maptool folder for log.txt to show the specific line and error. It will be the last line with DEBUG in it.

xavram
Dragon
Posts: 891
Joined: Tue Apr 20, 2010 8:22 pm

Re: moving a token on background layer

Post by xavram »

Hmmm...put the macro on a library token, then called it and it worked fine.

Odd, doesn't say that getTokenX or moveToken need to be called from a trusted macro...

User avatar
Jagged
Great Wyrm
Posts: 1306
Joined: Mon Sep 15, 2008 9:27 am
Location: Bristol, UK

Re: moving a token on background layer

Post by Jagged »

I copied your code directly into an empty macro, made no changes and I got the same error message as you. Then I unchecked the "allow players"option and it worked.

Post Reply

Return to “Macros”