some refactoring for post/stack

This commit is contained in:
Manuel Simon Hirsig
2016-02-20 07:22:48 +01:00
parent 9fe07b2520
commit e976d3da0d
3 changed files with 41 additions and 44 deletions
+26 -26
View File
@@ -49,31 +49,6 @@ function private.process()
end
end
function public.stop(k)
Aux.control.on_next_update(function()
private.stop()
if k then
return k()
end
end)
end
function private.stop()
controller().reset()
if state then
local callback = state.callback
local posted = state.posted
local partial_stack = state.partial_stack
state = nil
if callback then
callback(posted, partial_stack)
end
end
end
function private.post_auction(slot, k)
ClearCursor()
ClickAuctionSellItemButton()
@@ -88,8 +63,33 @@ function private.post_auction(slot, k)
end)
end
function private.stop()
controller().reset()
if state then
local callback = state.callback
local posted = state.posted
local partial_stack = state.partial_stack
state = nil
if callback then
callback(posted, partial_stack)
end
end
end
function public.stop(k)
controller().wait(function()
private.stop()
if k then
return k()
end
end)
end
function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, allow_partial, callback)
Aux.control.on_next_update(function()
controller().wait(function()
private.stop()
state = {
+4 -6
View File
@@ -13,7 +13,7 @@ end)()
local state
local scan_auctions, scan_auctions_helper, submit_query, wait_for_callback, wait_for_results, wait_for_owner_data, on_abort, current_query
local scan_auctions, scan_auctions_helper, submit_query, wait_for_callback, wait_for_results, wait_for_owner_data, abort, current_query
function private.default_next_page(page, total_pages)
local last_page = max(total_pages - 1, 0)
@@ -28,7 +28,7 @@ end
function public.start(params)
return controller().wait(function() return true end, function()
on_abort()
abort()
state = {
params = params,
@@ -40,9 +40,7 @@ end
function public.abort(k)
return controller().wait(function() return true end, function()
on_abort()
state = nil
abort()
if k then
return k()
@@ -50,7 +48,7 @@ function public.abort(k)
end)
end
function on_abort()
function abort()
local on_abort = Aux.util.safe_index{state, 'params', 'on_abort' }
state = nil
if on_abort then
+11 -12
View File
@@ -112,20 +112,9 @@ function private.max_stack(slot)
return container_item_info and container_item_info.max_stack
end
function public.stop(k)
Aux.control.on_next_update(function()
private.stop()
if k then
return k()
end
end)
end
function private.stop()
controller().reset()
if state then
local callback, slot = state.callback, state.target_slot
state = nil
@@ -136,8 +125,18 @@ function private.stop()
end
end
function public.stop(k)
controller().wait(function()
private.stop()
if k then
return k()
end
end)
end
function public.start(item_key, size, callback)
Aux.control.on_next_update(function()
controller().wait(function()
private.stop()
local slots = private.item_slots(item_key)