Module:Skill link and Module:Skill link/sandbox: Difference between pages
(Difference between pages)
(No globals. Use invoker factory from Module:Util.) |
No edit summary |
||
Line 3: | Line 3: | ||
-- Module:Skill link | -- Module:Skill link | ||
-- | -- | ||
-- This module implements | -- This module implements Template:Skill link | ||
------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ||
require('Module: | local getArgs = require('Module:Arguments').getArgs | ||
local m_util = require('Module:Util') | local m_util = require('Module:Util') | ||
local m_cargo = require('Module:Cargo') | |||
-- Should we use the sandbox version of our submodules? | -- Should we use the sandbox version of our submodules? | ||
local use_sandbox = m_util.misc.maybe_sandbox('Skill link') | local use_sandbox = m_util.misc.maybe_sandbox('Skill link') | ||
-- The cfg table contains all localisable strings and configuration, to make it | -- The cfg table contains all localisable strings and configuration, to make it | ||
Line 49: | Line 47: | ||
function h.format_skill_icon(skill, tpl_args) | function h.format_skill_icon(skill, tpl_args) | ||
--[[ | --[[ | ||
Add a skill image. | |||
]] | ]] | ||
if tpl_args.icon ~= nil then | if tpl_args.icon ~= nil then | ||
skill['skill.skill_icon'] = tpl_args.icon | skill['skill.skill_icon'] = tpl_args.icon | ||
Line 78: | Line 78: | ||
-- ---------------------------------------------------------------------------- | -- ---------------------------------------------------------------------------- | ||
-- | -- Exported functions | ||
-- ---------------------------------------------------------------------------- | -- ---------------------------------------------------------------------------- | ||
local function | local p = {} | ||
function p.skill_infobox_link(frame) | |||
--[[ | --[[ | ||
Finds and shows the infobox of a skill. | Finds and shows the infobox of a skill. | ||
Line 89: | Line 91: | ||
= p.skill_infobox_link{"Icestorm"} | = p.skill_infobox_link{"Icestorm"} | ||
= p.skill_infobox_link{q_where = 'skill.active_skill_name="Icestorm"'} | = p.skill_infobox_link{q_where = 'skill.active_skill_name="Icestorm"'} | ||
]] | ]] | ||
-- Get args | |||
tpl_args = getArgs(frame, { | |||
parentFirst = true | |||
}) | |||
frame = m_util.misc.get_frame(frame) | |||
if tpl_args.id and (tpl_args.q_where == nil) then | if tpl_args.id and (tpl_args.q_where == nil) then | ||
Line 160: | Line 169: | ||
}, | }, | ||
} | } | ||
out = {} | |||
local cats = {} | local cats = {} | ||
for _,v in ipairs(err_tbl) do | for _,v in ipairs(err_tbl) do | ||
Line 184: | Line 193: | ||
end | end | ||
-- Store as main page | -- Store as main page: | ||
m_cargo.store( | |||
{ | |||
_table='main_pages', | |||
id=v['skill.skill_id'], | |||
} | |||
) | |||
end | end | ||
Line 202: | Line 205: | ||
end | end | ||
-- | |||
-- Template:Skill link | |||
-- | |||
function p.skill_link(frame) | |||
--[[ | --[[ | ||
Links a skill | Links a skill | ||
Line 217: | Line 223: | ||
} | } | ||
]] | ]] | ||
-- Get args | |||
local tpl_args = getArgs(frame, { | |||
parentFirst = true | |||
}) | |||
frame = m_util.misc.get_frame(frame) | |||
tpl_args.skill_name = tpl_args.skill_name or tpl_args[1] | tpl_args.skill_name = tpl_args.skill_name or tpl_args[1] | ||
Line 372: | Line 384: | ||
:node(activator) | :node(activator) | ||
:node(display) | :node(display) | ||
:done() | |||
return tostring(container) | return tostring(container) | ||
Line 383: | Line 396: | ||
end | end | ||
end | end | ||
return p | return p |