setMacroCommand: Difference between revisions

From RPTools Wiki
Jump to navigation Jump to search
m (Conversion script moved page SetMacroCommand to setMacroCommand: Converting page titles to lowercase)
No edit summary
Line 7: Line 7:


|usage=
|usage=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
setMacroCommand(index, command)
setMacroCommand(index, command)
setMacroCommand(index, command, id)
setMacroCommand(index, command, id)
setMacroCommand(index, command, id, mapname)
setMacroCommand(index, command, id, mapname)
</source>
</syntaxhighlight>
'''Parameters'''
'''Parameters'''
{{param|index|The index of the macro button.}}
{{param|index|The index of the macro button.}}
Line 19: Line 19:


|examples=
|examples=
<source lang="mtmacro" line>
<syntaxhighlight lang="mtmacro" line>
[h: setMacroCommand(1, "[macro('Test@Lib:Test'): '']")]
[h: setMacroCommand(1, "[macro('Test@Lib:Test'): '']")]
</source>
</syntaxhighlight>


|changes=
|changes=

Revision as of 20:55, 14 March 2023

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, mapname)

Parameters

  • index - The index of the macro button.
  • command - A string containing the command to set on the macro button.
  • id - The token id of the token that the command is set on.
  • mapname - The name 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.