big module refactoring
This commit is contained in:
+2
-2
@@ -10,7 +10,7 @@ function public.present(...)
|
||||
end
|
||||
end
|
||||
|
||||
function public.unpack(array, ...)
|
||||
function public.expand(array, ...)
|
||||
local table = {}
|
||||
for i=1,arg.n do
|
||||
table[arg[i]] = array[i]
|
||||
@@ -221,7 +221,7 @@ function public.bag_type(bag)
|
||||
return 1
|
||||
end
|
||||
for link in aux.util.present(GetInventoryItemLink('player', ContainerIDToInventoryID(bag))) do
|
||||
local item_id = aux.info.parse_hyperlink(link)
|
||||
local item_id = aux.info.parse_link(link)
|
||||
local item_info = aux.info.item(item_id)
|
||||
return aux.info.item_subclass_index(3, item_info.subclass)
|
||||
end
|
||||
|
||||
+2
-2
@@ -235,8 +235,8 @@ do
|
||||
end
|
||||
for _, parser in {
|
||||
{'class', aux.info.item_class_index},
|
||||
{'subclass', aux._(aux.info.item_subclass_index, aux.index(self.class, 2) or 0, aux.arg1)},
|
||||
{'slot', aux._(aux.info.item_slot_index, aux.index(self.class, 2) or 0, aux.index(self.subclass, 2) or 0, aux.arg1)},
|
||||
{'subclass', aux.C(aux.info.item_subclass_index, aux.index(self.class, 2) or 0, aux._1)},
|
||||
{'slot', aux.C(aux.info.item_slot_index, aux.index(self.class, 2) or 0, aux.index(self.subclass, 2) or 0, aux._1)},
|
||||
{'quality', aux.info.item_quality_index},
|
||||
} do
|
||||
if not self[parser[1]] then
|
||||
|
||||
+26
-30
@@ -38,9 +38,9 @@ do
|
||||
end
|
||||
|
||||
function public.container_item(bag, slot)
|
||||
for _, hyperlink in {GetContainerItemLink(bag, slot)} do
|
||||
for link in aux.util.present(GetContainerItemLink(bag, slot)) do
|
||||
|
||||
local item_id, suffix_id, unique_id, enchant_id = m.parse_hyperlink(hyperlink)
|
||||
local item_id, suffix_id, unique_id, enchant_id = m.parse_link(link)
|
||||
local item_info = m.item(item_id, suffix_id, unique_id, enchant_id)
|
||||
|
||||
local texture, count, locked, quality, readable, lootable = GetContainerItemInfo(bag, slot) -- quality not working?
|
||||
@@ -55,7 +55,7 @@ function public.container_item(bag, slot)
|
||||
unique_id = unique_id,
|
||||
enchant_id = enchant_id,
|
||||
|
||||
hyperlink = hyperlink,
|
||||
link = link,
|
||||
itemstring = item_info.itemstring,
|
||||
item_key = item_id..':'..suffix_id,
|
||||
|
||||
@@ -83,9 +83,7 @@ function public.container_item(bag, slot)
|
||||
end
|
||||
|
||||
function public.auction_sell_item()
|
||||
local name, texture, count, quality, usable, vendor_price = GetAuctionSellItemInfo()
|
||||
|
||||
if name then
|
||||
for name, texture, count, quality, usable, vendor_price in GetAuctionSellItemInfo do
|
||||
return {
|
||||
name = name,
|
||||
texture = texture,
|
||||
@@ -100,9 +98,9 @@ end
|
||||
function public.auction(index, query_type)
|
||||
query_type = query_type or 'list'
|
||||
|
||||
for _, hyperlink in {GetAuctionItemLink(query_type, index)} do
|
||||
for link in aux.util.present(GetAuctionItemLink(query_type, index)) do
|
||||
|
||||
local item_id, suffix_id, unique_id, enchant_id = m.parse_hyperlink(hyperlink)
|
||||
local item_id, suffix_id, unique_id, enchant_id = m.parse_link(link)
|
||||
local item_info = m.item(item_id, suffix_id, unique_id, enchant_id)
|
||||
|
||||
local name, texture, count, quality, usable, level, start_price, min_increment, buyout_price, high_bid, high_bidder, owner, sale_status = GetAuctionItemInfo(query_type, index)
|
||||
@@ -121,7 +119,7 @@ function public.auction(index, query_type)
|
||||
unique_id = unique_id,
|
||||
enchant_id = enchant_id,
|
||||
|
||||
hyperlink = hyperlink,
|
||||
link = link,
|
||||
itemstring = item_info.itemstring,
|
||||
item_key = item_id..':'..suffix_id,
|
||||
search_signature = table.concat({item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), _G.aux_ignore_owner and (aux.is_player(owner) and 0 or 1) or (owner or '?')}, ':'),
|
||||
@@ -179,7 +177,6 @@ end
|
||||
|
||||
function public.set_shopping_tooltip(slot)
|
||||
local index1, index2 = m.inventory_index(slot)
|
||||
|
||||
local tooltips = {}
|
||||
if index1 then
|
||||
local tooltip = m.tooltip(function(tt) tt:SetInventoryItem('player', index1) end)
|
||||
@@ -196,7 +193,6 @@ function public.set_shopping_tooltip(slot)
|
||||
|
||||
if tooltips[1] then
|
||||
tinsert(tooltips[1], 1, { left_text = 'Currently Equipped', left_color = { 0.5, 0.5, 0.5 } })
|
||||
|
||||
ShoppingTooltip1:SetOwner(GameTooltip, 'ANCHOR_BOTTOMRIGHT')
|
||||
m.load_tooltip(ShoppingTooltip1, tooltips[1])
|
||||
ShoppingTooltip1:Show()
|
||||
@@ -205,7 +201,6 @@ function public.set_shopping_tooltip(slot)
|
||||
|
||||
if tooltips[2] then
|
||||
tinsert(tooltips[2], 1, { left_text = 'Currently Equipped', left_color = { 0.5, 0.5, 0.5 } })
|
||||
|
||||
ShoppingTooltip2:SetOwner(ShoppingTooltip1, 'ANCHOR_BOTTOMRIGHT')
|
||||
m.load_tooltip(ShoppingTooltip2, tooltips[2])
|
||||
ShoppingTooltip2:Show()
|
||||
@@ -231,7 +226,6 @@ function public.tooltip_find(pattern, tooltip)
|
||||
count = count + 1
|
||||
end
|
||||
end
|
||||
|
||||
return count
|
||||
end
|
||||
|
||||
@@ -251,7 +245,7 @@ function public.load_tooltip(frame, tooltip)
|
||||
end
|
||||
|
||||
function public.display_name(item_id, no_brackets, no_color)
|
||||
for _, item_info in {aux.info.item(item_id)} do
|
||||
for item_info in aux.util.present(aux.info.item(item_id)) do
|
||||
local name = item_info.name
|
||||
if not no_brackets then
|
||||
name = '['..name..']'
|
||||
@@ -346,13 +340,13 @@ function public.durability(tooltip)
|
||||
end
|
||||
end
|
||||
|
||||
function public.item_key(hyperlink)
|
||||
local item_id, suffix_id = m.parse_hyperlink(hyperlink)
|
||||
function public.item_key(link)
|
||||
local item_id, suffix_id = m.parse_link(link)
|
||||
return item_id..':'..suffix_id
|
||||
end
|
||||
|
||||
function public.parse_hyperlink(hyperlink)
|
||||
local _, _, item_id, enchant_id, suffix_id, unique_id, name = strfind(hyperlink, '|c%x%x%x%x%x%x%x%x|Hitem:(%d*):(%d*):(%d*):(%d*)[:0-9]*|h%[(.-)%]|h|r')
|
||||
function public.parse_link(link)
|
||||
local _, _, item_id, enchant_id, suffix_id, unique_id, name = strfind(link, '|c%x%x%x%x%x%x%x%x|Hitem:(%d*):(%d*):(%d*):(%d*)[:0-9]*|h%[(.-)%]|h|r')
|
||||
return tonumber(item_id) or 0, tonumber(suffix_id) or 0, tonumber(unique_id) or 0, tonumber(enchant_id) or 0, name
|
||||
end
|
||||
|
||||
@@ -362,18 +356,20 @@ end
|
||||
|
||||
function public.item(item_id, suffix_id)
|
||||
local itemstring = 'item:'..(item_id or 0)..':0:'..(suffix_id or 0)..':0'
|
||||
local name, itemstring, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
|
||||
return name and {
|
||||
name = name,
|
||||
itemstring = itemstring,
|
||||
quality = quality,
|
||||
level = level,
|
||||
class = class,
|
||||
subclass = subclass,
|
||||
slot = slot,
|
||||
max_stack = max_stack,
|
||||
texture = texture,
|
||||
} or aux.cache.item_info(item_id)
|
||||
for name, itemstring, quality, level, class, subclass, max_stack, slot, texture in aux.util.present(GetItemInfo(itemstring)) do
|
||||
return {
|
||||
name = name,
|
||||
itemstring = itemstring,
|
||||
quality = quality,
|
||||
level = level,
|
||||
class = class,
|
||||
subclass = subclass,
|
||||
slot = slot,
|
||||
max_stack = max_stack,
|
||||
texture = texture,
|
||||
}
|
||||
end
|
||||
return aux.cache.item_info(item_id)
|
||||
end
|
||||
|
||||
function public.item_class_index(item_class)
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ function public.copper(gold, silver, copper)
|
||||
return gold * m.COPPER_PER_GOLD + silver * m.COPPER_PER_SILVER + copper
|
||||
end
|
||||
|
||||
function public.format(money, exact, color)
|
||||
function public.to_string2(money, exact, color)
|
||||
color = color or FONT_COLOR_CODE_CLOSE
|
||||
|
||||
local TEXT_NONE = '0'
|
||||
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
aux.module 'sort'
|
||||
aux.module 'sorting'
|
||||
|
||||
public.LT = {}
|
||||
public.EQ = {}
|
||||
@@ -24,7 +24,6 @@ function public.multi_lt(xs, ys)
|
||||
elseif not ys[i] then
|
||||
return false
|
||||
end
|
||||
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user