• 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

Lua - Give

Barnal

Active member
Joined
Jul 26, 2011
RedCents
128¢
This is something ChatGPT and I cooked up together and it's been pretty useful. It allows for a box to pick up any item from their bags and give it to a specified player. I know for me, running 32, it's shitty to have to manually tab back and forth and search through the find window to make trades. This was my answer.

All you have to do is type /Lua run PlayerRecievingTradeName "ItemName" and it will pick that item up and give it to the player you want. It makes it easy if, say, you need that bloodied luclinite powder on your alt to make the pet ear you just got an ore for on your SheiRaid.

I am working on learning how to create a functional UI, but it's still a bit beyond me. If I can figure it out, I'll toss an update here. eventually.

[CODE title="Give.Lua"]
local mq = require('mq')

function TradeItems(targetPlayer, itemName)
print("Starting trade process...")

local function IsTargetInRange(targetName)
local target = mq.TLO.Spawn(targetName)
return target and target.Distance() and target.Distance() < 10
end

local function FindAndMoveItem(itemName)
if itemName then
local item = mq.TLO.FindItem('=' .. itemName)
if not item.ID() then
print("Item not found in inventory.")
return false
end

if item.ItemSlot2() > -1 then
mq.cmd('/shiftkey /itemnotify in pack' .. (item.ItemSlot() - 22) .. ' ' .. (item.ItemSlot2() + 1) .. ' leftmouseup')
else
mq.cmd('/shiftkey /itemnotify ' .. item.ItemSlot() .. ' leftmouseup')
end
mq.delay(1000)
else
if not mq.TLO.Cursor.ID() or mq.TLO.Cursor.ID() == 0 then
print("No item on the cursor.")
return false
end
end
return true
end

local function NavigateToTarget(targetName)
if not IsTargetInRange(targetName) then
mq.cmd('/nav spawn "' .. targetName .. '"')
local startTime = os.time()
while not IsTargetInRange(targetName) do
if os.time() - startTime > 30 then
print("Failed to navigate to target.")
return false
end
mq.delay(500)
end
end
return true
end

local function OpenTradeWindow()
mq.cmdf("/target pc %s", targetPlayer)
local startTime = os.time()
while not mq.TLO.Window('TradeWnd').Open() do
if os.time() - startTime > 30 then
print("Failed to open trade window.")
return false
end
mq.cmd("/uset")
mq.delay(1000)
end
return true
end

if not targetPlayer or targetPlayer == '' then
local currentTarget = mq.TLO.Target.Name()
if currentTarget and mq.TLO.Target.Type() == 'PC' then
targetPlayer = currentTarget
else
print("No target player specified and no valid PC target selected.")
return
end
end

if not NavigateToTarget(targetPlayer) then
return
end

if not FindAndMoveItem(itemName) then
return
end

if not OpenTradeWindow() then
return
end

mq.cmd("/notify TradeWnd TRDW_Trade_Button leftmouseup")
mq.delay(2000)
print("Trade process completed.")
end

local args = {...}
local targetPlayer = args[1]
local itemName = args[2]

TradeItems(targetPlayer, itemName)
[/CODE]
 
Last edited:
I like it. One thing you might consider is when targeting a player, use the "pc" option so that you don't accidentally target pets if they share a similar name. Something like this

Lua:
mq.cmdf('/target pc %s', targetPlayer)
 
I like it. One thing you might consider is when targeting a player, use the "pc" option so that you don't accidentally target pets if they share a similar name. Something like this

Lua:
mq.cmdf('/target pc %s', targetPlayer)
Thank you. I'll modify it now.
 
can check for the item before doing the nav command. can also not nav if already at the target. can also check you made it to the target. could also use delay with a function to end when you get there instead of a static delay. OpenTradeWindow can probably also infinite loop if the window never opens, like if the toons busy or you never made it to them.
 
can check for the item before doing the nav command. can also not nav if already at the target. can also check you made it to the target. could also use delay with a function to end when you get there instead of a static delay. OpenTradeWindow can probably also infinite loop if the window never opens, like if the toons busy or you never made it to them.
Thank you. I added some contingencies.
 
After noticing I didn't quite get the modifications right, I spent a few minutes to fix them. This should be much cleaner.
 
Edited so that it will use the item in hand if none is specified and you have an item on your cursor - will also use the name of the person targeted if a name is not provided. So if you have warx targeted and a diamond on your cursor and type /Lua run give, it will give the item on your cursor to warx. It will also independently determine if 1 of the 2 arguments is missing and use the item in hand, or your target in place of the missing element.
 
Lua - Give

Users who are viewing this thread

Back
Top
Cart