Module:IconData
From ARC Raiders Wiki
More actions
Looks up an icon and label by key from a dataset subpage and renders it through Module:Icon. Used by templates to produce consistent icon and text output from a shared data source.
Usage
{{#invoke:IconData|main|dataset=ARC|key=wasp|size=22}}
{{#invoke:IconData|main|dataset=Condition|key=bcity|text=Birdy City|size=22}}
Parameters
- dataset - name of the dataset subpage under Module:IconData/. Hardcoded by the calling template.
- key - case-insensitive lookup key within the dataset.
- text - optional display text; falls back to the entry's label if omitted or empty.
- size - icon size in pixels. Supplied by the calling template as a default.
Dataset structure
Dataset subpages return a table keyed by lowercase lookup strings:
return {
tick = { icon = "Icon_ARC_Tick.png",
label = "Tick" },
pop = { icon = "Icon_ARC_Pop.png",
label = "Pop" },
}
Each entry must have an icon; label is optional.
local Icon = require("Module:Icon")
local IconData = {}
--- Look up an entry by key in the given dataset.
---
--- @param dataset string Name of the dataset subpage (e.g., "Condition")
--- @param key string Lowercase lookup key
--- @return table|nil Entry with `icon` (required) and `label` (optional)
function IconData.findEntry(dataset, key)
local data = mw.loadData("Module:IconData/" .. dataset)
return data[key]
end
--- Entry point: {{#invoke:IconData|main|...}}
function IconData.main(frame)
local args = frame.args
local dataset = mw.text.trim(args.dataset or "")
if dataset == "" then
return Icon.renderError("No dataset specified")
end
local key = string.lower(mw.text.trim(args.key or ""))
if key == "" then
return Icon.renderError("No key specified for: " .. dataset)
end
local entry = IconData.findEntry(dataset, key)
if not entry then
return Icon.renderError('No "' .. key .. '" found in: ' .. dataset)
end
local text = mw.text.trim(args.text or "")
if text == "" then text = entry.label or "" end
return Icon.buildIcon(entry.icon, text, "", args.size)
end
return IconData