From 2bc08b93591b050f65034cd8ef8fc3ef68b10dc5 Mon Sep 17 00:00:00 2001 From: Manuel Simon Hirsig Date: Sat, 10 Oct 2015 14:43:00 +0200 Subject: [PATCH] some refactorings --- core.lua | 2 +- post.lua | 115 +++++++++++++++++++++++++++++++----------------------- post.xml | 8 ---- scan.xml | 5 --- stack.lua | 2 +- stack.xml | 3 -- 6 files changed, 68 insertions(+), 67 deletions(-) delete mode 100644 scan.xml delete mode 100644 stack.xml diff --git a/core.lua b/core.lua index 3cf5b3e..51ed742 100644 --- a/core.lua +++ b/core.lua @@ -1,4 +1,4 @@ -AuxVersion = "1.4.2" +AuxVersion = "1.4.3" AuxAuthors = "shirsig; Zerf; Zirco (Auctionator); Nimeral (Auctionator backport)" local lastRightClickAction = GetTime() diff --git a/post.lua b/post.lua index 368a5b2..c7fe8f0 100644 --- a/post.lua +++ b/post.lua @@ -2,44 +2,59 @@ Aux.post = { orig = {} } +local controller = (function() + local controller + return function() + controller = controller or Aux.control.controller() + return controller + end +end)() + local state -local post_auction +local post_auction, stop, process -local DELAY = 0.5 - -local last_posted = GetTime() - -function Aux.post.onupdate() - if state then - if state.auctioning then - if not GetContainerItemInfo(state.auctioning.bag, state.auctioning.bag_slot) then - state.auctioning = nil +function process() + if state.posted < state.count then + local stacking_complete + local stack_slot + + Aux.stack.start( + state.name, + state.stack_size, + function(slot) + stacking_complete = true + stack_slot = slot + end + ) + + controller().wait(function() return stacking_complete end, function() + if stack_slot then + post_auction(stack_slot, function() state.posted = state.posted + 1 - end - end - if state.posted < state.count then - if not state.stacking and not state.auctioning then - state.stacking = true - Aux.stack.start( - state.name, - state.stack_size, - function(slot) - if state and slot then - post_auction(slot) - else - Aux.post.stop() - end - end - ) - end + process() + end) else - Aux.post.stop() + stop() end + end) + else + stop() end end -function Aux.post.stop() +function Aux.post.stop(k) + Aux.control.on_next_update(function() + stop() + + if k then + return k() + end + end) +end + +function stop() + controller().reset() if state then local callback = state.callback local posted = state.posted @@ -52,7 +67,7 @@ function Aux.post.stop() end end -function post_auction(slot) +function post_auction(slot, k) ClearCursor() ClickAuctionSellItemButton() ClearCursor() @@ -60,26 +75,28 @@ function post_auction(slot) ClickAuctionSellItemButton() ClearCursor() StartAuction(state.bid, state.buyout, state.duration) - state.auctioning = slot - state.stacking = false - -- TODO CHAT_MSG_SYSTEM arg1 + controller().wait(function() return not GetContainerItemInfo(slot.bag, slot.bag_slot) end, k) end function Aux.post.start(name, stack_size, duration, bid, buyout, count, callback) - Aux.post.stop() - - ClearCursor() - ClickAuctionSellItemButton() - ClearCursor() - - state = { - name = name, - stack_size = stack_size, - duration = duration, - bid = bid, - buyout = buyout, - count = count, - posted = 0, - callback = callback, - } + Aux.control.on_next_update(function() + stop() + + ClearCursor() + ClickAuctionSellItemButton() + ClearCursor() + + state = { + name = name, + stack_size = stack_size, + duration = duration, + bid = bid, + buyout = buyout, + count = count, + posted = 0, + callback = callback, + } + + process() + end) end \ No newline at end of file diff --git a/post.xml b/post.xml index 1bbdaa3..4dce3eb 100644 --- a/post.xml +++ b/post.xml @@ -1,11 +1,3 @@