Module:GEMinMax: Difference between revisions

Jump to navigation Jump to search
1,399 bytes removed ,  17 October 2024
no edit summary
(Created page with "-- <nowiki> local prices = mw.loadJsonData('Module:GEPrices/data.json') local _coins = require('Module:Currency')._amount local p = {} local fmap = { wikitable = 'wikitable', wikitablereverse = 'wikitablereverse', table = 'wikitable', t = 'wikitable', rtable = 'wikitablereverse', rt = 'wikitablereverse', bracket = 'bracket', b = 'bracket', backetreverse = 'backetreverse', rb = 'backetreverse', item = 'item', price = 'price', none = 'none' } local formats =...")
 
No edit summary
Tag: Reverted
Line 1:
-- <nowiki>
local prices = mw.loadJsonData('Module:GEPrices/data.json')
local _coins = require('Module:Currency')._amount
local p = {}
local expr = mw.ext.ParserFunctions.expr
 
function p._maxmin(argsframe)
local fmap = {
local args = getargs(frame)
wikitable = 'wikitable',
return p._min(args)
wikitablereverse = 'wikitablereverse',
end
table = 'wikitable',
t = 'wikitable',
rtable = 'wikitablereverse',
rt = 'wikitablereverse',
bracket = 'bracket',
b = 'bracket',
backetreverse = 'backetreverse',
rb = 'backetreverse',
item = 'item',
price = 'price',
none = 'none'
}
 
local formats = {
wikitable = function(i,v) return string.format('| %s\n| %s', i, v) end,
wikitablereverse = function(i,v) return string.format('| %s\n| %s', v, i) end,
bracket = function(i,v) return string.format('%s (%s)', i, v) end,
backetreverse = function(i,v) return string.format('%s (%s)', v, i) end,
item = function(i,v) return i end,
price = function(i,v) return v end,
none = function(i,v) return '' end
}
 
function findValp._min(comp, def, argstbl)
local itemlow = '@unknown@'tbl[1]
local value = def
for i_, v in ipairs(argstbl) do
localif prv =< prices[v]low then
if low pr= thenv
if comp(pr, value) then
value = pr
item = v
end
end
end
return item, valuelow
end
 
function p._minmax(argsframe)
local args = getargs(frame)
return findVal(function(pr,v) return v > pr end, math.huge, args)
return p._max(args)
end
function p._max(args)
return findVal(function(pr,v) return v < pr end, -1, args)
end
 
function p.main_max(frametbl)
local chigh = frame.argstbl[1]
local pargs = frame:getParent().args
for _, v in ipairs(tbl) do
local f = fmap[pargs.format]
if comp(pr,v value)> high then
f = formats[f] or formats.bracket
valuehigh = prv
local r1, r2 = p['_'..c](pargs)
end
if pargs.coins == 'y' then
r2 = _coins(r2, 'coins')
elseif pargs.coins == 'n' then
r2 = _coins(r2, 'nocoins')
elseif pargs.coins == 'f' then
r2 = mw.getContentLanguage():formatNum(r2)
end
if pargs.link == 'plp' then
r1 = string.format('[[File:%s.png|link=%s]]', r1, r1)
elseif pargs.link == 'p' then
r1 = string.format('[[File:%s.png|link=%s]] [[%s]]', r1, r1, r1)
elseif not pargs.link then
r1 = string.format('[[%s]]', r1)
end
return high
if pargs.var then
end
mw.ext.VariablesLua.vardefine(pargs.var..'_item', r1)
 
mw.ext.VariablesLua.vardefine(pargs.var..'_price', r2)
function getargs(frame)
local pargsargs = frame:getParent().args
local fmapnums = {}
for _, v in ipairs(args) do
r1local w = string.formatgsub(v,'[[%s]],', r1'')
w = tonumber(w) or tonumber(expr(w))
if pargs.varw then
table.insert(nums,w)
end
end
return f(r1, r2)nums
end
 
 
return p
-- </nowiki>

Navigation menu