Home arrow News arrow Guides arrow How To: Write your own macro mod
How To: Write your own macro mod
User Rating: / 0
PoorBest 
Guild - Tips and Guides
Written by Q   
Sunday, 15 October 2006
Ok, so you've written a nice macro, or want to write a nice macro but you've run out of room in the ingame macro editor.  What you need to do is put a chunk of code into a function that you can call from your macro.  This is how you go about it.

When the game loads it looks for folders in your games /interface directory and loads the .toc files inside them.  It only looks for .toc files that have the same name as the folder they are in!
So /interface/mystuff/mystuff.toc will load and /interface/mystuff/mymod.toc won't

So, how do you go about setting up your TOC file?

## Interface: 11200
## Title: My Macros
## Notes: This is my first AddOn.
## Dependencies: someAddOn, someOtherAddOn
## OptionalDeps: someAddOn, someOtherAddOn
## SavedVariables: someVariable, someOtherVariable
## SavedVariablesPerCharacter: somePercharVariable
macros.lua

The first line is the interface number, theres  a few ways to find out what this is, but since most people disable version checking by clicking ‘load out of date addons’ I won’t go into any of the methods but instead get back to the rest of the TOC file ;)

The next two lines are fairly self explanatory, the title will be what your mod will be listed as in your loading screens addon list.  The notes line is just a general comments field.

Dependencies and Optional dependencies, these two lines (which you can omit if you like) list the addons that need to load before this one.  If a dependency isn’t found the mod will fail to load, if an optional dependency isn’t found the mod will still load regardless.

The two saved variables lines are where you list which variables (if any) you would like to save inbetween game sessions.

The very end of the TOC file lists the files that will be loaded (in order).  These can be either LUA or XML files depending on how advanced your mod will be.  Since this will just be a dump for large macro’s all you need is a LUA entry.

Macros.lua

Your lua file is where you can build your set of functions.  The commands you put into these functions should not contain the usual macro slash commands like /cast and /script so if you have these in your macro remove the /script commands and change your /cast lines to CastSpellByName(“<<spell>>”)

Function building:

function myfunction()

                lua code

end

Copy your lua code into the function and next time you start the game (you need to restart the game client to load a new addon) you can run myfunction by using /script myfunction() in a macro.

Remember you can call functions from within functions in lua and you can put all your macro functions into the same lua file and call each function from different macros.  If you need to modify the code in your lua file after its loaded ingame you can do this by simply doing a /console reloadui.  Reloadui doesn’t load new TOC files or TOC file changes so if you amend your TOC you won’t be able to see the change until you restart your WoW client.

 

 

 

 

Last Updated ( Sunday, 15 October 2006 )
 
< Prev