Getting a reference to current active map

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
Draconem603
Kobold
Posts: 1
Joined: Sat Mar 01, 2025 7:20 am

Getting a reference to current active map

Post by Draconem603 »

I'm trying to create a macro that would easily allow me to toggle my "DM Screen" map by a simple press of a button.

This script would require me to find the current map name and store it so that when I press the "Toggle" button again from the DM Screen map, I 'm brought back to the previous map I was using.

Though, I cannot find how to do that. Anyone has an idea?

Thank you for your help! :D

User avatar
aliasmask
RPTools Team
Posts: 9136
Joined: Tue Nov 10, 2009 6:11 pm
Location: California

Re: Getting a reference to current active map

Post by aliasmask »

You put the macro on a lib token, then call the macro from the Campaign Window or GM Window.

Code: Select all

[H: home = "DM Screen"]
[H: lastMap = getLibProperty("lastMap")]
[H, if(json.isEmpty(lastMap)): lastMap = home]
[H: current = getCurrentMapName()]

[H, if(current == home): newMap = lastMap; newMap = home]
[H, if(newMap == home): setLibProperty("lastMap",current)]

[H: setCurrentMap(newMap)]

Post Reply

Return to “Macros”