I have updated from MapTool 1.5.10 to 1.7.0 just recently. After that, some of my macros have raised errors because of the map names I have used on my campaign. To sort special maps I have placed their names on square brackets like "[Lobby]" or "[Home Base]". On 1.5.10 this worked without problems, but raising errors on 1.7.0.
Now I have renamed this maps with simple brackets like "( Lobby )" and "( Home Base )" and changed my macros - that works.
Is this a behavior like desireded or an error?
Kind regards
from Purzelkater
Map names with square brackets
Moderators: dorpond, trevor, Azhrei, giliath, jay, Mr.Ice
- Purzelkater
- Cave Troll
- Posts: 41
- Joined: Thu Oct 31, 2019 3:45 am
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: Map names with square brackets
It would be helpful if you let the devs know what functions aren't working with brackets...Purzelkater wrote: ↑Thu Sep 17, 2020 7:57 amI have updated from MapTool 1.5.10 to 1.7.0 just recently. After that, some of my macros have raised errors because of the map names I have used on my campaign. To sort special maps I have placed their names on square brackets like "[Lobby]" or "[Home Base]". On 1.5.10 this worked without problems, but raising errors on 1.7.0.
I don't know whether it's a bug (or a fix.) But if there are restricted characters for map names then it would be helpful if the associated areas that allow you to name or change a map's name enforced those restrictions (New Map, Rename, Edit, and associated macros.)Is this a behavior like desireded or an error?
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."
- Purzelkater
- Cave Troll
- Posts: 41
- Joined: Thu Oct 31, 2019 3:45 am
Re: Map names with square brackets
I have made a little sample about the issue:
I have added some maps to my campaign: "[Lobby]", "(Spaceport)" and "Cantina".
Then I have made a little macro:
Now I get an error: Map "Lobby" not found on function "getTokenNames"
A simple "getAllMapNames()" returns: [Lobby],(Spaceport),Cantina
But with
I get this output:
I think the double quotes are the problem here. As said, on MT 1.5.10 was no problem with the same code.
I have added some maps to my campaign: "[Lobby]", "(Spaceport)" and "Cantina".
Then I have made a little macro:
Code: Select all
[r: "<b>List of PCs</b><br>"]
[h: mapNames = getAllMapNames()]
[foreach(mapName, mapNames, ""), code: {
[r: "Map: "+mapName+"<br>"]
[h: conditions = json.set("{}", "pc", 1, "mapName", mapName)]
[h: playerTokenNames = getTokenNames(",", conditions)]
[h, foreach(playerTokenName, playerTokenNames, ""), code: {
[r: "PC: "+playerTokenName+"<br>"]
}]
}]
A simple "getAllMapNames()" returns: [Lobby],(Spaceport),Cantina
But with
Code: Select all
[r: "<b>List of Maps</b><br>"]
[h: mapNames = getAllMapNames()]
[foreach(mapName, mapNames, ""), code: {
[r: "Map: "+mapName+"<br>"]
}]
Code: Select all
List of Maps
Map: ["Lobby"]
Map: (Spaceport)
Map: Cantina
Re: Map names with square brackets
It would also be helpful if there were documentation on it somewhere in the wiki, but I can't figure out where it should be.Full Bleed wrote: ↑Mon Sep 21, 2020 12:48 am
It would be helpful if you let the devs know what functions aren't working with brackets...
- Full Bleed
- Demigod
- Posts: 4736
- Joined: Sun Feb 25, 2007 11:53 am
- Location: FL
Re: Map names with square brackets
It seems like when the parser sees [Lobby] it sees it as a malformed json array and it just converts it to a "proper" array which messes up the output you want.Purzelkater wrote: ↑Mon Sep 21, 2020 1:50 amA simple "getAllMapNames()" returns: [Lobby],(Spaceport),Cantina
But withI get this output:Code: Select all
[r: "<b>List of Maps</b><br>"] [h: mapNames = getAllMapNames()] [foreach(mapName, mapNames, ""), code: { [r: "Map: "+mapName+"<br>"] }]
Code: Select all
List of Maps Map: ["Lobby"] Map: (Spaceport) Map: Cantina
So something must have changed in that area.
But, like I said, this may have been done to fix some other issues where malformed arrays were causing problems... but if it's going to stay the way it is now they should just invalidate using brackets in map names.
For now you could do this to "fix" the output:
Code: Select all
[h: mapName = if(json.type(mapName) == "ARRAY", "["+json.get(mapName, 0)+"]", mapName)]
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."