post simplifications

This commit is contained in:
Manuel Simon Hirsig
2016-04-15 09:07:44 +02:00
parent 1695928b83
commit e13ac9d145
4 changed files with 41 additions and 166 deletions
+6 -14
View File
@@ -4,10 +4,7 @@ Aux.post = public
local state
function private.process()
if state.posted < state.count or state.allow_partial then
if state.posted == state.count then
state.allow_partial = false
end
if state.posted < state.count then
local stacking_complete, target_slot
@@ -22,7 +19,7 @@ function private.process()
return Aux.control.wait_until(function() return stacking_complete end, function()
if target_slot then
return private.post_auction(target_slot, state.posted == state.count, private.process)
return private.post_auction(target_slot, private.process)
else
return public.stop()
end
@@ -32,9 +29,9 @@ function private.process()
return public.stop()
end
function private.post_auction(slot, partial, k)
function private.post_auction(slot, k)
local item_info = Aux.info.container_item(unpack(slot))
if item_info.item_key == state.item_key and Aux.info.auctionable(item_info.tooltip) and (item_info.aux_quantity == state.stack_size or partial and item_info.aux_quantity < state.stack_size) then
if item_info.item_key == state.item_key and Aux.info.auctionable(item_info.tooltip) and item_info.aux_quantity == state.stack_size then
ClearCursor()
ClickAuctionSellItemButton()
@@ -45,9 +42,6 @@ function private.post_auction(slot, partial, k)
StartAuction(max(1, Aux.round(state.unit_start_price * item_info.aux_quantity)), Aux.round(state.unit_buyout_price * item_info.aux_quantity), state.duration)
Aux.control.wait_until(function() return not GetContainerItemInfo(unpack(slot)) end, function()
if state.posted == state.count then
state.partial_stack = item_info.aux_quantity
end
state.posted = state.posted + 1
return k()
end)
@@ -63,17 +57,16 @@ function public.stop()
local callback = state.callback
local posted = state.posted
local partial_stack = state.partial_stack
state = nil
if callback then
callback(posted, partial_stack)
callback(posted)
end
end
end
function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, allow_partial, callback)
function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback)
public.stop()
local thread_id = Aux.control.new_thread(private.process)
@@ -86,7 +79,6 @@ function public.start(item_key, stack_size, duration, unit_start_price, unit_buy
unit_start_price = unit_start_price,
unit_buyout_price = unit_buyout_price,
count = count,
allow_partial = allow_partial,
posted = 0,
callback = callback,
}