Nice work with script. I like to purchase more than 20 rations and 20 water at a time (100). Even when you change the total it would only buy a stack of 20 then move to the next vendor. Minor adjustment to buy as many as you want.

[CODE highlight="29-38"]local function buyItem(item, vendor)
if not needItem(item) then
print('I don\'t need any ' .. item)
return
end
local desired = getDesiredCount(item)
local current = getCurrentCount(item)
local need = desired - current
print('i need ' .. need .. ' ' .. item .. ' from ' .. vendor)
navToVendor(vendor)
mq.TLO.Merchant.OpenWindow()
while not mq.TLO.Merchant.Open() and not mq.TLO.Merchant.ItemsReceived() do
mq.delay(1000) -- delay 1000ms
mq.TLO.Merchant.OpenWindow()
end
if not mq.TLO.Merchant.Item('=' .. item) then
print(item .. ' was not found on ' .. vendor)
return
end
while mq.TLO.Merchant.SelectedItem() ~= item do
mq.TLO.Merchant.SelectItem('=' .. item)
mq.delay(1000) -- delay 1000ms
end
::loop::
mq.TLO.Merchant.Buy(need)
mq.delay(1000)
if desired - mq.TLO.FindItemCount(item)() <= 0 then
return
end
if desired - mq.TLO.FindItemCount(item)() > 0 then
need = desired - mq.TLO.FindItemCount(item)()
goto loop
end
mq.delay(2000)
if need > getCurrentCount(item) then
print('Successfully bought ' .. need .. ' ' .. item)
end
end[/CODE]