guys, someone help me set this script to play (exemple 800 pot) within bp and not full capacity
and set the backpack Tile instead of {$ posx-1, $ posy + 1, $ posz}
please

init start
BpWithMana = "brown backpack"
BpOnSelf = "jewelled backpack"
ManaToUse = "ultimate mana potion"
Spells = {First = "exura vita", Second = 'utana vid', Third = 'exura vita'}
BpPos = {$posx-1, $posy+1, $posz}
init end

auto(100)
if windowcount(BpOnSelf) == 0 then
closewindows()
wait(500)
while windowcount(BpOnSelf) == 0 do
openitem(0, 'back')
wait(500,1000)
resizewindows(0, '0')
wait(1000)
end
end
if windowcount(BpWithMana) == 0 then
while windowcount(BpWithMana) == 0 do
browsefield(BpPos[1], BpPos[2], BpPos[3])
wait(1000)
openitem(BpWithMana, "Browse Field", false)
wait(500,1000)
resizewindows(0, '1')
wait(1000)
end
end
if itemcount(ManaToUse, BpOnSelf) <= 10 then
local FLASKS = {283,284,285}
for i = 1, #FLASKS do
while (itemcount(FLASKS[i]) > 0) do
moveitems(FLASKS[i], ground($posx, $posy, $posz), 'all', 100)
wait(300)
end
end
local function FreeSlots()
return getcontainer(BpOnSelf).maxcount-getcontainer(BpOnSelf).itemcount
end
local Weight = itemweight(ManaToUse)
local ItemsToMove = math.ceil(($cap-20)/Weight)
while ItemsToMove > 0 do
moveitems(ManaToUse, BpOnSelf, BpWithMana, ItemsToMove)
wait(500)
if itemcount(ManaToUse, BpWithMana) == 0 then
openitem(BpWithMana, BpWithMana, false)
wait(1000)
end
if FreeSlots() <= 1 or (itemcount(ManaToUse, BpWithMana) == 0 and itemcount(BpWithMana, BpWithMana) == 0)then
break
end
ItemsToMove = math.ceil(($cap-20)/Weight)
end
end
if cancastspell(Spells.First) then
cast(Spells.First)
wait(200)
elseif cancastspell(Spells.Second) then
cast(Spells.Second)
wait(200)
elseif cancastspell(Spells.Third) then
cast(Spells.Third)
wait(200)
end