• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver
Resource icon

Release Gimmie your coins 1.0

No permission to download

Xavierix

Member
Joined
Aug 10, 2020
RedCents
300¢
Xavierix submitted a new resource:

Gimmie your coins - Lua script makes your toons give you all their plat, gold, silver and copper.

My first time scripting something. I was told the best way to learn is to have a need you want addressed. I like to keep the cash on the main toon and hand it out for spells or other purchases. I was tired of manually collecting money from my toons, so I thought, why not script it?

This script will check if the toon has coins, if not send you a tell. Check for items on your cursor. Check to see if you have slots to auto inventory to clear your cursor and let you know otherwise. Then...

Read more about this resource...
 
Some suggestions:

Group leader can in fact be not group member 1 Try Group.Leader
You shouldn't target things without first being within range, so you should get the range to the spawn using the Spawn TLO.
mq.TLO.Navigation.Active() can be used to verify if you are currently still navigating. Stopping at 3 seconds is fairly arbitrary. Ideally one would be within 3 seconds of their group leader at a given point, but it's also possible they aren't. I don't Lua script, but in a macro I had create a while statement that would check mq.TLO.Spawn('id mq.TLO.Group.Leader.ID()').Distance3D() > 15 and mq.TLO.Navigation.Active() then keep going. if they were greater than 15 and navigation wasn't active then activate it again. Someone more versed may be able to assist with the logic for Lua, I'm not even entirely sure my example use cases are correct, but it's the general idea I was trying to convey.
Once you're within 15 and navigation has stopped, then target them, wait until they are your target, then grab your coins and hand them out.
regarding the mq.cmd('/autoinventory') being used. You don't first check to see if anything is on your cursor, you just use the autoinv command. It's also possible to have multiple things on your cursor (think mage summoning items onto nearby player cursors or quest rewards), so you should consider making that a while statement where while mq.TLO.Cursor.ID() and mq.TLO.Me.FreeInventory() >= 1 then autoinventory. There is also Me.CursorPlatinum etc. Maybe Cursor.Coin - I can't recall all the potential things that will show up on your cursor. I just know money isn't an item the same way a sword is an item on the cursor. So checking for an ID when you have money on the cursor would return no ID suggesting your cursor is empty when it is in fact not empty. I do see you have a note for CursorPlatinum but it wasn't used in your script.

Overall not a bad first go at things. Submitting a resource is a good way to get feedback that can hopefully improve the script when sharing. Improving could be implementing checks for situations you haven't encountered yourself that may need consideration, or new features that pair well with a given script.
 
Some suggestions:

Group leader can in fact be not group member 1 Try Group.Leader
You shouldn't target things without first being within range, so you should get the range to the spawn using the Spawn TLO.
mq.TLO.Navigation.Active() can be used to verify if you are currently still navigating. Stopping at 3 seconds is fairly arbitrary. Ideally one would be within 3 seconds of their group leader at a given point, but it's also possible they aren't. I don't Lua script, but in a macro I had create a while statement that would check mq.TLO.Spawn('id mq.TLO.Group.Leader.ID()').Distance3D() > 15 and mq.TLO.Navigation.Active() then keep going. if they were greater than 15 and navigation wasn't active then activate it again. Someone more versed may be able to assist with the logic for Lua, I'm not even entirely sure my example use cases are correct, but it's the general idea I was trying to convey.
Once you're within 15 and navigation has stopped, then target them, wait until they are your target, then grab your coins and hand them out.
regarding the mq.cmd('/autoinventory') being used. You don't first check to see if anything is on your cursor, you just use the autoinv command. It's also possible to have multiple things on your cursor (think mage summoning items onto nearby player cursors or quest rewards), so you should consider making that a while statement where while mq.TLO.Cursor.ID() and mq.TLO.Me.FreeInventory() >= 1 then autoinventory. There is also Me.CursorPlatinum etc. Maybe Cursor.Coin - I can't recall all the potential things that will show up on your cursor. I just know money isn't an item the same way a sword is an item on the cursor. So checking for an ID when you have money on the cursor would return no ID suggesting your cursor is empty when it is in fact not empty. I do see you have a note for CursorPlatinum but it wasn't used in your script.

Overall not a bad first go at things. Submitting a resource is a good way to get feedback that can hopefully improve the script when sharing. Improving could be implementing checks for situations you haven't encountered yourself that may need consideration, or new features that pair well with a given script.
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 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.
 
Last edited:
I'm unsure if Lua allows for mq.TLO.Me.VariableHere() type things. You could get away with such an action in macros.
It absolutely does, and yes, it seems like putting the currency types in a table and iterating through them would be a good play.

I think tables are pretty common in Lua.
Understatement of the week, from PIL:
Tables in Lua are not a data structure; they are [I]the[/I] data structure. All structures that other languages offer---arrays, records, lists, queues, sets---are represented with tables in Lua. More to the point, tables implement all these structures efficiently.

:dance:

Edit: Hit enter too soon.

I also wanted to say that iterating through the players with a single group command may be something to look into in the future!
 
You may also want to have it iterate through all the dannet peers as some type of option. That way it gets it from all the online characters
 
Release Gimmie your coins

Users who are viewing this thread

Back
Top
Cart