fixed a bug when trying to auction an unauctionable item

This commit is contained in:
Manuel Simon Hirsig
2015-10-06 19:08:20 +02:00
parent 30448813df
commit cfe55f902b
4 changed files with 67 additions and 17 deletions
+2
View File
@@ -20,3 +20,5 @@ about.xml
list.xml
completion.lua
+44
View File
@@ -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
+19 -16
View File
@@ -28,23 +28,26 @@ end
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 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)
auction_sell_item.charges = item_charges(auction_sell_item.tooltip)
return auction_sell_item
if name then
auction_sell_item = {
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)
auction_sell_item.charges = item_charges(auction_sell_item.tooltip)
return auction_sell_item
end
end
function Aux.info.auction_item(index)
+2 -1
View File
@@ -289,6 +289,7 @@ function Aux.sell.set_auction(bag, slot)
PickupContainerItem(bag,slot)
ClickAuctionSellItemButton()
local auction_sell_item = Aux.info.auction_sell_item() -- TODO
ClearCursor()
ClickAuctionSellItemButton()
ClearCursor()
@@ -307,7 +308,7 @@ function Aux.sell.set_auction(bag, slot)
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()
end