WoW:API CreateMacro: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
No edit summary
(Removed 4th parameter (local), it's been removed in WoW 3.0)
Line 2: Line 2:
Creates a new macro command/button.
Creates a new macro command/button.


  CreateMacro(name, icon, body, local, perCharacter)
  CreateMacro(name, icon, body, perCharacter)


== Arguments ==
== Arguments ==
:(name, icon, body, local, perCharacter)
:(name, icon, body, perCharacter)


; name : String - The name of the macro to be displayed in the UI. The current UI imposes a 16-character limit.
; name : String - The name of the macro to be displayed in the UI. The current UI imposes a 16-character limit.
Line 12: Line 12:


; body : String - The macro commands to be executed. If this string is longer than 255 characters, only the first 255 will be saved.
; body : String - The macro commands to be executed. If this string is longer than 255 characters, only the first 255 will be saved.
; local : Numeric - Purpose unknown, always 1.


; perCharcter : Numeric - 0 will create a "per account" saved macro, 1 will save it as "per character"
; perCharcter : Numeric - 0 will create a "per account" saved macro, 1 will save it as "per character"
Line 23: Line 21:
== Example ==
== Example ==


  local macroId = CreateMacro("MyMacro", 12, "/script CastSpellById(1);", 1, 1);
  local macroId = CreateMacro("MyMacro", 12, "/script CastSpellById(1);", 1);


== Notes ==
== Notes ==


* This function will generate an error if 18 macros of the specified kind already exist.
* This function will generate an error if the maximum macros of the specified kind already exist (36 for per acount and 18 for per character).


* It is possible to create macros with duplicate names. You should enumerate the current macros using [[API GetNumMacros|GetNumMacros()]] and [[API GetMacroIconInfo|GetMacroIconInfo(macroId)]] to ensure that your new macro name doesn't already exist. Macros with duplicate names can be used in most situations, but the behavior of macro functions that retrieve a macro by name is undefined when multiple macros of that name exist.
* It is possible to create macros with duplicate names. You should enumerate the current macros using [[API GetNumMacros|GetNumMacros()]] and [[API GetMacroIconInfo|GetMacroIconInfo(macroId)]] to ensure that your new macro name doesn't already exist. Macros with duplicate names can be used in most situations, but the behavior of macro functions that retrieve a macro by name is undefined when multiple macros of that name exist.


This function may not be called in combat anymore, as of 2.0.
This function may not be called in combat anymore, as of 2.0.

Revision as of 22:54, 16 October 2008

WoW API < CreateMacro

Creates a new macro command/button.

CreateMacro(name, icon, body, perCharacter)

Arguments

(name, icon, body, perCharacter)
name
String - The name of the macro to be displayed in the UI. The current UI imposes a 16-character limit.
icon
Numeric - A 1-based iconTextureId (index of icon textures as displayed in "Change Name/Icon" UI). Check the current number if icon textures available by calling GetNumMacroIcons().
body
String - The macro commands to be executed. If this string is longer than 255 characters, only the first 255 will be saved.
perCharcter
Numeric - 0 will create a "per account" saved macro, 1 will save it as "per character"

Returns

macroId
Numeric - The 1-based index of the newly-created macro, as displayed in the "Create Macros" UI.

Example

local macroId = CreateMacro("MyMacro", 12, "/script CastSpellById(1);", 1);

Notes

  • This function will generate an error if the maximum macros of the specified kind already exist (36 for per acount and 18 for per character).
  • It is possible to create macros with duplicate names. You should enumerate the current macros using GetNumMacros() and GetMacroIconInfo(macroId) to ensure that your new macro name doesn't already exist. Macros with duplicate names can be used in most situations, but the behavior of macro functions that retrieve a macro by name is undefined when multiple macros of that name exist.

This function may not be called in combat anymore, as of 2.0.