Postkeybind

1. Improved autopricing heuristics
2. Added post keybind for much faster mass posting of items
This commit is contained in:
geojak
2022-03-07 17:43:42 +01:00
committed by GitHub
parent 02cfc420dd
commit 4517dae952
6 changed files with 102 additions and 48 deletions
+5
View File
@@ -0,0 +1,5 @@
<Bindings>
<Binding name="Aux Post" header="AUX">
post_auctions_bind()
</Binding>
</Bindings>
+3
View File
@@ -0,0 +1,3 @@
1. Added auto bid feature, doubled the existing auto buy code and slighly editted
2. Added auto pricing heuristic, these are activate when posting an item with bid price 0, the buyout price works as a minimum
3. Added a keybind for the post button, this significantly speeds up mass posting of items
+2
View File
@@ -51,4 +51,6 @@ tabs\bids\frame.lua
core\crafting.lua
localization.lua
+31 -47
View File
@@ -33,37 +33,6 @@ function process()
return stop()
end
function post_auction2(slot, k)
local item_info = info.container_item(unpack(slot))
if item_info.item_key == state.item_key and info.auctionable(item_info.tooltip, nil, true) and item_info.aux_quantity == state.stack_size then
ClearCursor()
ClickAuctionSellItemButton()
ClearCursor()
PickupContainerItem(unpack(slot))
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)
local send_signal, signal_received = aux.signal()
aux.when(signal_received, function()
state.posted = state.posted + 1
return k()
end)
local posted
aux.event_listener('CHAT_MSG_SYSTEM', function(kill)
if arg1 == ERR_AUCTION_STARTED then
send_signal()
kill()
end
end)
else
return stop()
end
end
function post_auction(slot, k)
local item_info = info.container_item(unpack(slot))
if item_info.item_key == state.item_key and info.auctionable(item_info.tooltip, nil, true) and item_info.aux_quantity == state.stack_size then
@@ -77,37 +46,52 @@ function post_auction(slot, k)
local start_price = state.unit_start_price
local buyout_price = state.unit_buyout_price
local kz_undercut = 0
local kz_daily = 0
local kz_pricing = 0
--use autoprice heuristic if start bid 0 is set
if start_price == 0 then
if buyout_price > 0 then
kz_pricing=1
end
if history.market_value(state.item_key) ~= nil then
start_price = max(start_price,0.93*tonumber(history.market_value(state.item_key)))
buyout_price = max(buyout_price,0.99*tonumber(history.market_value(state.item_key)))
kz_undercut = 1
local tmp = tonumber(history.market_value(state.item_key))
tmp = max(0.99*tmp,tmp-50)
buyout_price = max(buyout_price,tmp)
kz_daily = 1
end
if disenchant.value(item_info.slot, item_info.quality, item_info.level) ~= nil then
buyout_price = max(buyout_price,0.80* tonumber(disenchant.value(item_info.slot, item_info.quality, item_info.level)))
buyout_price = max(buyout_price,0.85* tonumber(disenchant.value(item_info.slot, item_info.quality, item_info.level)))
end
if aux.account_data.merchant_sell[item_info.item_id] ~= nil then
start_price = max(start_price,tonumber(aux.account_data.merchant_sell[item_info.item_id]) * 1.35)
buyout_price = max(buyout_price,start_price)
if kz_undercut == 0 then
if aux.account_data.merchant_sell[item_info.item_id] ~= nil then
if kz_daily == 0 then
start_price = max(start_price,tonumber(aux.account_data.merchant_sell[item_info.item_id]) * (1.35+3.65*math.exp(-(1/4000)* tonumber(aux.account_data.merchant_sell[item_info.item_id] ))))
buyout_price = max(buyout_price,start_price)
else
start_price = max(start_price,tonumber(aux.account_data.merchant_sell[item_info.item_id]) * 1.35)
buyout_price = max(buyout_price,start_price)
end
end
if aux.account_data.merchant_buy[item_info.item_id] ~= nil then
local tmp = tostring(aux.account_data.merchant_buy[item_info.item_id])
tmp = strsub(tmp,1,-3)
start_price = max(start_price,tonumber(tmp) * 1.1)
buyout_price = max(buyout_price,tonumber(tmp) * 1.15)
end
if history.value(state.item_key) ~= nil then
start_price = max(start_price,0.89*tonumber(history.value(state.item_key)))
buyout_price = max(buyout_price,0.89*tonumber(history.value(state.item_key)))
if kz_undercut == 0 then
buyout_price = max(buyout_price,1.0* tonumber(history.value(state.item_key)))
if kz_pricing == 1 and kz_daily == 1 then
buyout_price = max(buyout_price,1.0*tonumber(history.value(state.item_key)))
elseif kz_daily == 1 then
start_price = max(start_price,0.91*tonumber(history.value(state.item_key)))
buyout_price = max(buyout_price,0.91*tonumber(history.value(state.item_key)))
else
buyout_price = max(buyout_price,0.99* tonumber(history.value(state.item_key)))
end
end
+7
View File
@@ -0,0 +1,7 @@
BINDING_HEADER_AUX = "aux";
local post = require 'aux.tabs.post'
function post_auctions_bind()
post.post_auctions_bind()
end
+54 -1
View File
@@ -248,6 +248,58 @@ function post_auctions()
end
end
function M.post_auctions_bind()
if selected_item then
local unit_start_price = get_unit_start_price()
local unit_buyout_price = get_unit_buyout_price()
local stack_size = stack_size_slider:GetValue()
local stack_count
stack_count = stack_count_slider:GetValue()
local duration = UIDropDownMenu_GetSelectedValue(duration_dropdown)
local key = selected_item.key
local duration_code
if duration == DURATION_2 then
duration_code = 2
elseif duration == DURATION_8 then
duration_code = 3
elseif duration == DURATION_24 then
duration_code = 4
end
post.start(
key,
stack_size,
duration,
unit_start_price,
unit_buyout_price,
stack_count,
function(posted)
if not frame:IsShown() then
return
end
for i = 1, posted do
record_auction(key, stack_size, unit_start_price * stack_size, unit_buyout_price, duration_code, UnitName'player')
end
update_inventory_records()
local same
for _, record in inventory_records do
if record.key == key then
same = record
break
end
end
if same then
update_item(same)
else
selected_item = nil
end
refresh = true
end
)
end
end
function validate_parameters()
if not selected_item then
post_button:Disable()
@@ -390,7 +442,8 @@ function update_item(item)
else
stack_size_slider:SetMinMaxValues(1, min(selected_item.max_stack, selected_item.aux_quantity))
end
stack_size_slider:SetValue(aux.huge)
--stack_size_slider:SetValue(aux.huge)
stack_size_slider:SetValue(1)
quantity_update(true)
unit_start_price_input:SetText(money.to_string(settings.start_price, true, nil, nil, true))