Page 1 of 2

CopyToken broken?

Posted: Sat Feb 29, 2020 7:52 am
by venger
Hi
I'm running MT 1.5.12
I last did some coding around december or so. And I seem to remember copytoken macro I made worked but I had a lot going on and its fuzzy and dunno if I just visualized it working
anyway

I'm getting this error
java.lang.NullPointerException error executing expression copyToken(EncounterShip, 1, "z.Tokens.Encounters")

The map I'm working with is named properly as the variable and I have a properly named set of tokens on that map.
I've been over the code but Im still learning. Does the below code look ok? Why do I get the error?

Code: Select all

[h:status=input(  
"EncounterShip|Armada, Beholder.EyeSpike, Beholder.Tyrant, Dragonfly, DragonShip, Drakkar, Flitter, Gadabout, Galleon, GrandBombard, Hammership, Hummingbird, Illithid.Nautiloid, Man-o-War, Mosquito, Neogi.DeathSpider, Neogi.MindSpider, SkeletonShip, Squidship, Tradesman, Wasp|SELECT: Which Ship?|RADIO|SELECT=0 VALUE=STRING"
)]

[h: copyToken(EncounterShip, 1, "z.Tokens.Encounters")]

Re: CopyToken broken?

Posted: Sat Feb 29, 2020 7:54 pm
by aliasmask
Nothing stands out with the syntax. Do you get the error with any selection? I know MT can be weird with the . in names sometimes depending on context. I say reduce your list to 1 item, output the result from input, change the map name of token and see if something works, then go backwards from there to see where the failure is.

Re: CopyToken broken?

Posted: Sat Feb 29, 2020 8:05 pm
by Mortuis
I'm having the same problem. I'm building a new macro, so far it's just:

Code: Select all

[h: copyToken("Magic Circle", 1, "Macro Map")]
I've quadruple checked the spelling of the token I'm trying to copy and the name of the map. When I click the macro I get:

java.lang.NullPointerException error executing expression copyToken("Magic Circle", 1, "Macro Map").

Re: CopyToken broken?

Posted: Sat Feb 29, 2020 8:28 pm
by aliasmask
My other thought would be permissions. I'm going to set up a test with 1.5.13 first.

Re: CopyToken broken?

Posted: Sat Feb 29, 2020 8:35 pm
by aliasmask
Okay, I'm getting the same error in 1.5.13. It seems there's a bug with the conditions option. If you put "{}" for the last parameter it should work fine. I'll log the bug for the next fix.

Re: CopyToken broken?

Posted: Sat Feb 29, 2020 8:38 pm
by aliasmask
Apparently, this is a known issue: https://github.com/RPTools/maptool/issues/1300

Re: CopyToken broken?

Posted: Sun Mar 01, 2020 4:38 pm
by Mortuis
Thanks aliasmask! Adding that as the fourth parameter fixed it for me!

Re: CopyToken broken?

Posted: Mon Mar 02, 2020 3:51 pm
by venger
Please advise, following the github comments,it looks like it may be some time before bug's squashed so I want to do the work around as mentioned by adding the {}
so,fourth parameter?

I'm not on step with all of the syntax , where does {} go in my code?
Tried it a few places I thought it might go to no avail, but better I ask here and learn the lesson of... why it goes where it does?
A Short answer is ok
Thanks

Re: CopyToken broken?

Posted: Mon Mar 02, 2020 4:33 pm
by Full Bleed
venger wrote:
Mon Mar 02, 2020 3:51 pm
I'm not on step with all of the syntax , where does {} go in my code?
Tried it a few places I thought it might go to no avail, but better I ask here and learn the lesson of... why it goes where it does?
A Short answer is ok
Haven't tested, but presumably:

Code: Select all

[h: copyToken(EncounterShip, 1, "z.Tokens.Encounters", {})]

Re: CopyToken broken?

Posted: Mon Mar 02, 2020 7:13 pm
by venger
I tried the above code Fullbleed,
Same error I got with the spots I tried.

Line 1:50: unexpected char: '{'

Re: CopyToken broken?

Posted: Tue Mar 03, 2020 12:15 am
by Full Bleed
venger wrote:
Mon Mar 02, 2020 7:13 pm
I tried the above code Fullbleed,
Same error I got with the spots I tried.

Line 1:50: unexpected char: '{'
Please share the macro.

Re: CopyToken broken?

Posted: Tue Mar 03, 2020 6:57 am
by venger
https://drive.google.com/open?id=1oCLtu ... WhLRJ0d8Qu

Here is my Token FullBleed
It's a representation of the PC's flagship I would control at a F2F game so for now I'm putting macros on it.
The macros are to set up Spelljammer type encounters and handle various combat things

The macro in question is titled "1.Add a Ship" which is to copy a token from the "z.Tokens.Encounters" map

---------------------
If you have the time, could you please look at this, is not a bug
I provided the token because before this issue, I was pondering a solution for the macro next to it, "1.Initiate Encounter" and would have been posting about it.

The macro is ok up until Step 7 (typo in the remarks as a second Step 6 in the code, sorry)

My Tactical map is a hex vertical
The token graphic shows the facings as a number, and I call them bearings.

Macro purpose: Reposition the encounter token relative to the PCFlagship, on a random bearing and distance.
My code handles placing the Encounter token adjacent to PCFlagship on a relative bearing, but I cant resolve what code or logic needed to move the token to its random 1d10+10 distance away on that bearing. I'm stymied for a solution.
I left my code out regarding that move, none of it worked. Not even close

Any tips, snippets, info whatsoever is greatly appreciated
Thanks

Re: CopyToken broken?

Posted: Tue Mar 03, 2020 8:25 am
by aliasmask
Put quotes around the braces:

Code: Select all

[h: copyToken(EncounterShip, 1, "z.Tokens.Encounters", "{}")]

Re: CopyToken broken?

Posted: Tue Mar 03, 2020 8:45 am
by venger
Yes Aliasmask that did it, thank you.
I see now its like a place holder for a parameter or something like that

Re: CopyToken broken?

Posted: Tue Mar 03, 2020 11:25 am
by Phergus
Yes. There were two bugs. copyToken() without the updates parameter just flat failed while passing the parameter worked but spewed a bogus error message.

Fixed in 1.5.14.