подчёт заданных айтемов в заданном контейнере [код AGRSа]
Code:
Sub get_amount(Type, Color, Cont)
var item_amount = 0
UO.UseObject(Cont)
CheckLag()
UO.IgnoreReset()
repeat
UO.FindType(Type, Color, Cont)
if UO.FindCount()>0 Then
if UO.GetQuantity('finditem')==0 Then
item_amount = item_amount + 1
else
item_amount = item_amount + UO.GetQuantity('finditem')
end if
UO.Ignore('finditem')
UO.FindType(Type, Color, Cont)
end if
until UO.FindCount()<1
UO.IgnoreReset()
return item_amount
end sub
обёртка к предыдущему скрипту на перекладку.
в месте назначения (destPack) будет лежать заданное кол-во (qGood) айтемов (tGood,cGood). если в исходном(resPack) и в конечном паках нет заданых айтемов - вернёт falseб иначе - true.
Писалось под специфичную задачу, переделать под требуемое - думаю не проблема.
Code:
Sub getGoods(tGood,cGood,qGood,resPack,destPack)
var t,z
t = get_amount(tGood,cGood,uo.getSerial(destPack))
while t < qGood
z = grabContainer(tGood,cGood,qGood-t,resPack)
if (z + t) == 0 then
return false
end if
if z == 0 then
return true
end if
t = get_amount(tGood,cGood,uo.getSerial(destPack))
wend
return true
end sub
NB! если берёшь из реально больших пачек надо обработать ситуёвину когда может возникнуть необходимость взять 1 айтем из пачки.