Module:Skill link

From Path of Exile Wiki
Revision as of 21:01, 1 April 2018 by >OmegaK2 (Created page with "-- -- Module for skill linking -- local m_util = require('Module:Util') local getArgs = require('Module:Arguments').getArgs local p = {} -- --------------------------------...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Module documentation[view] [edit] [history] [purge]


Lua logo

This module depends on the following other modules:

Overview

Module for creating links to skills via cargo.

Skill templates

Module:Item2

All templates defined in Module:Skill:

Module:Skill link

All templates defined in Module:Skill link:

--
-- Module for skill linking
--

local m_util = require('Module:Util')
local getArgs = require('Module:Arguments').getArgs

local p = {}

-- ----------------------------------------------------------------------------
-- Strings
-- ----------------------------------------------------------------------------

local i18n = {
}

-- ----------------------------------------------------------------------------
-- Helper functions and globals
-- ----------------------------------------------------------------------------

-- ----------------------------------------------------------------------------
-- Page functions
-- ----------------------------------------------------------------------------

local p = {}

function p.skill_infobox_link(frame)
    -- Get args
    tpl_args = getArgs(frame, {
        parentFirst = true
    })
    frame = m_util.misc.get_frame(frame)
    
    if tpl_args.id == nil then
        error('Id parameter must be specified.')
    end
    
    local results = m_util.cargo.query(
        {'skill'},
        {'skill.html'},
        {
            where=string.format('skill.skill_id = "%s"', tpl_args.id),
            limit=1,
        }
    )
    results = results[1]
    
    local container = mw.html.create('span')
    container:attr('class', 'skill-box-page-container')
    container:wikitext(results['skill.html'])
    
    return tostring(container)
end

-- ----------------------------------------------------------------------------
-- End
-- ----------------------------------------------------------------------------

return p