Map names with square brackets

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
User avatar
Purzelkater
Cave Troll
Posts: 41
Joined: Thu Oct 31, 2019 3:45 am

Map names with square brackets

Post by Purzelkater »

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

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

Re: Map names with square brackets

Post by Full Bleed »

Purzelkater wrote:
Thu Sep 17, 2020 7:57 am
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.
It would be helpful if you let the devs know what functions aren't working with brackets...
Is this a behavior like desireded or an error?
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.)
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

User avatar
Purzelkater
Cave Troll
Posts: 41
Joined: Thu Oct 31, 2019 3:45 am

Re: Map names with square brackets

Post by Purzelkater »

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:

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>"]
	}]	
}]
Now I get an error: Map "Lobby" not found on function "getTokenNames"

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>"]
}]
I get this output:

Code: Select all

List of Maps 
Map: ["Lobby"] 
Map: (Spaceport) 
Map: Cantina 
I think the double quotes are the problem here. As said, on MT 1.5.10 was no problem with the same code.

taustinoc
Dragon
Posts: 518
Joined: Mon Aug 03, 2015 6:30 pm

Re: Map names with square brackets

Post by taustinoc »

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...
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.

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

Re: Map names with square brackets

Post by Full Bleed »

Purzelkater wrote:
Mon Sep 21, 2020 1:50 am
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>"]
}]
I get this output:

Code: Select all

List of Maps 
Map: ["Lobby"] 
Map: (Spaceport) 
Map: Cantina 
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.

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", "&#91;"+json.get(mapName, 0)+"&#93;", mapName)]
Maptool is the Millennium Falcon of VTT's -- "She may not look like much, but she's got it where it counts."

Post Reply

Return to “Macros”