macro.return
The variable macro.return holds the value returned from a called macro to the calling macro. Other than macro.return, a called variable shares no other variables with the calling macro.
Examples
When a macro on a library token is called by another macro, the called macro may return a value to the called macro by assigning that value to the variable macro.args.
Calling Macro
The macro below calls a macro called getDamage on the library token "Lib:combat", passing the variable damageDice as an argument. It also sets
| Calling Macro
|
Called Macro
|
[h:damageDice="2d6"]
[MACRO("getDamage@Lib:combat"):damageDice]
[h:damageProperties=macro.return]
[h:varsFromStrProp(damageProperties)]
|
<!-- getDamage Macro -->
[h:returnData = ""]
[h:damageRoll = eval(macro.args) + 9]
[h:damageType = "piercing"]
You hit your target for [r:damageRoll] damage!
[h:returnData=setStrProp(returnData,"damType", damageType)]
[h:returnData=setStrProp(returnData,"damage", damageRoll)]
[h:macro.return=returnData]
|
In the example above, we assume that the getDamage macro was called by another macro (for example, a token macro) and has received some value in the form of macro.args. The statements in getDamage are executed, and the final statement assigns the value of returnData to the variable macro.return.
When execution of the getDamage macro is complete and control is handed back to the calling macro, macro.return is also passed back to the calling macro, where it can be manipulated like any other variable.
Library Token: A special token designed to hold a library of macros (similar to a function library) that can be called by token macros, campaign macros, and global macros. Often called "Lib:tokens."Token: A visual marker representing a character, monster, or NPCCampaign Macro: A macro specific to a campaign file. These macros are available to players and the GM, and are displayed in the Campaign Macros window.Global Macro: Macros that are available regardless of the campaign file currently loaded in MapTool, and regardless of whether the instance of MapTool is a server or a client. Global macros are ''only'' available to the running instance.Macro: A series of text instructions used to automate processes in MapTool.Campaign: A zipped XML file with the '''.cmpgn''' file extension containing tokens, maps, token macros, campaign macros, and token propertiesMap: An image file displayed in the map display area in MapTool. This image is shared among all connected players and the GM.