Hey Guys, I'm new on forum and I'm in trouble with some scripts for paladin. I would like to know how to build an action to withdrawn royal spear from depot, I'm trying this one, but it does not work. Thanks.

local bpforammo = getuseroption('BP royal spear')
local ammoname = "royal spear"
local ammoleft = itemcount(ammoname)
local amountammo = tonumber(getuseroption('Ammo Amount')) - ammoleft
local alarmnoammo = getuseroption('No Ammo Alarm')
local logoutnoammo = getuseroption('Logout no Ammo')
local star = getuseroption('Withdraw Royal Spear from depot')
local supplyBp = getlootingdestination('mainbp')
local dpbp = getlootingdestination('depotbp')
local log = getuseroption('Logout no Ammo')

setsetting('Cavebot/AutoRefillAmmo', 'no')
if star == true then
closewindows(dpbp) wait(700, 1000)
openitem('depot') wait(700, 1000)
openitem('3502') wait(700, 1000)
repeat
openitem(bpforammo) wait(700, 1000)
until
itemcount(ammoname, bpforammo) >= 1
moveitemsupto(ammoname, amountammo, supplyBp, bpforammo) wait(700, 1000)
if log == true and itemcount(ammoname) < amountammo then
gotolabel(0,'trainer')
elseif alarmnoammo == true and
itemcount(ammoname) < amountammo then
auto(0)
playsoundflash('monster.wav') wait(1000)
setsetting('Cavebot/Enabled', 'no')
end
repeat
openitem(bpforammo) wait(700, 1000)
until
itemcount(ammoname, bpforammo) >= 1

moveitemsupto(ammoname, amountammo, supplyBp, bpforammo) wait(700, 1000)

while itemcount(ammoname, bpforammo) == 0 and itemcount(bpforammo, bpforammo) >= 1
do openitem(bpforammo) wait(700, 1000) end

end