Home - Blog - Contact


Addons sans addons

Is there some piece of addon functionality you absolutely cannot play without? Do you ever play on computers where you can't install addons? Does playing on multiple computers make it hard to keep your addons synchronized? Whether it's all-in-one bags, custom action bars, click casting, or something else as yet unimagined, McRun will allow a cleverly-written addon to store both its code and configuration as macros on the server. You don't need to install a single addon to take advantage of this new system!

Feedback? Questions? Suggestions? Please visit the official WoWInterface forum thread.

Click here to lend your support to: Cogwheel’s Workshop and make a donation at www.pledgie.com !


See Setting up McRun for the latest version of McLib (McRun is stable and shouldn't change from now on)

Version 1.3 - 2010-05-25 22:32 - New methods: :N (GetName), :SAP (SetAllPoints), :CAP (ClearAllPoints), :T (SetText), :FT (SetFormattedText), :CF (CreateFontString), :HS (HookScript)
Version 1.2 - 2010-05-19 23:27 - New function: SL (SLash command registration)
Version 1.1 - 2010-05-19 08:21 - New methods: :SA (SetAttribute) and :RB (remove bindings)
Version 1.0 - 2010-05-18 12:10 - Initial Release

Current McRun addons

User’s Guide

McRun is a framework for running code stored in macro slots, which are saved on the server. It's able to load several macros as a single Lua script, which means it can bypass the 255 character limit. Specially designed addons take advantage of the features in McRun to keep them as short as possible.

Before explaining how to use McRun, you should be aware of several issues. Many sacrifices need to be made in order to fit addons into less than a kilobyte or so. This has several ramifications for the usability of McRun addons:

With that out of the way, let's get started!

Setting up McRun

Create a new account-wide macro named McRun and paste in the following code (on most browsers you can triple-click the line to precisely select everything on the line). Note: if you have AutoMcRun installed, you don't need this first macro. However, you may still want to create it if you think you might ever play on a computer where you can't install AutoMcRun.

/run function McRun(p,e)local s,i,f,c={},1,GetMacroInfo c=select(3,f(p..i))while c do s[i]=c i=i+1 c=select(3,f(p..i))end f=loadstring(strjoin(" ",unpack(s)))if e then setfenv(f,setmetatable(e,{__index=_G}))end return f()end McRun"McLib"McRun"McLoad"

This establishes the main McRun function which loads Lua code from a set of macros. From now on I'm going to use the term "scripts" to refer to macros that contain plain Lua code as opposed to built-in macros composed of slash commands.

Now you need to create scripts for the standard McRun library. Create three new account-wide scripts named McLib1, McLib2, McLib3 and McLib4, and fill them with the following code. Alternatively, you can install the addon version of McLib (same caveats apply as with AutoMcRun).


local s,t="MCSLASH",{S="Show",H="Hide",T="SetText",FT="SetFormattedText",CF="CreateFontString",SP="SetPoint",SAP="SetAllPoints",CAP="ClearAllPoints",SS="SetSize",SW="SetWidth",SH="SetHeight",SzPt=function(f,w,h,...)f:SS(w,h)f:SP(...)end,N="GetName",R=


"RegisterEvent",SSc="SetScript",HS="HookScript",SA="SetAttribute",RC="RegisterForClicks",RD="RegisterForDrag",MM=function(f)f:SetMovable(1)f:RD"LeftButton"f:SSc("OnDragStart",f.StartMoving)f:SSc("OnDragStop",f.StopMovingOrSizing)end,RB=function(f)for _,b


in ipairs{GetBindingKey("CLICK "..f:GetName()..":LeftButton")}do SetBinding(b,nil)end end}function Ij(f,m)for k,v in pairs(m or t)do f[k]=type(v)=="string"and f[v]or v end return f end function CF(...)return Ij(CreateFrame(...))end function SL(f,...)


SlashCmdList[s]=f for i,c in ipairs{...}do _G["SLASH_"..s..i]=c end s=s.."_"end

These scripts set up a few functions used by McRun addons to keep their code as short as possible.

Creating the McRun addon loader(s)

After the main McRun macro loads the McLib scripts, it will then look for McLoad scripts. Since all the scripts are called by name, you can put them in your character-specific set, your account-wide set, or a combination of both. The scripts are loaded in numerical order starting at 1, ending as soon as it comes across one that doesn't exist.

A simple and flexible arrangement would be an account-wide McLoad1 and a character-specific McLoad2. That way you have full control over which McRun addons are loaded for each character. Go ahead and create these scripts and leave them empty for now.

Installing a McRun addon

Installing a McRun addon is just like installing the McLib scripts. The addon author will provide you with the necessary scripts which you will paste into macros called AddonName1, AddonName2, etc. As with the loaders, you can put these in either your character-specific or account-wide sets (though you will probably want to use account-wide). The addon may have other specific instructions for any additional configuration scripts. Once the addon scripts are installed, you'll need to add McRun "AddonName" to one of your McLoad scripts.


Paste in the following two scripts


local message = "Hi from test #"
local function msg(n) print(message..n) end


message = "Now i'm in test #"

Now add the following line to McLoad1:

McRun "Test"

Put the McRun macro on one of your action bars and close the Macros window. When you run the McRun macro, you should see the following displayed in your chat window:

Hi from test #1
Now i'm in test #2

That's all there is to it. Enjoy!

Developer’s Guide

Be sure to read through the user's guide. You will need to structure your McRun addons to follow the described conventions.

The core McRun function is defined in the McRun macro.

results = McRun(prefix [, environment])

Runs Lua code constructed from one or more macros' text.



Example 1, basic use

McRun "McLib"

This appears at the end of the main McRun macro to automatically load the helper libraries. Any code inside McLib1, McLib2, etc. will be run as a single lua chunk.

Example 2, loading configuration

local configs = {}
McRun("CBConfig", configs)
for barNum,config in ipairs(configs.bars) do
    -- Do stuff

This is the way CogsBar loads its configuration information. The CBConfig script's global environment has access to all the variables and functions in the main global environment. However, any new globals created or overwritten by the code in CBConfig1, CBConfig2, etc. will be stored inside the configs table.

The rest of the functions described here are loaded from McLib. McLib is designed to minimize the space needed to write McRun addons. These initial features are merely what I've found useful to implement my own addons. Since having several libraries like this would defeat the purpose of minimizing macro consumption, please let me know if you would like anything added (especially new default method injections). As long as your request is for something substantially different from what's already here and is generally applicable to several types of addons, I shouldn't have any reason to say "no" (or at least if I do, I'll do my best to explain it :) )

frame = CF(...)

Creates a frame and injects the default set of short-named methods into the frame. Equivalent to frame = Ij(CreateFrame(...)).

frame = Ij(frame[, methods])

Injects a set of methods into a frame for shortening method calls.




If an entry in the methods table is a string, then the new method will simply alias an existing method. If the entry is a function, then the new method will map to that function.



Default method injections



Registers a slash command handler.



SL(function(msg) print("Hi "..msg) end, "/mygreet", "/mg") 

Code Shortening Tips

Copyright ©2008-2009 Matthew Orlando
This site is not affiliated with Blizzard Entertainment or John Wiley and Sons.