From Arms of God Wiki
Renders Codex records from Data:Codex.json on index and detail pages.
infobox— infobox for one record (used via Template:Codex infobox)index— sortable index table on Codexbody/crossRefs— per-section renderers invoked from detail pages
Bot-published: the module and its Data: page are regenerated on re-publish. Restyle via the per-section templates rather than editing page wikitext.
-- Module:Codex — the Codex category module, plus the shared lore lookup.
--
-- WHAT IT DOES
-- Standard category rendering (infobox / body / index / render) for
-- Codex pages, bound to Module:Core like every other category module.
-- The extra `lore` entry point powers the '== Lore ==' section on
-- weapon / enemy / character / codex pages: it finds the matching
-- Codex entry by (normalized) name at render time, so editing the
-- lore once in Data:Codex.json updates every page showing it.
--
-- HOW TO INVOKE
-- {{#invoke:Codex|infobox|id=Azrael}} / |body| / |index| / |render|
-- {{#invoke:Codex|lore|Azrael}} cross-category name match
-- {{#invoke:Codex|lore|Cutter|Weapons}} category-scoped; falls back
-- to the entity's own `description` when no codex entry matches.
--
-- SOURCE DATA IT READS (via Module:Core)
-- Data:Codex.json; `lore` also reads the named entity's category page
-- (e.g. Data:Weapons.json) to resolve names and fallbacks.
local Core = require('Module:Core')
local p = {}
local CAT = 'Codex'
function p.infobox(frame) return Core.infoboxEntry(CAT, frame) end
function p.body(frame) return Core.bodyEntry(CAT, frame) end
function p.crossRefs(frame)
return require('Module:CrossRef').entry(CAT, frame)
end
function p.index(frame) return Core.indexEntry(CAT, frame) end
function p.render(frame) return Core.renderEntry(CAT, frame) end
-- Codex entry type expected for an entity category (nil = any type).
local TYPE_FOR_CAT = {Weapons = 'Weapons', Enemies = 'Enemies'}
function p.lore(frame)
local key = (frame.args[1] or ''):gsub('^%s+', ''):gsub('%s+$', '')
if key == '' then return '' end
local catHint = Core.resolveCategory(frame.args[2] or '')
local entity = nil
if catHint then
entity = Core.byId(catHint)[key]
end
if not entity then
local foundCat, rec = Core.find(key)
if rec then
entity = rec
catHint = catHint or foundCat
end
end
local name = (entity and entity.name) or key
if catHint == 'Codex' then
-- standalone codex page: its own prose
return (entity and entity.description) or ''
end
local cx = Core.codexFor(name, TYPE_FOR_CAT[catHint])
if cx and cx.description and cx.description ~= '' then
return cx.description
end
-- no codex entry: the entity's own description (heroes, unmatched enemies)
return (entity and entity.description) or ''
end
return p