Module:Necropolis packs: Difference between revisions

From Path of Exile Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 6: Line 6:
local m_lookup = use_sandbox and mw.loadData('Module:Necropolis_pack_lookup/data/sandbox') or mw.loadData('Module:Necropolis_pack_lookup/data')
local m_lookup = use_sandbox and mw.loadData('Module:Necropolis_pack_lookup/data/sandbox') or mw.loadData('Module:Necropolis_pack_lookup/data')


local function _expand_template(data)
local function _expand_template(data, sections)
return mw.getCurrentFrame():expandTemplate{
return mw.getCurrentFrame():expandTemplate{
title = use_sandbox and 'Template:Necropolis packs/display/sandbox' or 'Template:Necropolis packs/display',
title = use_sandbox and 'Template:Necropolis packs/display/sandbox' or 'Template:Necropolis packs/display',
args = {
args = {
name = data.name,
name = sections and "==" .. data.name .. "==",
description = data.description,
description = data.description,
leader = data.leader
leader = data.leader
Line 18: Line 18:


local function _render_pack(tpl_args)
local function _render_pack(tpl_args)
tpl_args = tpl_args or {}
if tpl_args.name then
if tpl_args.name then
local data = m_data[m_lookup[tpl_args.name].pack_id]
local data = m_data[m_lookup[tpl_args.name].pack_id]
Line 24: Line 25:
local all = ""
local all = ""
for _, data in pairs(m_data) do
for _, data in pairs(m_data) do
all = all .. _expand_template(data)
all = all .. _expand_template(data, true)
end
end
return mw.getCurrentFrame():preprocess(all)
return mw.getCurrentFrame():preprocess(all)

Revision as of 07:40, 7 April 2024

Module documentation[view] [edit] [history] [purge]


Renders pack data for Template:Necropolis pack.

Usage

{{#invoke:Necropolis packs|function_name}}

require('Module:No globals')
local m_util = require('Module:Util')

local use_sandbox = m_util.misc.maybe_sandbox('Necropolis_packs')
local m_data = use_sandbox and mw.loadData('Module:Necropolis_packs/data/sandbox') or mw.loadData('Module:Necropolis_packs/data')
local m_lookup = use_sandbox and mw.loadData('Module:Necropolis_pack_lookup/data/sandbox') or mw.loadData('Module:Necropolis_pack_lookup/data')

local function _expand_template(data, sections)
	return mw.getCurrentFrame():expandTemplate{
		title = use_sandbox and 'Template:Necropolis packs/display/sandbox' or 'Template:Necropolis packs/display',
		args = {
			name = sections and "==" .. data.name .. "==",
			description = data.description,
			leader = data.leader
		}
	}
end

local function _render_pack(tpl_args)
	tpl_args = tpl_args or {}
	if tpl_args.name then
		local data = m_data[m_lookup[tpl_args.name].pack_id]
		return mw.getCurrentFrame():preprocess(_expand_template(data))
	else
		local all = ""
		for _, data in pairs(m_data) do
			all = all .. _expand_template(data, true)
		end
		return mw.getCurrentFrame():preprocess(all)
	end
end

local p = {}

p.render_pack = _render_pack

return p