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]
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:

