Home
Random
Log in
Settings
About the Petit Planet Wiki
Search
Editing
Module
:
Neighbor Journey
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 Arguments = require('Module:Arguments') -- Converts a group title into its parameter key. -- Example: -- "Neighbor Events" -> "neighbor_events" -- "Starsea Voyages" -> "starsea_voyages" local function getKey(group) group = mw.ustring.lower(mw.text.trim(group)) group = mw.ustring.gsub(group, "%s+", "_") return group end -- Splits a reward string into: -- quantity // title // dough local function parseReward(value) local parts = mw.text.split(value, "//", true) return { quantity = mw.text.trim(parts[1] or ""), title = mw.text.trim(parts[2] or ""), dough = mw.text.trim(parts[3] or "") } end -- Gets all numbered rewards for a group. -- Stops at the first missing number. local function getRewards(args, key) local rewards = {} local i = 1 while args[key .. "_" .. i] do local value = mw.text.trim(args[key .. "_" .. i]) if value ~= "" then table.insert(rewards, parseReward(value)) end i = i + 1 end return rewards end function p.main(frame) local args = Arguments.getArgs(frame, { wrapper = "Template:Neighbor Journey" }) return p._main(args, frame) end function p._main(args, frame) local neighbor = args.neighbor or "" local groupsString = args.groups or "" if neighbor == "" then return "" end -- Split groups on semicolons. local groups = mw.text.split(groupsString, ";", true) -- Remove empty groups. local validGroups = {} for _, group in ipairs(groups) do group = mw.text.trim(group) if group ~= "" then table.insert(validGroups, group) end end -- Start table. local output = { "{| class=\"wikitable wikitable--stripe\"", "! width=155px | Node !! Quantity !! Title !! {{Item|Dough|notext=1}}" } ---------------------------------------------------------------- -- Meet ---------------------------------------------------------------- table.insert(output, "|-") table.insert(output, "! rowspan=\"1\" | {{Icon/Journey|Meet}} Meet<br>" .. "<small>''Meet " .. neighbor .. " for the very first time''</small>" ) table.insert(output, "| 1 || '''A Chance Encounter''' || 30" ) ---------------------------------------------------------------- -- Groups ---------------------------------------------------------------- local hasGroup = false for _, group in ipairs(validGroups) do local key = getKey(group) local description = args[key .. "_desc"] or "" local rewards = getRewards(args, key) -- Don't output groups that have no rewards. if #rewards > 0 then -- Add a separator after Meet / between groups. table.insert(output, "|-") table.insert(output, '! colspan="4" style="height:10px; min-height:5px; padding:0; border:0;" |' ) hasGroup = true -- Replace {name} with the neighbor's name. description = mw.text.trim(description) description = mw.ustring.gsub(description, "{name}", neighbor) -- First row of the group. table.insert(output, "|-") local nodeCell = "! rowspan=\"" .. #rewards .. "\" | " .. "{{Icon/Journey|" .. group .. "}} " .. group if description ~= "" then nodeCell = nodeCell .. "<br><small>''" .. description .. "''</small>" end table.insert(output, nodeCell) -- First reward. local first = rewards[1] table.insert(output, "| " .. first.quantity .. " || '''" .. first.title .. "''' || " .. first.dough ) -- Remaining rewards. for i = 2, #rewards do local reward = rewards[i] table.insert(output, "|-") table.insert(output, "| " .. reward.quantity .. " || '''" .. reward.title .. "''' || " .. reward.dough ) end end end -- End table. table.insert(output, "|}") -- Process generated wikitext so that templates -- such as {{Icon/Journey}} and {{Item}} are evaluated. local result = table.concat(output, "\n") return frame:preprocess(result) end return p
Summary:
Please note that all contributions to The Petit Planet Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
Petit Planet Wiki: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
—
,
­
Pages included on this page:
Template:Documentation/Header
(
edit
)
Template:Documentation/styles.css
(
edit
)
Template:T
(
edit
)
Template:TOC Right
(
edit
)
Module:Arguments
(
edit
)
Module:Arguments/i18n
(
edit
)
Module:Common/i18n
(
edit
)
Module:Config
(
edit
)
Module:Documentation
(
edit
)
Module:Documentation/config
(
edit
)
Module:Documentation/i18n
(
edit
)
Module:Entrypoint
(
edit
)
Module:Exists
(
edit
)
Module:Fallbacklist
(
edit
)
Module:Feature
(
edit
)
Module:Formatting
(
edit
)
Module:I18n
(
edit
)
Module:Languages
(
edit
)
Module:Neighbor Journey/doc
(
edit
)
Module:TableTools
(
edit
)
Module:Yesno
(
edit
)
This page is a member of 2 hidden categories:
Category:Pages using DynamicPageList4 parser function
Category:Pages using DynamicPageList4