PDA

View Full Version : Inbox withdrawer. Need some input.



draadloos
12-06-2015, 12:11 AM
Hello,
so i got this inbox withdrawer,
only problem is that it is only withdrawng 1 item and then continouing.

Ive spend several ourhs trying to fix it, but coudlnt find the problem.


local container = 'backpack' -- where deposit items

function withdraw()
local contfrom = Container.New('Your Inbox')
local contto = Container.New(container)
while not contfrom:isOpen() do
contfrom = Container.New('Your Inbox')
local dp = Container.New('Locker')
for mailspot, touse in dp:iItems() do
if touse.id == 12902 then
dp:UseItem(mailspot, true)
wait(500, 1700)
end
end
end
if contfrom:isOpen() and contto:isOpen() then
for slot, items in contfrom:iItems() do
while Self.Cap() - Item.GetWeight(items.id) >= 1 do
if not contto:isFull() then
contfrom:MoveItemToContainer(slot, contto:Index(), 19, 100)
wait(300, 1200)
break
else
for spot, item in contto:iItems() do
if item.id == Item.GetID(container) then
contto:UseItem(spot, true)
wait(500, 1600)
end
end
end
if Self.Cap() - Item.GetWeight(items.id) < 1 then
error('You need '..math.floor((Item.GetWeight(items.id)+1)-Self.Cap())..' capity to pickup item.')
break
end
end
end
end
end

function checking(label)
if label == 'mail' then
Self.CloseContainers()
wait(300, 700)
Self.OpenMainBackpack()
wait(500, 900)
Self.OpenLocker()
wait(300, 1200)
withdraw()
end
end
registerEventListener(WALKER_SELECTLABEL, 'checking')


Thanks in advance.

shadowart
12-06-2015, 01:40 PM
The problem is that when you're moving an item out of the inbox, the slot number for all following items change. Change to a for loop that iterates backwards through the inbox and it will work:

function withdraw()
local contfrom = Container.New('Your Inbox')
local contto = Container.New(container)
while not contfrom:isOpen() do
contfrom = Container.New('Your Inbox')
local dp = Container.New('Locker')
for mailspot, touse in dp:iItems() do
if touse.id == 12902 then
dp:UseItem(mailspot, true)
wait(500, 1700)
end
end
end
if contfrom:isOpen() and contto:isOpen() then
for slot = contfrom:ItemCount() - 1, 0, -1 do -- Changed
local items = contfrom:GetItemData(slot) -- New
while Self.Cap() - Item.GetWeight(items.id) >= 1 do
if not contto:isFull() then
contfrom:MoveItemToContainer(slot, contto:Index(), 19, 100)
wait(300, 1200)
break
else
for spot, item in contto:iItems() do
if item.id == Item.GetID(container) then
contto:UseItem(spot, true)
wait(500, 1600)
end
end
end
if Self.Cap() - Item.GetWeight(items.id) < 1 then
error('You need '..math.floor((Item.GetWeight(items.id)+1)-Self.Cap())..' capity to pickup item.')
break
end
end
end
end
end

maniek11
12-31-2015, 09:16 AM
The problem is that when you're moving an item out of the inbox, the slot number for all following items change. Change to a for loop that iterates backwards through the inbox and it will work:

function withdraw()
local contfrom = Container.New('Your Inbox')
local contto = Container.New(container)
while not contfrom:isOpen() do
contfrom = Container.New('Your Inbox')
local dp = Container.New('Locker')
for mailspot, touse in dp:iItems() do
if touse.id == 12902 then
dp:UseItem(mailspot, true)
wait(500, 1700)
end
end
end
if contfrom:isOpen() and contto:isOpen() then
for slot = contfrom:ItemCount() - 1, 0, -1 do -- Changed
local items = contfrom:GetItemData(slot) -- New
while Self.Cap() - Item.GetWeight(items.id) >= 1 do
if not contto:isFull() then
contfrom:MoveItemToContainer(slot, contto:Index(), 19, 100)
wait(300, 1200)
break
else
for spot, item in contto:iItems() do
if item.id == Item.GetID(container) then
contto:UseItem(spot, true)
wait(500, 1600)
end
end
end
if Self.Cap() - Item.GetWeight(items.id) < 1 then
error('You need '..math.floor((Item.GetWeight(items.id)+1)-Self.Cap())..' capity to pickup item.')
break
end
end
end
end
end


Dear Shadowart, i copy it and bot didnt withdraw any item from mail box :(
And i have one question, when he got full cap he go to other wpt? if not can u help me with it?
Also bot when withdraw (on first script version) didnt open next bp :(


local container = 'backpack' -- where deposit items

function withdraw()
local contfrom = Container.New('Your Inbox')
local contto = Container.New(container)
while not contfrom:isOpen() do
contfrom = Container.New('Your Inbox')
local dp = Container.New('Locker')
for mailspot, touse in dp:iItems() do
if touse.id == 12902 then
dp:UseItem(mailspot, true)
wait(500, 1700)
end
end
end
if contfrom:isOpen() and contto:isOpen() then
for slot = contfrom:ItemCount() - 1, 0, -1 do -- Changed
local items = contfrom:GetItemData(slot) -- New
while Self.Cap() - Item.GetWeight(items.id) >= 1 do
if not contto:isFull() then
contfrom:MoveItemToContainer(slot, contto:Index(), 19, 100)
wait(300, 1200)
break
else
for spot, item in contto:iItems() do
if item.id == Item.GetID(container) then
contto:UseItem(spot, true)
wait(500, 1600)
end
end
end
if Self.Cap() - Item.GetWeight(items.id) < 1 then
error('You need '..math.floor((Item.GetWeight(items.id)+1)-Self.Cap())..' capity to pickup item.')
break
end
end
end
end
end

function checking(label)
if label == 'mail' then
Self.CloseContainers()
wait(300, 700)
Self.OpenMainBackpack()
wait(500, 900)
Self.OpenLocker()
wait(300, 1200)
withdraw()
end
end
registerEventListener(WALKER_SELECTLABEL, 'checking')


its looking thath for now, please help me:(