Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Neighbors
Esassani
Mobai
Glenn
Mors
Creatures
Fish
Insects
Shore-Dwellers
Search
Search
English
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Recipe
Module
Discussion
English
Read
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
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._main({ name = sName, text = sAmt, show_caption = '1', mobile = 'bulleted' }) category:wikitext('[[Category:Uses ', sName, '|', padLeft(sAmt:gsub('%D', ''), 10), ']]') return cardNode end function pluralize(sOut,plural) if plural then sOut = sOut .. 's' end return sOut end function p.main(frame) local args = require('Module:Arguments').getArgs(frame, { parentFirst = true, wrapper = { 'Template:Recipe' } }) return p._main(args,frame) end function p._main(args,frame) local output = mw.html.create('div') :addClass('recipe_container') if type(args[param.sTypeArg]) ~= 'string' then output:tag('span'):addClass('error'):wikitext('Recipe type error. Must include recipe type.') else local tArgsProcessed = {} local header = output:tag('div'):addClass('recipe_header') --Type Parse local sType = args[param.sTypeArg] header:tag('span'):addClass('recipe_header_main') -- Mobile Icon :tag('span'):addClass('mobileHide'):wikitext('<big>' .. sType .. '</big>'):done() -- Desktop Icon :tag('span'):addClass('mobileHide'):wikitext('<big>' .. sType .. '</big>'):done() -- Text :tag('span'):addClass('recipe_header_text'):wikitext('[[' .. sType .. ']]'):done() category:wikitext('[[Category:' .. sType .. ']]') --Time Parse if type(args[param.sTimeArg]) == 'string' then local tTime = {} local key = false local plural = false for n1, d, n2, h, n3, m, n4, s in mw.ustring.gmatch(args[param.sTimeArg], '(%d+)(d?)(%d*)(h?)(%d*)(m?)(%d*)(s?)') do table.insert(tTime,n1) --insert first value definitely if n1 ~= '1' then plural = true --generate plural end if d == 'd' then table.insert(tTime, pluralize('day', plural)) plural = false --consume plural key = true end if n2 ~= '' then table.insert(tTime, n2) if n2 ~= '1' then plural = true --generate plural end end if h == 'h' then table.insert(tTime,pluralize('hour', plural)) plural = false --consume plural key = true end if n3 ~= '' then table.insert(tTime, n3) if n3 ~= '1' then plural = true --generate plural end end if m == 'm' then table.insert(tTime, pluralize('minute', plural)) plural = false --consume plural key = true end if n4 ~= '' then table.insert(tTime, n4) if n4 ~= '1' then plural = true --generate plural end end if s == 's' then table.insert(tTime, pluralize('second', plural)) key = true end end if not(key) then table.insert(tTime,pluralize('minute', plural)) end local sTime = '' for _, each in ipairs(tTime) do sTime = sTime .. each .. ' ' end header:tag('span'):addClass('recipe_header_sub') :tag('span'):addClass('mobileHide'):wikitext(' for '):done() :tag('span'):addClass('hidden'):wikitext(' for '):done() :tag('span'):addClass('recipe_header_text'):wikitext(sTime):done() end --Character Parse if type(args[param.sCharArg]) == 'string' then local sCharName = args[param.sCharArg] header:tag('span'):addClass('recipe_header_sub') :tag('span'):addClass('mobileHide'):wikitext(' with '):done() :tag('span'):addClass('hidden'):wikitext('[[File:' .. sCharName .. ' Icon.png|24x24px|link=' .. sCharName .. ']]'):done() :tag('span'):addClass('recipe_header_text'):wikitext('[[' .. sCharName .. ']]'):done() end local body = output:tag('div'):addClass('recipe_body') --Check if sSortDelim2 exists in sSortArg if ((args[param.sSortArg] or ''):find(param.sSortDelim2) ~= nil) then param.sSortDelim = param.sSortDelim2 end --Process Sort Parameter (Split by Delimiter) for sKey in string.gmatch(args[param.sSortArg] or '', '([^' .. param.sSortDelim .. ']+)') do if type(args[sKey]) ~= 'nil' then body:node(addRecipe(args[sKey], sKey)) tArgsProcessed[sKey] = true end end --Process Rest of Unrestricted Parameters for sKey,sVal in pairs(args) do --Check if restricted parameter local restricted = false for _, keyParam in pairs(param) do if keyParam == sKey then restricted = true end end --If not processed, and not a restricted parameter if tArgsProcessed[sKey] ~= true and not(restricted) then body:node(addRecipe(sVal, sKey)) end end --Yield Parse if args[param.sYieldArg] ~= '0' then local sYield = args[param.sYieldArg] or '1' local pageTitle = args.page or mw.title.getCurrentTitle().text local yieldCard = Card._main{ name = pageTitle, text = sYield, show_caption = '1', } body :tag('div'):addClass('recipe_body_icon') :wikitext('➜'):done() :tag('div'):addClass('recipe_body_yield') :node(yieldCard) local itemText = require('Module:Item').main{ [1] = pageTitle, [2] = '15', x = sYield } end body:done() end output:node(require('Module:Namespace detect').main{["main"]=category}) return output end return p
Summary:
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Petit Planet:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Below are commonly used wikitext from
MediaWiki:Edittools
. Click on any to insert them in the edit box.
File Pages
==Summary==
==Licensing==
{{Fairuse}}
{{File|}}
Dynamic Page List
¦
²
«
»
²{¦}²
«»
«/»
«!----»
Array in DPL
¹
^2{
}^2
^2{¹}^2
Parser Functions
{{#if:||}}
{{#if:<condition>|<result if true>|<result if false>}}
{{#ifeq:|||}}
{{#ifeq:<text1>|<text2>|<result if text1=text2>|<result if text1≠text2>}}
{{#expr:}}
{{#expr:<mathematical expression>}}
{{#switch:||#default=}}
{{#switch:<text1>|<text2>=<result if text1=text2>|<text3>=<result if text1=text3>|#default=<result if no valid match>}}
{{#replace:||}}
{{#replace:<text1>|<plain text to find in text1>|<plain text to insert in place of the text found>}}
{{#titleparts:}}
{{#replace:<page name>}}
{{#tag:|}}
{{#tag:<name of html tag>|<content inside html tag>}}
Markup
{{}}
|
[]
[[]]
[[Category:]]
#REDIRECT [[]] [[Category:Redirect Pages]]
<code></code>
<includeonly></includeonly>
<noinclude></noinclude>
<nowiki></nowiki>
<!---->
<br>
§
Notices
{{Stub|}}
{{Stub Dialogue}}
{{Upcoming}}
{{Under Construction}}
{{Placeholder|}}
Magic Words
{{!}}
{{formatnum:}}
{{lc:}}
{{uc:}}
{{PAGENAME}}
{{FULLPAGENAME}}
{{ROOTPAGENAME}}
{{BASEPAGENAME}}
{{SUBPAGENAME}}
{{DISPLAYTITLE:|noreplace}}
__TOC__
__NOTOC__
__EXPECTUNUSEDCATEGORY__
__HIDDENCAT__
HTML Entities
—
,
­
Template used on this page:
Module:Recipe/doc
(
edit
)