Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for map IDs in macro functions #4127

Merged
merged 6 commits into from
Jun 12, 2023

Conversation

kwvanderlinde
Copy link
Collaborator

@kwvanderlinde kwvanderlinde commented Jun 12, 2023

Identify the Bug or Feature request

Implements #3852

Description of the Change

All map functions that accept a map name or display name now accept a map ID if it makes sense. Many other functions should also support map IDs now, though this was done by modifying common functionality and I have not exhaustively checked which are all affected (not all functions use common functionality to find maps).

The following new functions have been added to return map IDs similar to the existing functions that return map names:

  • getCurrentMapID()
  • getAllMapIDs([delim])
  • getMapIDs(mapName, [delim])
  • getVisibleMapIDs([delim])
  • getTokenMapIDs(name/ID, [delim])

Finally, a list of zone IDs has been added to the result of getInfo("campaign"), under the "zoneIDs" key

Possible Drawbacks

In the edge case that someone has a map named with the GUID of another map, the lookup behaviour will be changed.

Documentation Notes

What follows is documentation for the new functions. Many existing functions will also need updating in the Wiki to add IDs to the set of possible parameters.

getCurrentMapID

Returns the unique ID of the current map.

Usage

getCurrentMapID()

getAllMapIDs

Note: This function can only be used in a Trusted Macro

Returns the IDs of all maps in the campaign as either a String List of a JSON Array

Usage

getAllMapIDs()
getAllMapIDs(delim)

Parameters

  • delim The delimiter to use for a String List. If the value is json, then a JSON Array is returned.

getMapIDs

Returns the IDs of all maps with the given name.

Usage

getMapIDs(name)
getMapIDs(name, delim)

Parameters

  • name The name of the map to find
  • delim The delimiter to use for a String List. If the value is json, then a JSON Array is returned.

getVisibleMapIDs

Returns the IDs of all visible maps in the campaign as either a String List of a JSON Array

Usage

getVisibleMapIDs()
getVisibleMapIDs(delim)

Parameters

  • delim The delimiter to use for a String List. If the value is json, then a JSON Array is returned.

getTokenMapIDs

Gets the list of map(s) where a token resides. The list is returned either as a string list, or as a JSON Array.

Usage

getTokenMapIDs(name/ID)
getTokenMapIDs(name/ID, delim)

Parameters

  • name/ID Either the name of the token or the ID.
  • delim The delimiter used in the string list returned, defaults to ",". If set to json, then a JSON array is returned.

Release Notes

  • Map macro functions and many other macro functions now support map IDs as parameters.
  • Added functions getCurrentMapID(), getAllMapIDs([delim]), getMapIDs(mapName, [delim]), getVisibleMapIDs([delim]), getTokenMapIDs(name/ID, [delim])
  • Add list of map IDs under the "zoneIDs" key of getInfo("campaign")

This change is Reviewable

This duplicated the logic in `FunctionUtil.getZoneRenderer()` and so is unnecessary. By using
`FunctionUtil.getZoneRenderer()`, future improvements can be gained for these functions automatically.
By using the common utility `FunctionUtil.getZoneRenderer()`, future improvements can be gained for these functions
automatically.
Any dependents of `FindTokenFunctions.findToken()`, `FunctionUtil.getZoneRenderer()`, or
`FunctionUtil.getZoneRendererFromParam()` now automatically supports map GUIDs where names used to be acceptable.
In addition to clearer variable names, this adds `getCurrentMapID()`, `getAllMapIds(delim)`, and
`getVisibleMapIDs(delim) for retrieving map IDs, and `getMapIDs(mapName, delim)` for mapping names to IDs.
Added `getTokenMapIDs()` similar to `getTokenMap()`, while `moveTokenFromMap()` and `moveTokenToMap()` now accept map
IDs.
This is useful for those who need access to the list in addition to much of the other information from
`getInfo("campaign")`, without having to make separate function calls to get each thing.
@cwisniew cwisniew added this pull request to the merge queue Jun 12, 2023
Merged via the queue into develop with commit 199f3e8 Jun 12, 2023
@kwvanderlinde kwvanderlinde deleted the feature/3852-map-ids-in-macro-functions branch June 12, 2023 17:36
@Azhrei
Copy link
Member

Azhrei commented Jun 12, 2023

Thanks for the doc; I'll get it added to the wiki. 👍

@cwisniew cwisniew added the feature Adding functionality that adds value label Sep 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Adding functionality that adds value
Projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

3 participants