forked from evl/auctionlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExternal.lua
More file actions
47 lines (41 loc) · 1.2 KB
/
External.lua
File metadata and controls
47 lines (41 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
-------------------------------------------------------------------------------
-- External.lua
--
-- Implement external API.
-------------------------------------------------------------------------------
-- External interface for vendor values.
-- Deprecated due to addition of built-in vendor values.
function AuctionLite:GetVendorValue()
return nil;
end
-- External interface for auction values.
function AuctionLite:GetAuctionValue(arg1, arg2)
local result = nil;
-- If we got a number, use it.
-- If we got a string or a link, parse it.
local id;
local suffix;
if type(arg1) == "number" then
id = arg1;
suffix = arg2;
if suffix == nil then
suffix = 0;
end
elseif type(arg1) == "string" then
_, _, id, suffix = self:SplitLink(arg1);
end
-- Now look up the price.
if id ~= nil then
local hist = self:GetHistoricalPriceById(id, suffix);
if hist ~= nil then
result = math.floor(hist.price);
end
end
return result;
end
-- Implement Tekkub's GetAuctionBuyout.
local origGetAuctionBuyout = GetAuctionBuyout;
function GetAuctionBuyout(item)
return AuctionLite:GetAuctionValue(item) or
(origGetAuctionBuyout and origGetAuctionBuyout(item));
end