gondacki
12-23-2012, 01:35 AM
need help with funtionably backpack reset like that: it's error
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(BP)
local func = loadstring(Bp)
if(func)then func()
end
end
--BACKPACK OPENER--
function closeBackpacks(...) -- CREDITS TO FORGEE
local tmpBP = Container.GetFirst()
local cascaded = {...}
while tmpBP:isOpen() do
for spot = 0, tmpBP:ItemCount() do
local item = tmpBP:GetItemData(spot)
if item.id == tmpBP:ID() then
table.insert(cascaded, tmpBP:ID())
tmpBP = tmpBP:GetNext()
end
end
tmpBP = Container.GetFirst()
if not table.contains(cascaded, tmpBP:ID()) or tmpBP:ItemCount() == 0 then -- Backpack is main or last cascaded. Closing...
Self.UseItem(tmpBP:ID())
wait(500, 900)
end
if #cascaded > 0 then -- Any cascaded backpacks?
for i = 1, #cascaded do
if tmpBP:ID() == cascaded[i] then -- Found cascaded backpack.
if tmpBP:ItemCount() > 0 then -- Backpack contains atleast one item, check for anoter bp.
for spot = 0, tmpBP:ItemCount() do
local item = tmpBP:GetItemData(spot)
if item.id == tmpBP:ID() then -- Found anoter cascade bp, opening...
tmpBP:UseItem(spot)
break
end
end
end
end
end
end
wait(500, 900)
tmpBP = Container.GetFirst() -- Get a new bp to check.
if tmpBP:ID() == 0 then -- No more open backpacks.
print("All backpacks were successfully closed.")
end
end
return true
end
function openBackpacks(...) -- openBackpacks(2869, 5949, 2871)
Self.UseItem(Self.Backpack().id)
wait(1900, 3700)
for _, input in ipairs(arg) do
local Bp = Container.GetFromIndex(input[2])
for spot = 0, Bp:ItemCount() do
local item = Bp:GetItemData(spot)
if(item.id == input[1]) then
Bp:UseItem(spot)
break
end
end
wait(900, 1700)
end
end
function bpOpen()
setWalkerEnabled(false)
closeBackpacks()
wait(500)
openBackpacks({Blue Backpack, 0}, {Golden Backpack, 0}, {Grey Backpack, 0}) -- brocade Backpack, Brocade Backpack
setWalkerEnabled(true)
end
registerEventListener(WALKER_SELECTLABEL, "onWalkerSelectLabel")
function onWalkerSelectLabel(BP)
local func = loadstring(Bp)
if(func)then func()
end
end
--BACKPACK OPENER--
function closeBackpacks(...) -- CREDITS TO FORGEE
local tmpBP = Container.GetFirst()
local cascaded = {...}
while tmpBP:isOpen() do
for spot = 0, tmpBP:ItemCount() do
local item = tmpBP:GetItemData(spot)
if item.id == tmpBP:ID() then
table.insert(cascaded, tmpBP:ID())
tmpBP = tmpBP:GetNext()
end
end
tmpBP = Container.GetFirst()
if not table.contains(cascaded, tmpBP:ID()) or tmpBP:ItemCount() == 0 then -- Backpack is main or last cascaded. Closing...
Self.UseItem(tmpBP:ID())
wait(500, 900)
end
if #cascaded > 0 then -- Any cascaded backpacks?
for i = 1, #cascaded do
if tmpBP:ID() == cascaded[i] then -- Found cascaded backpack.
if tmpBP:ItemCount() > 0 then -- Backpack contains atleast one item, check for anoter bp.
for spot = 0, tmpBP:ItemCount() do
local item = tmpBP:GetItemData(spot)
if item.id == tmpBP:ID() then -- Found anoter cascade bp, opening...
tmpBP:UseItem(spot)
break
end
end
end
end
end
end
wait(500, 900)
tmpBP = Container.GetFirst() -- Get a new bp to check.
if tmpBP:ID() == 0 then -- No more open backpacks.
print("All backpacks were successfully closed.")
end
end
return true
end
function openBackpacks(...) -- openBackpacks(2869, 5949, 2871)
Self.UseItem(Self.Backpack().id)
wait(1900, 3700)
for _, input in ipairs(arg) do
local Bp = Container.GetFromIndex(input[2])
for spot = 0, Bp:ItemCount() do
local item = Bp:GetItemData(spot)
if(item.id == input[1]) then
Bp:UseItem(spot)
break
end
end
wait(900, 1700)
end
end
function bpOpen()
setWalkerEnabled(false)
closeBackpacks()
wait(500)
openBackpacks({Blue Backpack, 0}, {Golden Backpack, 0}, {Grey Backpack, 0}) -- brocade Backpack, Brocade Backpack
setWalkerEnabled(true)
end