fixed a bug when trying to auction an unauctionable item
This commit is contained in:
@@ -20,3 +20,5 @@ about.xml
|
|||||||
|
|
||||||
list.xml
|
list.xml
|
||||||
|
|
||||||
|
completion.lua
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
local NUM_MATCHES = 5
|
||||||
|
|
||||||
|
local item_names = {}
|
||||||
|
for item_id=1,100 do
|
||||||
|
local name = GetItemInfo(item_id)
|
||||||
|
tinsert(item_names, name)
|
||||||
|
end
|
||||||
|
|
||||||
|
function leven(s,t)
|
||||||
|
if s == '' then return strlen(t) end
|
||||||
|
if t == '' then return strlen(s) end
|
||||||
|
|
||||||
|
local s1 = string.sub(s, 2, -1)
|
||||||
|
local t1 = string.sub(t, 2, -1)
|
||||||
|
|
||||||
|
if string.sub(s, 0, 1) == string.sub(t, 0, 1) then
|
||||||
|
return leven(s1, t1)
|
||||||
|
end
|
||||||
|
|
||||||
|
return 1 + math.min(
|
||||||
|
leven(s1, t1),
|
||||||
|
leven(s, t1),
|
||||||
|
leven(s1, t)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
function get_matches(input)
|
||||||
|
local closest = {}
|
||||||
|
for _, name in pairs(item_names) do
|
||||||
|
local edit_distance = leven(input, name)
|
||||||
|
if getn(closest) < NUM_MATCHES then
|
||||||
|
tinsert(closest, { name=name, edit_distance=edit_distance })
|
||||||
|
else
|
||||||
|
sort(closest, function(a, b) return a.edit_distance > b.edit_distance end)
|
||||||
|
if closest[1].edit_distance > edit_distance then
|
||||||
|
closest[1] = { name=name, edit_distance=edit_distance }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, winner in ipairs(closest) do
|
||||||
|
Aux.log(winner.name)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -28,23 +28,26 @@ end
|
|||||||
function Aux.info.auction_sell_item()
|
function Aux.info.auction_sell_item()
|
||||||
local name, texture, stack_size, quality, usable, vendor_price, vendor_price_per_unit, max_stack, total_count = GetAuctionSellItemInfo()
|
local name, texture, stack_size, quality, usable, vendor_price, vendor_price_per_unit, max_stack, total_count = GetAuctionSellItemInfo()
|
||||||
local base_deposit = CalculateAuctionDeposit(120) / stack_size
|
local base_deposit = CalculateAuctionDeposit(120) / stack_size
|
||||||
auction_sell_item = name and {
|
|
||||||
name = name,
|
|
||||||
texture = texture,
|
|
||||||
stack_size = stack_size,
|
|
||||||
quality = quality,
|
|
||||||
usable = usable,
|
|
||||||
vendor_price = vendor_price,
|
|
||||||
vendor_price_per_unit = vendor_price_per_unit,
|
|
||||||
max_stack = max_stack,
|
|
||||||
total_count = total_count,
|
|
||||||
base_deposit = base_deposit,
|
|
||||||
}
|
|
||||||
|
|
||||||
auction_sell_item.tooltip = Aux.info.tooltip(function(tt) tt:SetAuctionSellItem() end)
|
if name then
|
||||||
auction_sell_item.charges = item_charges(auction_sell_item.tooltip)
|
auction_sell_item = {
|
||||||
|
name = name,
|
||||||
return auction_sell_item
|
texture = texture,
|
||||||
|
stack_size = stack_size,
|
||||||
|
quality = quality,
|
||||||
|
usable = usable,
|
||||||
|
vendor_price = vendor_price,
|
||||||
|
vendor_price_per_unit = vendor_price_per_unit,
|
||||||
|
max_stack = max_stack,
|
||||||
|
total_count = total_count,
|
||||||
|
base_deposit = base_deposit,
|
||||||
|
}
|
||||||
|
|
||||||
|
auction_sell_item.tooltip = Aux.info.tooltip(function(tt) tt:SetAuctionSellItem() end)
|
||||||
|
auction_sell_item.charges = item_charges(auction_sell_item.tooltip)
|
||||||
|
|
||||||
|
return auction_sell_item
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Aux.info.auction_item(index)
|
function Aux.info.auction_item(index)
|
||||||
|
|||||||
@@ -289,6 +289,7 @@ function Aux.sell.set_auction(bag, slot)
|
|||||||
PickupContainerItem(bag,slot)
|
PickupContainerItem(bag,slot)
|
||||||
ClickAuctionSellItemButton()
|
ClickAuctionSellItemButton()
|
||||||
local auction_sell_item = Aux.info.auction_sell_item() -- TODO
|
local auction_sell_item = Aux.info.auction_sell_item() -- TODO
|
||||||
|
ClearCursor()
|
||||||
ClickAuctionSellItemButton()
|
ClickAuctionSellItemButton()
|
||||||
ClearCursor()
|
ClearCursor()
|
||||||
|
|
||||||
@@ -307,7 +308,7 @@ function Aux.sell.set_auction(bag, slot)
|
|||||||
has_charges = container_item.charges ~= nil,
|
has_charges = container_item.charges ~= nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
if current_auction and not auxSellEntries[current_auction.name] then
|
if not auxSellEntries[current_auction.name] then
|
||||||
refresh_entries()
|
refresh_entries()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user