Upd. Found a better guide at https://runesofmagic.gamepedia.com/Addon_Tutorial
You better start there
Macros provide a nice way to do get more when spending less efforts.
And when you start using them extensively, you’ll notice two things. First, there’s a limit on a macro length. Second, you might want to use the same code in different macros.
This is where custom functions come to resque. Below are some steps you can take to start learning the subject.
First, browse to <your-ROM-directory>/interface/addons (if it doesn’t exist yet, create the missing directories). Then create a new directory, say, MyFunctions. That’s right, you are making your first addon ))
Then create two files, MyFunctions.toc and MyFunctions.lua. Note that some file managers hide file extension so you might have to work around this. Or you can download and unpack the examples in the post.
The file MyFunctions.toc should consist of one line “MyFunctions.lua” without quotes marks. Yes, this tells ROM to load all code from the your second file.
Now let’s edit MyFunctions.lua. Just add some of the code below
The first example is for champion/mage gate protector alt in SW. You want it to require as little attention as possible. Your main obstacle is the hard limit of macro length. So add the following lines to your lua script
Then return to character selection and enter again, this will refresh your addons. Now you can use the function in your macro like
and put as many lines as you can. This way the gate will be protected for about 10 min without any attention. But what happens if you forget? Let’s make the macro inform you about its progress. Modify the function like
if parameter ~= nil then
SendChatMessage(“Counter is: ” .. tostring(parameter) , “WHISPER”, 0, “Your-main-char-name”)
Then you can change the 10th call to
The 20th to
And so on. As the macro executes, you’ll get whispers “Counter is: 1”, “Counter is: 2” etc. The highest counter value will be 5 so you know when it’s time to restart the macro. Of course, you might annoyed by this spam and choose to leave only the last notification. For instance, replace the text in the function “Counter is: ” .. tostring(parameter) with “Macro ending soon, needs restart” and pass any parameter to s() almost at the end. Of course, strings are acceptable too like /run s(“something”). I used digits only to keep the macro small.
Also note that some one-letter functions might already exist. If the current implementation doesn’t work, try renaming.
Another application. Sometimes you might want go same route though NPC chat menu, quite a common thing during festivals. There’s no problem calling the correct functions but you may choose not to type them over and over again but replace them with something shorter
Relog your char again and you can create chatting macro
/run u() — uses “Attack” skill which meants open dialog for friendly NPCs
The delays depend on your ping and other factors. Sometimes then can be omitted at all. Test for yourself.
More sophisticated example
function CheckBuff(unit, buff)
for i = 1, 40 do
if UnitDebuff(unit, i) == buff then
To be honest, this piece of code isn’t the most effective solution but it should do for educational purposes.
/run if CheckBuff(“target”, “Weakened”) then CastSpellByName(“Puzzlement”) else CastSpellByName(“Weakening Weave Curse”)
Of course, this is a very basic example but it should give you the idea of using the same piece of code in multiple macro.
There’s also a way to avoid relogging after extending your lua scripts. Use the following macro
Another useful (although weird-looking) trick if you have length problems. Copy the first like to your macro editing window, press Enter, then copy the second line ad press Enter again. After this you select the two lines in you macro editor and keep pasting them. This will give you a slightly longer macro copared to copying text from this page. Yes, it sounds very odd but it works, at least in Widows.
https://forum.runesofmagic.gameforge.com/forum/thread/523-give-a-macro-take-a-macro/ – forum topic about useful macro, check if you can borrow something useful
https://runesofmagic.gamepedia.com/List_of_Functions – list of available functions
https://www.lua.org/pil/contents.html – good place to start with lua language if you have any (even very little) experience in programming
http://s000.tinyupload.com/index.php?file_id=00939015820386094200 – examples used in this post.
You must be logged in to reply to this topic.