I appreciate the feedback more than you know. The stuff you listed gives me a good checklist for improvements. I definitely need to familiarize myself with the navigation functionality vs distance. I did consider trying that, but I sometimes pull the cart before the horse, and get ahead of myself. Now, it doesn't look as daunting as it did since I rolled out my first resource. I put a short list of simple functions that I wish I didn't have to manually do and will try to automate a few of those first for more practice. Then come back and update this if I can. Thank you for the support and guidance.
I've learned quite a bit about the way EQ works and how to bend MQ to accomplish some goals along the way. Some of the things I've learned can be "gotchas" that I just keep in mind when making tools to help me along the way.
Functions are in fact your friend. If you find yourself doing the same thing over and over again such as handing out coin. You look at the repeated actions and find the parts that are different. Determine if it's viable to make those differences a parameter that you can then use when calling the function. It can even be useful in optimization to make delays in those functions parameters if you want to try different speeds in doing actions.
[CODE lang="
Lua" highlight="1,3,6"] if mq.TLO.Me.Platinum() > 0 then
-- Checks if the toon has any Platinum, and if so with trade with the target.
mq.cmd('/notify inventorywindow IW_Money0 leftmouseup')
mq.cmd('/notify quantitywnd QTYW_Accept_Button leftmouseup')
mq.cmd('/click left target')
mq.delay(2000)
end
if mq.TLO.Me.Gold() > 0 then
-- Checks if the toon has any Gold, and if so with trade with the target.
mq.cmd('/notify inventorywindow IW_Money1 leftmouseup')
mq.cmd('/notify quantitywnd QTYW_Accept_Button leftmouseup')
mq.cmd('/click left target')
mq.delay(2000)
end[/CODE]
So here you have TLOs that are all essentially the same, the body of these checks appear to all be the same with the exception of IW_Money# where the # is different.
You could do this a couple of different ways. You know how many IW_Money#'s there are to start from platinum and work your way down to copper. So you could consider using a for loop.
https://www.tutorialspoint.com/lua/lua_for_loop.htm here is a link for for loops. No idea if there is a more preferred site. I just googled "for loop
Lua" and it was one of the results.
I'm unsure if
Lua allows for mq.TLO.Me.VariableHere() type things. You could get away with such an action in macros. ${Me.${MyVariable}} for example. You could simply store the TLOs in a list of some sort that you could then iterate through. I think tables are pretty common in
Lua. Either way at first glance this seems like a good option for a potential function even if that function was just the mq.cmd portions of it.
Lua:
function GiveCoin(coinType)
mq.cmdf('/notify InventoryWindow IW_Money%d leftmouseup', coinType)
mq.cmd('/notify QuantityWnd QTYW_Accept_Button leftmouseup')
mq.cmd('click left target')
mq.delay(2000)
end
if (mq.TLO.Me.Platinum() > 0 then
GiveCoin(0)
end
if (mq.TLO.Me.Gold() > 0 then
GiveCoin(1)
end
etc
For what it's worth, that was the first
Lua function I've written myself. No idea if it's right or works :-) As Grim mentioned, if you have questions feel free to ask people that know, best for back and forth is going to be discord.
With that said, code generally speaking is more or less the same across different languages. They all have their differences but generally speaking the basics are still the same. I have knowledge of macros/C/C++, but it translates a lot to
Lua or other languages. The ability to see patterns in the code you're typing allows you to identify things that are likely candidates for functions, or simply things you may only use once in your current project, but will be used in many tools are also good candidates for functions so that you can use some sort of include method to include a library of functions you commonly use so that they can be employed across multiple resources without the need to copy/paste the function into each individual script.