refactoring
This commit is contained in:
+13
-13
@@ -1,15 +1,15 @@
|
||||
local m, public, private = Aux.module'post'
|
||||
|
||||
local state
|
||||
private.state = nil
|
||||
|
||||
function private.process()
|
||||
if state.posted < state.count then
|
||||
if m.state.posted < m.state.count then
|
||||
|
||||
local stacking_complete, target_slot
|
||||
|
||||
Aux.stack.start(
|
||||
state.item_key,
|
||||
state.stack_size,
|
||||
m.state.item_key,
|
||||
m.state.stack_size,
|
||||
function(slot)
|
||||
stacking_complete = true
|
||||
target_slot = slot
|
||||
@@ -30,7 +30,7 @@ end
|
||||
|
||||
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 then
|
||||
if item_info.item_key == m.state.item_key and Aux.info.auctionable(item_info.tooltip) and item_info.aux_quantity == m.state.stack_size then
|
||||
|
||||
ClearCursor()
|
||||
ClickAuctionSellItemButton()
|
||||
@@ -39,7 +39,7 @@ function private.post_auction(slot, k)
|
||||
ClickAuctionSellItemButton()
|
||||
ClearCursor()
|
||||
|
||||
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)
|
||||
StartAuction(max(1, Aux.round(m.state.unit_start_price * item_info.aux_quantity)), Aux.round(m.state.unit_buyout_price * item_info.aux_quantity), m.state.duration)
|
||||
|
||||
local posted
|
||||
local listener = Aux.control.event_listener('CHAT_MSG_SYSTEM')
|
||||
@@ -51,7 +51,7 @@ function private.post_auction(slot, k)
|
||||
end)
|
||||
listener:start()
|
||||
Aux.control.wait_until(function() return posted end, function()
|
||||
state.posted = state.posted + 1
|
||||
m.state.posted = m.state.posted + 1
|
||||
return k()
|
||||
end)
|
||||
|
||||
@@ -61,13 +61,13 @@ function private.post_auction(slot, k)
|
||||
end
|
||||
|
||||
function public.stop()
|
||||
if state then
|
||||
Aux.control.kill_thread(state.thread_id)
|
||||
if m.state then
|
||||
Aux.control.kill_thread(m.state.thread_id)
|
||||
|
||||
local callback = state.callback
|
||||
local posted = state.posted
|
||||
local callback = m.state.callback
|
||||
local posted = m.state.posted
|
||||
|
||||
state = nil
|
||||
m.state = nil
|
||||
|
||||
if callback then
|
||||
callback(posted)
|
||||
@@ -80,7 +80,7 @@ function public.start(item_key, stack_size, duration, unit_start_price, unit_buy
|
||||
|
||||
local thread_id = Aux.control.new_thread(m.process)
|
||||
|
||||
state = {
|
||||
m.state = {
|
||||
thread_id = thread_id,
|
||||
item_key = item_key,
|
||||
stack_size = stack_size,
|
||||
|
||||
Reference in New Issue
Block a user