• You've discovered RedGuides 📕 an EverQuest multi-boxing community 🛡️🧙🗡️. We want you to play several EQ characters at once, come join us and say hello! 👋
  • IS THIS SITE UGLY? Change the look. To dismiss this notice, click the X --->
Resource icon

Guide - MacroScript to Lua (1 Viewer) 0.2

Joined
Sep 13, 2019
RedCents
13,648¢
aquietone submitted a new resource:

MacroScript to Lua - How to write macro basics in Lua

This guide will cover what (I) think seem to be some of the more common building blocks of code found in macros, and ways they may be written in Lua. They may not be the only ways or the best ways, but hopefully they are useful to see.

All the Lua code from this guide is also included in the howto.lua script provided with the guide.

Other Resources
MQ2Lua wiki...

Read more about this resource...
 
Nice guide! A couple of things to mention:
{...} is the table containing the varargs in a function, which might give closer results to the macro equivalent of directly accessing the varags by index.
This is MQ specific, but you don't just directly write slash-commands, they are accessed through mq.cmd('/mycommand and args') (and cmdf), which is a major difference from the macro language.
 
This might be a bit advanced but one of the benefits of select in the macro language is short style syntax for shared code but knowing what the value is. It’s sort of a compact switch statement that sets the variable for you. So maybe the example would be more illustrative if you set variables. One of the common examples is selecting melee classes, caster classes, or hybrid classes.

Lua actually does this with tables more than anything else. So a table with class short names matched to their respective melee/caster/hybrid might be a good example of replacing a select (otherwise set a variable rather than print so the explanation is relatable since macro language also had else if. The tables example is a start to this but I think it lacks applicability where it would be a good place to get “properties” of an item in a table.

Moving on, the for loop example (repeat until) is closer to a do while than a for loop. I don’t remember if the macro language has a do while or not. 5c should probably be renamed though.

It might also be worth mentioning that Lua binds are different from macro binds in that macro binds rely on some other command executing for them to be processed. This is no longer the case with Lua binds. Just something to know as you transfer knowledge.

Great job!
 
Last edited:
This might be a bit advanced but one of the benefits of select in the macro language is short style syntax for shared code but knowing what the value is. It’s sort of a compact switch statement that sets the variable for you. So maybe the example would be more illustrative if you set variables. One of the common examples is selecting melee classes, caster classes, or hybrid classes.

Lua actually does this with tables more than anything else. So a table with class short names matched to their respective melee/caster/hybrid might be a good example of replacing a select (otherwise set a variable rather than print so the explanation is relatable since macro language also had else if. The tables example is a start to this but I think it lacks applicability where it would be a good place to get “properties” of an item in a table.

Moving on, the for loop example (repeat until) is closer to a do while than a for loop. I don’t remember if the macro language has a do while or not. 5c should probably be renamed though.

It might also be worth mentioning that Lua binds are different from macro binds in that macro binds rely on some other command executing for them to be processed. This is no longer the case with Lua binds. Just something to know as you transfer knowledge.

Great job!

Thanks for the feedback. I made some updates to the sections around loops/flow control, and split out the bit on Lua tables and ${Select[...]} into their own sections with some updated examples. Think the guide should flow a little better now.
 
Guide - MacroScript to Lua

Users who are viewing this thread

Back
Top