diff --git a/src/main/java/net/rptools/maptool/client/functions/DrawingFunctions.java b/src/main/java/net/rptools/maptool/client/functions/DrawingFunctions.java
index b6c5b820d4..074e12fe17 100644
--- a/src/main/java/net/rptools/maptool/client/functions/DrawingFunctions.java
+++ b/src/main/java/net/rptools/maptool/client/functions/DrawingFunctions.java
@@ -23,7 +23,6 @@
import net.rptools.lib.MD5Key;
import net.rptools.maptool.client.MapTool;
import net.rptools.maptool.client.MapToolUtil;
-import net.rptools.maptool.client.ui.zone.ZoneRenderer;
import net.rptools.maptool.language.I18N;
import net.rptools.maptool.model.GUID;
import net.rptools.maptool.model.Zone;
@@ -210,24 +209,6 @@ protected Layer getLayer(String layer) {
return Layer.TOKEN;
}
- /**
- * Find the map/zone for a given map name
- *
- * @param functionName String Name of the calling function.
- * @param mapName String Name of the searched for map.
- * @return ZoneRenderer The map/zone.
- * @throws ParserException if the map is not found
- */
- protected ZoneRenderer getNamedMap(String functionName, String mapName) throws ParserException {
- for (ZoneRenderer zr : MapTool.getFrame().getZoneRenderers()) {
- if (mapName.equals(zr.getZone().getName())) {
- return zr;
- }
- }
- throw new ParserException(
- I18N.getText("macro.function.moveTokenMap.unknownMap", functionName, mapName));
- }
-
/**
* Looks for a drawing on a specific map that matches a specific id and returns its pen. Throws a
* ParserException
if the drawing is not found.
diff --git a/src/main/java/net/rptools/maptool/client/functions/DrawingGetterFunctions.java b/src/main/java/net/rptools/maptool/client/functions/DrawingGetterFunctions.java
index 8677a60463..56ef1ab21b 100644
--- a/src/main/java/net/rptools/maptool/client/functions/DrawingGetterFunctions.java
+++ b/src/main/java/net/rptools/maptool/client/functions/DrawingGetterFunctions.java
@@ -61,7 +61,7 @@ public Object childEvaluate(
FunctionUtil.checkNumberParam(functionName, parameters, 2, 2);
String mapName = parameters.get(0).toString();
String id = parameters.get(1).toString();
- Zone map = getNamedMap(functionName, mapName).getZone();
+ Zone map = FunctionUtil.getZoneRenderer(functionName, mapName).getZone();
GUID guid = getGUID(functionName, id);
if ("getDrawingLayer".equalsIgnoreCase(functionName)) {
return getDrawable(functionName, map, guid).getLayer().name();
diff --git a/src/main/java/net/rptools/maptool/client/functions/DrawingMiscFunctions.java b/src/main/java/net/rptools/maptool/client/functions/DrawingMiscFunctions.java
index 48f1c934a7..2312355706 100644
--- a/src/main/java/net/rptools/maptool/client/functions/DrawingMiscFunctions.java
+++ b/src/main/java/net/rptools/maptool/client/functions/DrawingMiscFunctions.java
@@ -64,7 +64,7 @@ public Object childEvaluate(
checkTrusted(functionName);
String mapName = parameters.get(0).toString();
String drawing = parameters.get(1).toString();
- Zone map = getNamedMap(functionName, mapName).getZone();
+ Zone map = FunctionUtil.getZoneRenderer(functionName, mapName).getZone();
if ("movedOverDrawing".equalsIgnoreCase(functionName)) {
FunctionUtil.checkNumberParam(functionName, parameters, 3, 3);
String jsonPath = parameters.get(2).toString();
diff --git a/src/main/java/net/rptools/maptool/client/functions/DrawingSetterFunctions.java b/src/main/java/net/rptools/maptool/client/functions/DrawingSetterFunctions.java
index 27210c4d08..b94c6eacd2 100644
--- a/src/main/java/net/rptools/maptool/client/functions/DrawingSetterFunctions.java
+++ b/src/main/java/net/rptools/maptool/client/functions/DrawingSetterFunctions.java
@@ -54,7 +54,7 @@ public Object childEvaluate(
FunctionUtil.checkNumberParam(functionName, parameters, 3, 3);
String mapName = parameters.get(0).toString();
String id = parameters.get(1).toString();
- Zone map = getNamedMap(functionName, mapName).getZone();
+ Zone map = FunctionUtil.getZoneRenderer(functionName, mapName).getZone();
GUID guid = getGUID(functionName, id);
if ("setDrawingLayer".equalsIgnoreCase(functionName)) {
Layer layer = getLayer(parameters.get(2).toString());
diff --git a/src/main/java/net/rptools/maptool/client/functions/FindTokenFunctions.java b/src/main/java/net/rptools/maptool/client/functions/FindTokenFunctions.java
index 80c80559be..fe60e6adef 100644
--- a/src/main/java/net/rptools/maptool/client/functions/FindTokenFunctions.java
+++ b/src/main/java/net/rptools/maptool/client/functions/FindTokenFunctions.java
@@ -872,21 +872,35 @@ private String findTokenId(String identifier, String zoneName) {
* Finds the specified token.
*
* @param identifier the identifier of the token (name, GM name, or GUID).
- * @param zoneName the name of the zone. If null, check current zone.
+ * @param zoneNameOrId the name or ID of the zone. If null, check current zone.
* @return the token, or null if none found.
*/
- public static Token findToken(String identifier, String zoneName) {
+ public static Token findToken(String identifier, String zoneNameOrId) {
if (identifier == null) {
return null;
}
- if (zoneName == null || zoneName.length() == 0) {
+ if (zoneNameOrId == null || zoneNameOrId.length() == 0) {
ZoneRenderer zr = MapTool.getFrame().getCurrentZoneRenderer();
return zr == null ? null : zr.getZone().resolveToken(identifier);
} else {
+ if (!GUID.isNotGUID(zoneNameOrId)) {
+ try {
+ final var zr = MapTool.getFrame().getZoneRenderer(GUID.valueOf(zoneNameOrId));
+ if (zr != null) {
+ Token token = zr.getZone().resolveToken(identifier);
+ if (token != null) {
+ return token;
+ }
+ }
+ } catch (InvalidGUIDException ignored) {
+ // Wasn't a GUID after all. Fall back to looking up by name.
+ }
+ }
+
List zrenderers = MapTool.getFrame().getZoneRenderers();
for (ZoneRenderer zr : zrenderers) {
Zone zone = zr.getZone();
- if (zone.getName().equalsIgnoreCase(zoneName)) {
+ if (zone.getName().equalsIgnoreCase(zoneNameOrId)) {
Token token = zone.resolveToken(identifier);
if (token != null) {
return token;
diff --git a/src/main/java/net/rptools/maptool/client/functions/FogOfWarFunctions.java b/src/main/java/net/rptools/maptool/client/functions/FogOfWarFunctions.java
index f77caf74cf..d0fd07e70a 100644
--- a/src/main/java/net/rptools/maptool/client/functions/FogOfWarFunctions.java
+++ b/src/main/java/net/rptools/maptool/client/functions/FogOfWarFunctions.java
@@ -28,6 +28,7 @@
import net.rptools.maptool.model.GUID;
import net.rptools.maptool.model.Token;
import net.rptools.maptool.model.Zone;
+import net.rptools.maptool.util.FunctionUtil;
import net.rptools.parser.Parser;
import net.rptools.parser.ParserException;
import net.rptools.parser.VariableResolver;
@@ -75,17 +76,7 @@ public Object childEvaluate(
parameters.size()));
}
- ZoneRenderer zoneRenderer;
- if (parameters.size() >= 1) {
- String mapName = parameters.get(0).toString();
- zoneRenderer = MapTool.getFrame().getZoneRenderer(mapName);
- if (zoneRenderer == null) {
- throw new ParserException(
- I18N.getText("macro.function.moveTokenMap.unknownMap", functionName, mapName));
- }
- } else {
- zoneRenderer = MapTool.getFrame().getCurrentZoneRenderer();
- }
+ final var zoneRenderer = FunctionUtil.getZoneRendererFromParam(functionName, parameters, 0);
/*
* String empty = exposePCOnlyArea(optional String mapName)
diff --git a/src/main/java/net/rptools/maptool/client/functions/MapFunctions.java b/src/main/java/net/rptools/maptool/client/functions/MapFunctions.java
index 42521020cb..71519c4f80 100644
--- a/src/main/java/net/rptools/maptool/client/functions/MapFunctions.java
+++ b/src/main/java/net/rptools/maptool/client/functions/MapFunctions.java
@@ -20,6 +20,8 @@
import net.rptools.maptool.client.MapTool;
import net.rptools.maptool.client.ui.zone.ZoneRenderer;
import net.rptools.maptool.language.I18N;
+import net.rptools.maptool.model.GUID;
+import net.rptools.maptool.model.InvalidGUIDException;
import net.rptools.maptool.model.Zone;
import net.rptools.maptool.util.FunctionUtil;
import net.rptools.parser.Parser;
@@ -34,10 +36,14 @@ private MapFunctions() {
super(
0,
2,
+ "getCurrentMapID",
+ "getAllMapIDs",
+ "getMapIDs",
"getAllMapNames",
"getAllMapDisplayNames",
"getCurrentMapName",
"getMapDisplayName",
+ "getVisibleMapIDs",
"getVisibleMapNames",
"getVisibleMapDisplayNames",
"setCurrentMap",
@@ -58,7 +64,25 @@ public static MapFunctions getInstance() {
public Object childEvaluate(
Parser parser, VariableResolver resolver, String functionName, List