setCurrentMap: Difference between revisions
(Replaced source with syntaxhighlight as test.) |
(Changed language to "bash" to see if it gets rid of syntax error.) |
||
Line 12: | Line 12: | ||
|usage= | |usage= | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash"> | ||
setCurrentMap(mapName) | setCurrentMap(mapName) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
|examples= | |examples= | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="bash" line> | ||
[h: status = input("NewMap|" + getAllMapNames() + "|Map to switch to|LIST|VALUE=STRING")] | [h: status = input("NewMap|" + getAllMapNames() + "|Map to switch to|LIST|VALUE=STRING")] | ||
[h:abort(status)] | [h:abort(status)] |
Revision as of 23:54, 10 October 2020
setCurrentMap() Function
WARNING: This function changes an internal variable used by MapTool to keep track of which map is current and this change takes place immediately. However, changes to tokens are queued up and only occur when the macro finishes execution (well, sort of). The end result is that if a token is being modified on map "A" and your macro calls setCurrentMap() to switch to map "B", when the macro finishes and the token changes are executed they will be processing a token on map B! If there was no such token on map B a new one will be created, thus mysteriously duplicating tokens!
Therefore, do NOT modify any token properties, states, names, notes, or any other token-specific values after calling setCurrentMap(). Or make sure that the first thing your macro does is call setCurrentMap() so that all tokens accessed later will be on the map that is current when the macro finishes.
Search http://forums.rptools.net/ forsetCurrentMap
to find some discussion threads on this topic.Usage
setCurrentMap(mapName)
Examples
[h: status = input("NewMap|" + getAllMapNames() + "|Map to switch to|LIST|VALUE=STRING")]
[h:abort(status)]
[h:setCurrentMap(NewMap)]