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:Shop Availability
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 Parse = require('Module:Parser').getTemplateArgs local Slib = require('Module:Shop') local lib = require('Module:Feature') function p.main(frame) local args = require('Module:Arguments').getArgs(frame, { parentOnly = false, wrapper = {'Template:Shop Availability'} }) local item = args[1] or mw.title.getCurrentTitle().rootText args._PAGES = {} args._BOOL = {nototal=1} if lib.isNotEmpty(args.pages) then for page in string.gmatch(args.pages, '(.-)%$%$%$') do local data = Parse(page, { only='Shop' } ) local _ret = {PAGENAME = page, rows = 0} if type(data[1]) == 'table' then for num, call in pairs(data) do local Pdata = p.ParseCall(call, item, args) if Pdata then _ret.rows = _ret.rows + #Pdata table.insert(_ret, Pdata) end end else local Pdata = p.ParseCall(data, item, args) if Pdata then _ret.rows = _ret.rows + #Pdata table.insert(_ret, Pdata) end end if #_ret>0 then table.insert(args._PAGES, _ret) end end if #args._PAGES>0 then return p._main(args, frame) else return args.noresult or ('No shop sells ' .. item .. lib.ternary(item:find('%."?$'), '', '.')) end else return args.noresult or ('No shop sells ' .. item .. lib.ternary(item:find('%."?$'), '', '.')) end end function p._main(args, frame) local _table = mw.html.create('table'):addClass('fandom-table article-table sortable') -- header row local tr = _table:tag('tr') tr:tag('th'):wikitext('Source') tr:tag('th'):wikitext('Cost') tr:tag('th'):wikitext('Stock') if lib.isNotEmpty(args._BOOL.refresh) then tr:tag('th'):wikitext('Refresh') end if lib.isNotEmpty(args._BOOL.note) then tr:tag('th'):wikitext('Notes') end -- rest of table for _, page in ipairs(args._PAGES) do local tr = _table:tag('tr') tr:tag('td'):attr('rowspan', page.rows):wikitext('[[', page.PAGENAME, ']]') for i, calls in ipairs(page) do if i>1 then tr = _table:tag('tr') end for y, call in ipairs(calls) do if #page==1 and y>1 then tr = _table:tag('tr') end tr:node(Slib.ItemRow(call, args._BOOL)) end end end -- mw.logObject(_table) --debug return frame:preprocess(tostring(_table)) end function p.ParseCall(call_data, item, args) local delim = call_data.delim or ';;' local ret = {} for _, row in ipairs(call_data) do local data = Slib.splitParams(row, delim) local specific = data.specific or lib.ternary(tonumber(data.blueprint)==1, 'Recipe: ' .. data[1], data[1]) if item == specific then data._SPECFIC = specific data[1] = nil data.currency = data.currency or call_data.currency or 'Dough' if not args._BOOL.refresh and data.refresh then args._BOOL.refresh = 1 end if not args._BOOL.note and data.note then args._BOOL.note = 1 end table.insert(ret, data) end end if #ret > 0 then return ret end 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:Shop Availability/doc
(
edit
)