« Module:Infobox Skill » : différence entre les versions
De Eco - Wiki Français
[version non vérifiée] | [version non vérifiée] |
Page créée avec « -- Credit: Original Infobox (now known as Infobox_Item) created by Pradoxzon was then edited by Nesphit and TreeNuts0. Fyre (FishAus) and Scotty (ZeelNightwolf) further edited the Infobox_Item. They then duplicated and used as a base for Infobox_Skill, Infobox_Plant, and Infobox_Animal. local p = {} -- Grabs args from the parent frame -- Trims and parses the args into a table, then returns the table function norm() local origArgs = mw.getCurrentFrame():getP... » |
Reprise du modèle depuis le site EN, pour test |
||
Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
local Utils = require('Module:Utils') | |||
local IconUtils = require('Module:IconUtils') | |||
-- Main entry point for the Module | -- Main entry point for the Module | ||
function p. | function p.main(skillname) | ||
-- get args from the Template | -- get args from the Template | ||
local args = Utils.normaliseArgs(skillname) | |||
-- check to see if skill was actually passed in | |||
if args.skill == '' then return 'skill must be specified.' end | |||
-- check to see if | |||
if | |||
local skillData = {} | local skillData = {} | ||
local skillTable = {} | local skillTable = {} | ||
skillData = require( "Module:SkillData" ) | |||
skillTable = skillData.skills[args.skill] | |||
-- string used to build the infobox | -- string used to build the infobox | ||
local infobox = '{| class=\"infobox\"\n' | local infobox = '{| class=\"infobox\"\n' | ||
-- name of the skill | -- name of the skill | ||
infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. | infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. args.skill .. '</big>\'\'\'\n' | ||
infobox = infobox .. '|- style=\"text-align: center;color: white; background-color: goldenrod;\"\n| colspan=\"2\"' | infobox = infobox .. '|- style=\"text-align: center;color: white; background-color: goldenrod;\"\n| colspan=\"2\"' | ||
if skillTable. | if skillTable.Root == 'True' then | ||
infobox = infobox .. '| \'\'\'Profession\'\'\'[[Category:Profession]]\n' | infobox = infobox .. '| \'\'\'Profession\'\'\'[[Category:Profession]]\n' | ||
elseif skillTable. | elseif skillTable.Root == 'False' then | ||
infobox = infobox .. '| \'\'\'Specialty\'\'\'[[Category:Specialty]]\n' | infobox = infobox .. '| \'\'\'Specialty\'\'\'[[Category:Specialty]]\n' | ||
else | else | ||
infobox = infobox .. '|\n' | infobox = infobox .. '|\n' | ||
end | end | ||
-- Skill | -- Skill | ||
local | local SkillIcon = IconUtils.main{ name = args.skill, id = skillTable.SkillID , size = 64, style = 1, link = args.skill} | ||
infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | <center>' .. SkillIcon .. '</center> \n' | |||
-- 'Description' section header | |||
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Description\'\'\'\n' | infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Description\'\'\'\n' | ||
if skillTable. | if skillTable.Description == nil then | ||
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n' | infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n' | ||
elseif skillTable. | elseif skillTable.Description == '' then | ||
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n' | infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n' | ||
else | else | ||
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. skillTable. | infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. skillTable.Description .. '\n' | ||
end | end | ||
--SKILL | --SKILL | ||
-- 'Skill Information' section header | -- 'Skill Information' section header | ||
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Skill Information\'\'\'\n' | infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Skill Information\'\'\'\n' | ||
-- Professsion | -- Professsion | ||
if skillTable. | if skillTable.Root == 'False' then | ||
infobox = infobox .. '|-\n| Profession:\n| style=\"text-align: right; padding: 3px;\" | ' .. skillTable. | infobox = infobox .. '|-\n| Profession:\n| style=\"text-align: right; padding: 3px;\" | [[' .. skillTable.RootSkill .. ']]\n' | ||
end | end | ||
-- maxlevel .maxLevel | -- maxlevel .maxLevel | ||
if skillTable. | if skillTable.MaxLevel ~= nil then | ||
infobox = infobox .. '|-\n| Max Level:\n| style=\"text-align: right; padding: 3px;\" | Level ' .. skillTable. | infobox = infobox .. '|-\n| Max Level:\n| style=\"text-align: right; padding: 3px;\" | Level ' .. skillTable.MaxLevel .. '\n' | ||
end | end | ||
-- skill id (type) | -- skill id (type) | ||
infobox = infobox .. '|- valign=\"center\"\n| | infobox = infobox .. '|- valign=\"center\"\n| Skill ID:\n| style=\"text-align: right; padding: 3px;\" | ' .. skillTable.SkillID.. '\n' | ||
infobox = infobox .. '|}' | infobox = infobox .. '|}' | ||
return infobox | return infobox |
Version du 16 janvier 2025 à 22:49
Documentation
This module provides the back end functionality of the Template:Infobox_Skill.
If the template is passed an Infobox will be made using details from the following Modules:
Credit
Original Infobox (now known as Infobox_Item) created by Pradoxzon was then edited by Nesphit and TreeNuts0. Fyre (FishAus) and Scotty (ZeelNightwolf) further edited the Infobox_Item. They then duplicated and used as a base for Infobox_Skill, Infobox_Plant, and Infobox_Animal.
local p = {}
local Utils = require('Module:Utils')
local IconUtils = require('Module:IconUtils')
-- Main entry point for the Module
function p.main(skillname)
-- get args from the Template
local args = Utils.normaliseArgs(skillname)
-- check to see if skill was actually passed in
if args.skill == '' then return 'skill must be specified.' end
local skillData = {}
local skillTable = {}
skillData = require( "Module:SkillData" )
skillTable = skillData.skills[args.skill]
-- string used to build the infobox
local infobox = '{| class=\"infobox\"\n'
-- name of the skill
infobox = infobox .. '|- style=\"color: white; background-color: #1165AF; text-align: center;\"\n| colspan=\"2\" | \'\'\'<big>' .. args.skill .. '</big>\'\'\'\n'
infobox = infobox .. '|- style=\"text-align: center;color: white; background-color: goldenrod;\"\n| colspan=\"2\"'
if skillTable.Root == 'True' then
infobox = infobox .. '| \'\'\'Profession\'\'\'[[Category:Profession]]\n'
elseif skillTable.Root == 'False' then
infobox = infobox .. '| \'\'\'Specialty\'\'\'[[Category:Specialty]]\n'
else
infobox = infobox .. '|\n'
end
-- Skill
local SkillIcon = IconUtils.main{ name = args.skill, id = skillTable.SkillID , size = 64, style = 1, link = args.skill}
infobox = infobox .. '|-\n| colspan=\"2\" style=\"padding: 10px;\" | <center>' .. SkillIcon .. '</center> \n'
-- 'Description' section header
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Description\'\'\'\n'
if skillTable.Description == nil then
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
elseif skillTable.Description == '' then
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | \'\'\'None\'\'\'\n'
else
infobox = infobox .. '|- style=\"text-align: center;\"\n| colspan=\"2\" | ' .. skillTable.Description .. '\n'
end
--SKILL
-- 'Skill Information' section header
infobox = infobox .. '|- style=\"background-color: #4688C0; text-align: center;\"\n| colspan=\"2\" | \'\'\'Skill Information\'\'\'\n'
-- Professsion
if skillTable.Root == 'False' then
infobox = infobox .. '|-\n| Profession:\n| style=\"text-align: right; padding: 3px;\" | [[' .. skillTable.RootSkill .. ']]\n'
end
-- maxlevel .maxLevel
if skillTable.MaxLevel ~= nil then
infobox = infobox .. '|-\n| Max Level:\n| style=\"text-align: right; padding: 3px;\" | Level ' .. skillTable.MaxLevel .. '\n'
end
-- skill id (type)
infobox = infobox .. '|- valign=\"center\"\n| Skill ID:\n| style=\"text-align: right; padding: 3px;\" | ' .. skillTable.SkillID.. '\n'
infobox = infobox .. '|}'
return infobox
end
return p