setMacroCommand: Difference between revisions
Jump to navigation
Jump to search
(New page: ==Function setMacroCommand== {{TrustedOnlyFunction}} Sets the command that will be run when the Token:Macro Button is pressed. Note because of the way the parser interprets values w...) |
Bubblobill (talk | contribs) mNo edit summary |
||
(12 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
= | {{MacroFunction | ||
|name=setMacroCommand | |||
|trusted=true | |||
|version=1.3b48 | |||
|description= | |||
Sets the command that will be run when the [[Token:Macro Button|Macro Button]] is pressed. Note because of the way the parser interprets values within [] you may have to use the [[Macros:Functions:encode| encode()]] and [[Macros:Functions:decode|decode()]] functions with the string. | Sets the command that will be run when the [[Token:Macro Button|Macro Button]] is pressed. Note because of the way the parser interprets values within [] you may have to use the [[Macros:Functions:encode| encode()]] and [[Macros:Functions:decode|decode()]] functions with the string. | ||
|usage= | |||
< | <syntaxhighlight lang="mtmacro" line> | ||
setMacroCommand(index, command) | |||
</ | setMacroCommand(index, command, id) | ||
setMacroCommand(index, command, id, mapRef) | |||
</syntaxhighlight> | |||
'''Parameters''' | |||
{{param|index|The index of the macro button.}} | |||
{{param|command|A string containing the command to set on the macro button.}} | |||
{{param|id|The token {{code|id}} of the token that the command is set on. From v1.15, accepts "campaign" and "gm" as ids for the relevant panels.}} | |||
{{param|mapRef|The Name or ID of the map to find the token. Defaults to the current map.}} | |||
|examples= | |||
< | <syntaxhighlight lang="mtmacro" line> | ||
[h: setMacroCommand(1, "[macro('Test@Lib:Test'): '']")] | [h: setMacroCommand(1, "[macro('Test@Lib:Test'): '']")] | ||
</ | </syntaxhighlight> | ||
|changes= | |||
{{change|1.3b49|Changed to a trusted function.}} | |||
{{change|1.3b51|Added {{code|id}} parameter option.}} | |||
{{change|1.5.11|Added {{code|mapname}} parameter option.}} | |||
{{change|1.15|Addition of "gm" and "campaign" options for id}} | |||
}} | |||
[[Category:Metamacro Function]] |
Latest revision as of 23:59, 17 March 2024
setMacroCommand() Function
Note: This function can only be used in a Trusted Macro
• Introduced in version 1.3b48
Sets the command that will be run when the Macro Button is pressed. Note because of the way the parser interprets values within [] you may have to use the encode() and decode() functions with the string.
Usage
setMacroCommand(index, command)
setMacroCommand(index, command, id)
setMacroCommand(index, command, id, mapRef)
Parameters
index
- The index of the macro button.command
- A string containing the command to set on the macro button.id
- The tokenid
of the token that the command is set on. From v1.15, accepts "campaign" and "gm" as ids for the relevant panels.mapRef
- The Name or ID of the map to find the token. Defaults to the current map.
Examples
[h: setMacroCommand(1, "[macro('Test@Lib:Test'): '']")]
Version Changes
- 1.3b49 - Changed to a trusted function.
- 1.3b51 - Added
id
parameter option. - 1.5.11 - Added
mapname
parameter option. - 1.15 - Addition of "gm" and "campaign" options for id