big refactoring

This commit is contained in:
Manuel Simon Hirsig
2016-08-21 14:29:01 +02:00
parent 2b9a63fe8c
commit 590347a1e5
23 changed files with 236 additions and 263 deletions
+17 -17
View File
@@ -3,7 +3,7 @@ aux.module 'post'
state = nil
function process()
if m.state.posted < m.state.count then
if state.posted < state.count then
local stacking_complete
@@ -11,21 +11,21 @@ function process()
control.when(signal_received, function()
local slot = signal_received()[1]
if slot then
return m.post_auction(slot, m.process)
return post_auction(slot, process)
else
return m.stop()
return stop()
end
end)
return stack.start(m.state.item_key, m.state.stack_size, send_signal)
return stack.start(state.item_key, state.stack_size, send_signal)
end
return m.stop()
return stop()
end
function post_auction(slot, k)
local item_info = info.container_item(unpack(slot))
if item_info.item_key == m.state.item_key and info.auctionable(item_info.tooltip) and item_info.aux_quantity == m.state.stack_size then
if item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and item_info.aux_quantity == state.stack_size then
ClearCursor()
ClickAuctionSellItemButton()
@@ -34,11 +34,11 @@ function post_auction(slot, k)
ClickAuctionSellItemButton()
ClearCursor()
StartAuction(max(1, round(m.state.unit_start_price * item_info.aux_quantity)), round(m.state.unit_buyout_price * item_info.aux_quantity), m.state.duration)
StartAuction(max(1, round(state.unit_start_price * item_info.aux_quantity)), round(state.unit_buyout_price * item_info.aux_quantity), state.duration)
local send_signal, signal_received = signal()
control.when(signal_received, function()
m.state.posted = m.state.posted + 1
state.posted = state.posted + 1
return k()
end)
@@ -50,18 +50,18 @@ function post_auction(slot, k)
end
end)
else
return m.stop()
return stop()
end
end
function public.stop()
if m.state then
control.kill_thread(m.state.thread_id)
if state then
control.kill_thread(state.thread_id)
local callback = m.state.callback
local posted = m.state.posted
local callback = state.callback
local posted = state.posted
m.state = nil
state = nil
if callback then
callback(posted)
@@ -70,11 +70,11 @@ function public.stop()
end
function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback)
m.stop()
stop()
local thread_id = control.thread(m.process)
local thread_id = control.thread(process)
m.state = {
state = {
thread_id = thread_id,
item_key = item_key,
stack_size = stack_size,