• 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

Problem - Understanding why a specific mq.cmd isn't working in a script

Joined
Sep 27, 2020
RedCents
6,554¢
I have a very basic script designed to hire a tank merc from one of the general race merc liaisons in PoK.

Lua:
---@type Mq
local mq = require("mq")

mq.TLO.Target.RightClick()
mq.delay(2000, function()
    return mq.TLO.Window("MMTW_MerchantWnd").Open()
end)
mq.delay(100)
print("Select Journeyman Merc")
--mq.cmd.notify("MMTW_MerchantWnd MMTW_TypeComboBox listselect 3")
mq.cmd("/notify MMTW_MerchantWnd MMTW_TypeComboBox listselect 3")
mq.delay(1000)
print("Select Journeyman Tank")
mq.cmd.notify("MMTW_MerchantWnd MMTW_SubtypeListBox listselect 2")
mq.exit()
mq.delay(100)
mq.cmd.notify("MMTW_MerchantWnd MMTW_HireButton leftmouseup")
mq.delay(100)

The sticking point is mq.cmd("/notify MMTW_MerchantWnd MMTW_TypeComboBox listselect 3"). It's not selecting the Journeyman option from the dropdown when used in the running script. If I use that exact command with /lua parse, it does the job. And certainly if I use the raw command it works. I've also tried with /docommand prepended (again, mq.cmd and raw command both work).

I've tried longer delays, but that just pauses longer before the next mq.cmd (which has the expected result).
 

Attachments

Solution
FWIW; this version of your code works better for me:

Lua:
mq.TLO.Target.RightClick()
mq.delay(2000, function()
    return mq.TLO.Window("MMTW_MerchantWnd").Open()
end)
mq.delay("2s")
print("Select Journeyman Merc")
--mq.cmd.notify("MMTW_MerchantWnd MMTW_TypeComboBox listselect 3")
mq.cmd("/notify MMTW_MerchantWnd MMTW_TypeComboBox listselect 3")
mq.delay("1s")
print("Select Journeyman Tank")
mq.cmd.notify("MMTW_MerchantWnd MMTW_SubtypeListBox listselect 2")
mq.exit()
mq.delay(100)
mq.cmd.notify("MMTW_MerchantWnd MMTW_HireButton leftmouseup")
mq.delay(100)
FWIW; this version of your code works better for me:

Lua:
mq.TLO.Target.RightClick()
mq.delay(2000, function()
    return mq.TLO.Window("MMTW_MerchantWnd").Open()
end)
mq.delay("2s")
print("Select Journeyman Merc")
--mq.cmd.notify("MMTW_MerchantWnd MMTW_TypeComboBox listselect 3")
mq.cmd("/notify MMTW_MerchantWnd MMTW_TypeComboBox listselect 3")
mq.delay("1s")
print("Select Journeyman Tank")
mq.cmd.notify("MMTW_MerchantWnd MMTW_SubtypeListBox listselect 2")
mq.exit()
mq.delay(100)
mq.cmd.notify("MMTW_MerchantWnd MMTW_HireButton leftmouseup")
mq.delay(100)
 
Solution
Not sure what your end goal is with this, however depending on which server and sub status this may vary. Just a clip from an old macro for example.

Code:
/if (${Me.Subscription.Equal[SILVER]}) {
                    /notify MMTW_MerchantWnd MMTW_SubtypeListBox listselect 1
                } else /if (${Me.Subscription.Equal[GOLD]}) {
                    /notify MMTW_MerchantWnd MMTW_TypeComboBox listselect 2
                    /delay 5s
                    /notify MMTW_MerchantWnd MMTW_SubtypeListBox listselect 1
                }
                /delay 10
                /notify MMTW_MerchantWnd MMTW_HireButton leftmouseup
 
Lua:
mq.cmd("/notify MMTW_MerchantWnd MMTW_TypeComboBox listselect 3")

sanity check: I know you say you've tried this exact command outside of the mq.cmd and it's worked, but is the 3 correct? I only have 2 options in that box (Journeyman and Apprentice). Are you sure the 3 and 2 are correct?

I think Lua starts counting arrays at 1 so TypeComboBox should be 2, and on my (gold char) screen tank merc is the 4th option so 4? maybe? mostly spitballing here
 
FWIW; this version of your code works better for me:

