|
|
@@ -19,6 +19,13 @@ end |
|
|
|
local function un_quote(s) |
|
|
|
return string.gsub(s, "'", "") |
|
|
|
end |
|
|
|
local function max(a, b) |
|
|
|
if (a > b) then |
|
|
|
return a |
|
|
|
else |
|
|
|
return b |
|
|
|
end |
|
|
|
end |
|
|
|
local function matches(a, b) |
|
|
|
if starts_with(a, "lte:") then |
|
|
|
return (tonumber(string.sub(a, 5)) >= tonumber(b)) |
|
|
@@ -29,7 +36,7 @@ local function matches(a, b) |
|
|
|
end |
|
|
|
end |
|
|
|
local function find_items(params, _3fsort) |
|
|
|
_G.assert((nil ~= params), "Missing argument params on main.fnl:37") |
|
|
|
_G.assert((nil ~= params), "Missing argument params on main.fnl:42") |
|
|
|
local results |
|
|
|
do |
|
|
|
local tbl_17_auto = {} |
|
|
@@ -63,7 +70,7 @@ local function find_items(params, _3fsort) |
|
|
|
end |
|
|
|
end |
|
|
|
local function find_item(params, _3fsort) |
|
|
|
_G.assert((nil ~= params), "Missing argument params on main.fnl:52") |
|
|
|
_G.assert((nil ~= params), "Missing argument params on main.fnl:57") |
|
|
|
local results = find_items(params, _3fsort) |
|
|
|
if results then |
|
|
|
return first(results) |
|
|
@@ -75,14 +82,14 @@ local function find_item_by_name(name) |
|
|
|
return find_item({[8] = name}) |
|
|
|
end |
|
|
|
local function find_next_better_item(class, subclass, invtype, lv, ilv, stat_position, item_stat, _3fsort) |
|
|
|
return find_items({[4] = class, [6] = subclass, [10] = invtype, [14] = string.format("gte:%d", (lv - 4)), [stat_position] = string.format("gte:%d", item_stat)}, _3fsort) |
|
|
|
return find_items({[4] = class, [6] = subclass, [10] = invtype, [14] = string.format("lte:%d", lv), [stat_position] = string.format("gte:%d", item_stat)}, _3fsort) |
|
|
|
end |
|
|
|
local function find_good_item(invtype, lv, stat_position, stat_baseline, _3fsort) |
|
|
|
_G.assert((nil ~= stat_baseline), "Missing argument stat-baseline on main.fnl:72") |
|
|
|
_G.assert((nil ~= stat_position), "Missing argument stat-position on main.fnl:72") |
|
|
|
_G.assert((nil ~= lv), "Missing argument lv on main.fnl:72") |
|
|
|
_G.assert((nil ~= invtype), "Missing argument invtype on main.fnl:72") |
|
|
|
return find_items({[10] = invtype, [14] = string.format("gte:%d", (lv - 6)), [stat_position] = string.format("gte:%d", stat_baseline)}, _3fsort) |
|
|
|
_G.assert((nil ~= stat_baseline), "Missing argument stat-baseline on main.fnl:77") |
|
|
|
_G.assert((nil ~= stat_position), "Missing argument stat-position on main.fnl:77") |
|
|
|
_G.assert((nil ~= lv), "Missing argument lv on main.fnl:77") |
|
|
|
_G.assert((nil ~= invtype), "Missing argument invtype on main.fnl:77") |
|
|
|
return find_items({[10] = invtype, [14] = string.format("lte:%d", lv), [stat_position] = string.format("gte:%d", stat_baseline)}, _3fsort) |
|
|
|
end |
|
|
|
local function parse_opts(msg) |
|
|
|
local tbl_17_auto = {} |
|
|
@@ -129,10 +136,10 @@ local function main0(msg) |
|
|
|
end |
|
|
|
opts = tbl_17_auto |
|
|
|
end |
|
|
|
local _let_10_ = opts |
|
|
|
local slot = _let_10_[1] |
|
|
|
local stat = _let_10_[2] |
|
|
|
local gear_index = _let_10_[3] |
|
|
|
local _let_11_ = opts |
|
|
|
local slot = _let_11_[1] |
|
|
|
local stat = _let_11_[2] |
|
|
|
local gear_index = _let_11_[3] |
|
|
|
local slot0 = (slot .. "Slot") |
|
|
|
local stat0 = (21 + tonumber(stat)) |
|
|
|
local gear_index0 = tonumber((gear_index or "1")) |
|
|
@@ -141,11 +148,12 @@ local function main0(msg) |
|
|
|
local p_level = UnitLevel("player") |
|
|
|
if not i_link then |
|
|
|
local best |
|
|
|
local function _11_(a, b) |
|
|
|
return (a[12] < b[12]) |
|
|
|
local function _12_(a, b) |
|
|
|
return ((a[stat0] < b[stat0]) and (a[12] < b[12])) |
|
|
|
end |
|
|
|
best = (find_good_item(inv_slot, UnitLevel("player"), stat0, 0, _11_))[gear_index0] |
|
|
|
best = (find_good_item(inv_slot, UnitLevel("player"), stat0, 1, _12_))[gear_index0] |
|
|
|
if best then |
|
|
|
DEFAULT_CHAT_FRAME:AddMessage(string.format("|Hitem:%d:0:0:0:0:0:0:0:0|h[%s]|h|r", best[2], best[8])) |
|
|
|
return ui_print(("next best available: " .. best[8] .. " " .. stat_print(best) .. " at " .. best[20] .. "N/A")) |
|
|
|
else |
|
|
|
return nil |
|
|
@@ -160,11 +168,12 @@ local function main0(msg) |
|
|
|
local i_level = stats[12] |
|
|
|
local i_stat = stats[stat0] |
|
|
|
local best |
|
|
|
local function _13_(a, b) |
|
|
|
local function _14_(a, b) |
|
|
|
return (a[stat0] < b[stat0]) |
|
|
|
end |
|
|
|
best = (find_next_better_item(i_class, i_subclass, i_invtype, p_level, i_level, stat0, i_stat, _13_))[gear_index0] |
|
|
|
best = (find_next_better_item(i_class, i_subclass, i_invtype, p_level, i_level, stat0, max(i_stat, 1), _14_))[gear_index0] |
|
|
|
if best then |
|
|
|
DEFAULT_CHAT_FRAME:AddMessage(string.format("|Hitem:%d:0:0:0:0:0:0:0:0|h[%s]|h|r", best[2], best[8])) |
|
|
|
ui_print(("next best available: " .. best[8] .. " " .. stat_print(best) .. " at " .. best[20] .. "N/A")) |
|
|
|
ui_print(("currently equipped " .. i_name .. " " .. (stats[stat0] or "N/A"))) |
|
|
|
else |
|
|
|