Module:Recipe: Difference between revisions
From The Petit Planet Wiki
More actions
ReisuDesign (talk | contribs) Created page with "local p = {} local Card = require('Module:Card') local category = mw.html.create() --Arguments for template local param = { sCharArg = 'character', sTypeArg = 'type', sSortArg = 'sort', sSortDelim = ';', --Needs to be pattern sSortDelim2 = '¤', sTimeArg = 'time', sYieldArg = 'yield', sPage = 'page' } p.param = param function padLeft(str, amt) return string.rep('0', amt - str:len()) .. str end function addRecipe(sAmt, sName) local cardNode = Card._m..." |
Replacing with my custom version from ZZZ, because it's better here. |
||
| Line 48: | Line 48: | ||
function p._main(args,frame) | function p._main(args,frame) | ||
local output = mw.html.create('div') | local output = mw.html.create('div') | ||
:addClass(' | :addClass('recipe_container') | ||
if type(args[param.sTypeArg]) ~= 'string' then | if type(args[param.sTypeArg]) ~= 'string' then | ||
output:tag('span'):addClass('error'):wikitext('Recipe type error. Must include recipe type.') | output:tag('span'):addClass('error'):wikitext('Recipe type error. Must include recipe type.') | ||
else | else | ||
local tArgsProcessed = {} | local tArgsProcessed = {} | ||
local header = output:tag('div'):addClass(' | local header = output:tag('div'):addClass('recipe_header') | ||
--Type Parse | --Type Parse | ||
local sType = args[param.sTypeArg] | local sType = args[param.sTypeArg] | ||
header:tag('span'):addClass(' | header:tag('span'):addClass('recipe_header_main') | ||
-- Mobile Icon | -- Mobile Icon | ||
:tag('span'):addClass('mobileHide'):wikitext(' | :tag('span'):addClass('mobileHide'):wikitext('<big>' .. sType .. '</big>'):done() | ||
-- Desktop Icon | -- Desktop Icon | ||
:tag('span'):addClass(' | :tag('span'):addClass('mobileHide'):wikitext('<big>' .. sType .. '</big>'):done() | ||
-- Text | -- Text | ||
:tag('span'):addClass(' | :tag('span'):addClass('recipe_header_text'):wikitext('[[' .. sType .. ']]'):done() | ||
category:wikitext('[[Category:' .. sType .. ']]') | category:wikitext('[[Category:' .. sType .. ']]') | ||
| Line 121: | Line 121: | ||
sTime = sTime .. each .. ' ' | sTime = sTime .. each .. ' ' | ||
end | end | ||
header:tag('span'):addClass(' | header:tag('span'):addClass('recipe_header_sub') | ||
:tag('span'):addClass('mobileHide'):wikitext(' for '):done() | :tag('span'):addClass('mobileHide'):wikitext(' for '):done() | ||
:tag('span'):addClass('hidden'):wikitext(' | :tag('span'):addClass('hidden'):wikitext(' for '):done() | ||
:tag('span'):addClass(' | :tag('span'):addClass('recipe_header_text'):wikitext(sTime):done() | ||
end | end | ||
--Character Parse | --Character Parse | ||
if type(args[param.sCharArg]) == 'string' then | if type(args[param.sCharArg]) == 'string' then | ||
local sCharName = args[param.sCharArg] | local sCharName = args[param.sCharArg] | ||
header:tag('span'):addClass(' | header:tag('span'):addClass('recipe_header_sub') | ||
:tag('span'):addClass('mobileHide'):wikitext(' with '):done() | :tag('span'):addClass('mobileHide'):wikitext(' with '):done() | ||
:tag('span'):addClass('hidden'):wikitext('[[File:' .. sCharName .. ' Icon.png|24x24px|link=' .. sCharName .. ']]'):done() | :tag('span'):addClass('hidden'):wikitext('[[File:' .. sCharName .. ' Icon.png|24x24px|link=' .. sCharName .. ']]'):done() | ||
:tag('span'):addClass(' | :tag('span'):addClass('recipe_header_text'):wikitext('[[' .. sCharName .. ']]'):done() | ||
end | end | ||
local body = output:tag('div'):addClass(' | local body = output:tag('div'):addClass('recipe_body') | ||
--Check if sSortDelim2 exists in sSortArg | --Check if sSortDelim2 exists in sSortArg | ||
| Line 175: | Line 175: | ||
} | } | ||
body | body | ||
:tag('div'):addClass(' | :tag('div'):addClass('recipe_body_icon') | ||
:wikitext(' | :wikitext('➜'):done() | ||
:tag('div'):addClass(' | :tag('div'):addClass('recipe_body_yield') | ||
:node(yieldCard) | :node(yieldCard) | ||