Lua:
mq.TLO.Target.RightClick()
mq.delay(2000, function()
    return mq.TLO.Window("MMTW_MerchantWnd").Open()
end)
mq.delay("2s")
print("Select Journeyman Merc")
--mq.cmd.notify("MMTW_MerchantWnd MMTW_TypeComboBox listselect 3")
mq.cmd("/notify MMTW_MerchantWnd MMTW_TypeComboBox listselect 3")
mq.delay("1s")
print("Select Journeyman Tank")
mq.cmd.notify("MMTW_MerchantWnd MMTW_SubtypeListBox listselect 2")
mq.exit()
mq.delay(100)
mq.cmd.notify("MMTW_MerchantWnd MMTW_HireButton leftmouseup")
mq.delay(100)
The longer delay after window open does allow the selection. It's disappointing there isn't a way to delay until the window is "ready". One second worked for me, but with lag/processing delays who knows how long it'll actually take (say, if the window happens to be in the background).
 
Last edited:
Not sure what your end goal is with this, however depending on which server and sub status this may vary. Just a clip from an old macro for example.

Code:
/if (${Me.Subscription.Equal[SILVER]}) {
                    /notify MMTW_MerchantWnd MMTW_SubtypeListBox listselect 1
                } else /if (${Me.Subscription.Equal[GOLD]}) {
                    /notify MMTW_MerchantWnd MMTW_TypeComboBox listselect 2
                    /delay 5s
                    /notify MMTW_MerchantWnd MMTW_SubtypeListBox listselect 1
                }
                /delay 10
                /notify MMTW_MerchantWnd MMTW_HireButton leftmouseup
Correct. And if I have code to release with this sort of logic, I'll take subscription level into account. Your five second delay after the ComboBox listselect highlights another issue. I can't determine which list item is actually "selected".
 
Lua:
mq.cmd("/notify MMTW_MerchantWnd MMTW_TypeComboBox listselect 3")

sanity check: I know you say you've tried this exact command outside of the mq.cmd and it's worked, but is the 3 correct? I only have 2 options in that box (Journeyman and Apprentice). Are you sure the 3 and 2 are correct?

I think Lua starts counting arrays at 1 so TypeComboBox should be 2, and on my (gold char) screen tank merc is the 4th option so 4? maybe? mostly spitballing here
All valid points. For this logic, the "3" is the index as seen by the /notify command. It also starts indexing at 1, so there isn't any disconnect here. Using something like Window("MMTW_MerchantWnd").Child("MMTW_TypeComboBox").List(3, 1)() to see the text value of the third item in the dropdown reports "Journeyman Mercenaries (<race>)".

As for whether "3" is correct here, it really depends on which merc merchant is used in PoK. I specifically referenced the general race merc merchants (think the male/female pairs that hang around in PoK). I haven't tested all of them, but of the ones I use, listselect 3 is correct. There is a lone Human merc merchant in PoK (Balknir) with only two options (the same as the tutorial merc merchant Elegist). A better approach would be to include the race of the target merchant, use Window("MMTW_MerchantWnd").Child("MMTW_TypeComboBox").List("Journeyman Mercenaries (<race>)", 1)() to get the specific index of the option, and then feed that index into the /notify listselect command. All of that was beyond the scope of creating a small script for posting here.
 
Correct. And if I have code to release with this sort of logic, I'll take subscription level into account. Your five second delay after the ComboBox listselect highlights another issue. I can't determine which list item is actually "selected".

As a follow-up to this. I found I can do

Lua:
print("Select Journeyman Merc")
mq.cmd("/notify MMTW_MerchantWnd MMTW_TypeComboBox ListSelect 3")
mq.delay(2000, function ()
    return mq.TLO.Window("MMTW_MerchantWnd").Child("MMTW_TypeComboBox").GetCurSel() == 3
end)
mq.delay(250)
print("Select Journeyman Tank")
mq.cmd.notify("MMTW_MerchantWnd MMTW_SubtypeListBox listselect 2")

Still requires a slight delay after to wait for the Available Mercenaries to populate.
 
you can use the Select method as well:

Code:
mq.TLO.Window("MMTW_MerchantWnd/MMTW_TypeComboBox").Select(index)

Huh. I know I tried using Select, but must not have used the correct syntax. Upon further reflection, I think I tried to use it directly on List(x,y). That's what I get for coding at 3 in the morning.
 
Problem - Understanding why a specific mq.cmd isn't working in a script

Users who are viewing this thread

Back
Top
Cart