WoW:API CreateMacro: Difference between revisions

From AddOn Studio
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
[[Category:API Functions|CreateMacro]]
[[Category:API Macro Functions|CreateMacro]]
Creates a new macro command/button.
CreateMacro(name, icon, body, local)
== Arguments ==
:(name, icon, body, local)
; 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 [[API GetNumMacroIcons|GetNumMacroIcons()]].


; body : String - The macro commands to be executed.


[[Category:API Functions|CreateMacro]]
; local : Numeric - Purpose unknown, always 1.
[[Category:API Macro Functions|CreateMacro]]
 
== 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 ==
 
It is possible to do some WrongThings(tm) here:
 
* It is possible to create more macros than the UI can display. Call [[API GetNumMacros|GetNumMacros()]] to ensure there are no more than 17 macros (18 is the current UI limit) before calling CreateMacro().
 
* 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.
 
 
 
----
__NOTOC__
{{Template:WoW API}}

Revision as of 11:36, 31 December 2005


Creates a new macro command/button.

CreateMacro(name, icon, body, local)

Arguments

(name, icon, body, local)
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.
local
Numeric - Purpose unknown, always 1.

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

It is possible to do some WrongThings(tm) here:

  • It is possible to create more macros than the UI can display. Call GetNumMacros() to ensure there are no more than 17 macros (18 is the current UI limit) before calling CreateMacro().
  • 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.



Template:WoW API