fixed small bug
This commit is contained in:
@@ -135,6 +135,10 @@ function Postal.control.controller()
|
||||
}
|
||||
end
|
||||
|
||||
function self.reset()
|
||||
state = nil
|
||||
end
|
||||
|
||||
function self.cleanup()
|
||||
listener.stop()
|
||||
end
|
||||
|
||||
@@ -15,14 +15,17 @@ function wait_for_update(k)
|
||||
end
|
||||
|
||||
function Postal.open.start(selected, callback)
|
||||
wait_for_update(function()
|
||||
process(selected, function()
|
||||
callback()
|
||||
end)end)
|
||||
Postal.control.on_next_update(function()
|
||||
process(selected, function()
|
||||
callback()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
function Postal.open.stop()
|
||||
wait_for_update(function() end)
|
||||
Postal.control.on_next_update(function()
|
||||
controller().reset()
|
||||
end)
|
||||
end
|
||||
|
||||
function process(selected, k)
|
||||
@@ -35,7 +38,6 @@ function process(selected, k)
|
||||
local _, _, _, _, money, CODAmount, _, hasItem = GetInboxHeaderInfo(index)
|
||||
local bodyText, _, _, isInvoice = GetInboxText(index)
|
||||
|
||||
snipe.log(bodyText)
|
||||
if CODAmount > 0 then
|
||||
tremove(selected, 1)
|
||||
return process(selected, k)
|
||||
@@ -79,6 +81,26 @@ function open(i, has_item, has_money, has_message, k)
|
||||
end)
|
||||
end
|
||||
|
||||
function open_alternative(i, k, inbox_count)
|
||||
wait_for_update(function()
|
||||
local _, _, _, _, money, CODAmount, _, has_item = GetInboxHeaderInfo(index)
|
||||
if CODAmount > 0 then
|
||||
return k()
|
||||
elseif has_item then
|
||||
TakeInboxItem(i)
|
||||
open_alternative(i, k, inbox_count)
|
||||
elseif money > 0 then
|
||||
TakeInboxMoney(i)
|
||||
open_alternative(i, k, inbox_count)
|
||||
else
|
||||
if GetInboxNumItems() == inbox_count then
|
||||
DeleteInboxItem(i)
|
||||
end
|
||||
controller().wait(function() return GetInboxNumItems() < inbox_count end, k)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function inventory_count()
|
||||
local acc = 0
|
||||
for bag = 0, 4 do
|
||||
|
||||
Reference in New Issue
Block a user