setCurrentMap: Difference between revisions
m (missed a bracket) |
m (Conversion script moved page SetCurrentMap to setCurrentMap: Converting page titles to lowercase) |
||
(7 intermediate revisions by 4 users not shown) | |||
Line 4: | Line 4: | ||
|description= | |description= | ||
Designates the given map as the current one, allowing initiative to be moved from map to map. | Designates the given map as the current one, allowing initiative to be moved from map to map. | ||
'''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 {{func|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 {{func|setCurrentMap}}. Or make sure that the first thing your macro does is call {{func|setCurrentMap}} so that all tokens accessed later will be on the map that is current when the macro finishes. | |||
Search http://forums.rptools.net/ for {{code|setCurrentMap}} to find some discussion threads on this topic. | |||
|usage= | |usage= | ||
< | <syntaxhighlight lang="bash"> | ||
setCurrentMap( | setCurrentMap(mapRef) | ||
</ | </syntaxhighlight> | ||
|examples= | |examples= | ||
< | <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)] | ||
[h:setCurrentMap(NewMap)] | [h:setCurrentMap(NewMap)] | ||
</ | </syntaxhighlight> | ||
|also= | |also= | ||
{{func|getAllMapNames}} {{func|getVisibleMapNames}} | {{func|getAllMapNames}} {{func|getVisibleMapNames}} | ||
}} | }} | ||
[[Category: | [[Category:Map_Function]] |
Latest revision as of 23:59, 9 February 2023
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(mapRef)
Examples
[h: status = input("NewMap|" + getAllMapNames() + "|Map to switch to|LIST|VALUE=STRING")]
[h:abort(status)]
[h:setCurrentMap(NewMap)]