Нет описания правки |
Нет описания правки |
||
| Строка 17: | Строка 17: | ||
end | end | ||
end | end | ||
local function compareByCost(a, b) | local function compareByCost(a, b) | ||
| Строка 29: | Строка 25: | ||
for _, k in ipairs(keys) do | for _, k in ipairs(keys) do | ||
out = out .. frame:expandTemplate{ title = "Uplink", args = { prototype = k}} | |||
out = out .. frame:expandTemplate{ title = "Uplink", args = { prototype = k | |||
end | end | ||
Версия от 10:55, 20 января 2024
Для документации этого модуля может быть создана страница Модуль:Uplink Lookup/doc
local prototypes = mw.loadData("Module:Uplink Lookup/data")
local p = {}
p.store = prototypes.store
function p.readscalar(frame)
return mw.text.nowiki(p.store[frame.args[1]][frame.args[2]])
end
function p.buildlists(frame)
local out = ""
local group = frame.args[1]
local keys = {}
for k in pairs(p.store) do
if p.store[k].group == group or group == nil then
table.insert(keys, k)
end
end
local function compareByCost(a, b)
return tonumber(p.store[a].cost) < tonumber(p.store[b].cost)
end
table.sort(keys, compareByCost)
for _, k in ipairs(keys) do
out = out .. frame:expandTemplate{ title = "Uplink", args = { prototype = k}}
end
return out
end
return p