模块:Qualityprice:修订间差异
来自星露谷物语扩展百科
更多操作
删除的内容 添加的内容
无编辑摘要 |
无编辑摘要 |
||
| 第1行: | 第1行: | ||
local cache = require "mw.ext.LuaCache" |
|||
local KEY_PREFIX = "Module:Qp" |
|||
local EXP_TIME = 172800 |
|||
local p = {} |
local p = {} |
||
function |
local function expandTemplate(args) |
||
local |
local templateArgs = {} |
||
| ⚫ | |||
| ⚫ | |||
if value ~= "" then |
|||
local bp = args[2] or "0" |
|||
templateArgs[key] = value |
|||
local pm = args['pm'] or "1" |
|||
| ⚫ | |||
local cacheKey = KEY_PREFIX .. "|Data|" .. name .. "|" .. bp .. "|" .. pm |
|||
| ⚫ | |||
local priceData |
|||
| ⚫ | |||
local cached = cache.get(cacheKey) |
|||
| ⚫ | |||
| ⚫ | |||
if cached then |
|||
templateArgs[1], |
|||
priceData = mw.text.jsonDecode(cached) |
|||
templateArgs[2], |
|||
else |
|||
pm = templateArgs['pm'], |
|||
priceData = {} |
|||
dsv = templateArgs['dsv'], |
|||
hide = templateArgs['hide'], |
|||
| ⚫ | |||
| ⚫ | |||
priceData[k] = frame:preprocess(string.format("{{#invoke:Templates|csp|im=%s|bp=%s|q=%d|pm=%s|fm=true}}", name, bp, v, pm)) |
|||
} |
|||
| ⚫ | |||
} |
|||
cache.set(cacheKey, mw.text.jsonEncode(priceData), EXP_TIME) |
|||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
| ⚫ | |||
args[1], |
|||
args[2], |
|||
pm = pm, |
|||
dsv = args['dsv'], |
|||
hide = args['hide'], |
|||
| ⚫ | |||
p0 = priceData.p0, |
|||
p1 = priceData.p1, |
|||
p2 = priceData.p2, |
|||
p4 = priceData.p4 |
|||
} |
|||
} |
|||
end |
end |
||
function p. |
function p.render(frame) |
||
local args = frame.args |
|||
cache.delete("Module:Qp|Data|Fried Egg|35|1") |
|||
| ⚫ | |||
local result = expandTemplate(args) |
|||
return result |
|||
end |
end |
||
2026年1月12日 (一) 21:00的最新版本
local p = {}
local function expandTemplate(args)
local templateArgs = {}
for key, value in pairs(args) do
if value ~= "" then
templateArgs[key] = value
end
end
return mw.getCurrentFrame():expandTemplate{
title = '模板:Qualityprice/Base',
args = {
templateArgs[1],
templateArgs[2],
pm = templateArgs['pm'],
dsv = templateArgs['dsv'],
hide = templateArgs['hide'],
quality = templateArgs['quality'],
}
}
end
function p.render(frame)
local args = frame.args
args[1] = args[1]:gsub(".png", "")
local result = expandTemplate(args)
return result
end
return p