Module:Save Surala Dungeon Items table
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Save Surala Dungeon Items table/doc
--------------------------------------------------------------------------------
--
-- Module:Save Surala Dungeon Items table
--
--------------------------------------------------------------------------------
local p = {}
local mw = require('mw')
function p.main(frame)
local data = require("Module:Save Surala Item Data Cell")
local metatable = {__index = function () return "" end}
setmetatable(data, metatable)
local args = frame.args
local output = mw.html.create()
local header = mw.html.create()
local categoryArg = args["category"]
-- Header row
header
:tag('tr')
:tag('th'):attr("colspan", "3"):wikitext(frame:expandTemplate{title = "Shiren1SFCSprite", args = {frame:preprocess('{{#switch:' .. categoryArg .. ' | Riceballs=Riceball | Projectiles=Arrows | Miscellaneous=Jar Fragment | #default={{{category|}}} }}')}} .. '<br>' .. frame:expandTemplate{title = "SaveSurala", args = {(categoryArg or "")}}):done()
:tag('tr')
if string.lower(categoryArg) == "gitan" then
header
:tag('th'):cssText("width: 33%"):wikitext("Lowest amount"):done()
:tag('th'):cssText("width: 33%"):wikitext("Highest amount"):done()
else
header
:tag('th'):cssText("width: 33%"):wikitext("English"):done()
:tag('th'):cssText("width: 33%"):wikitext("Japanese"):done()
end
header
:tag('th'):cssText("width: 34%"):wikitext("Floors"):done()
-- Data rows
local rows = mw.html.create()
local i = 1
while true do
local row = mw.html.create()
local itemArg = args["item_" .. i]
local lowAmountArg = args["low_amount_" .. i]
local highAmountArg = args["high_amount_" .. i]
local floorsArg = args["floors_" .. i]
if not itemArg and not floorsArg and not lowAmountArg and not highAmountArg then
break -- exit loop when no more rows are found
end
row
:tag("tr")
if string.lower(categoryArg) == "gitan" then
row
:tag("td"):wikitext((lowAmountArg or frame:expandTemplate{title = "Research"})):done()
:tag("td"):wikitext((highAmountArg or frame:expandTemplate{title = "Research"})):done()
else
row
:tag("td"):wikitext(frame:expandTemplate{title = "SaveSurala", args = {(itemArg or "")}}):done()
:tag("td"):wikitext(data[itemArg]["ja"]):done()
end
row
:tag("td"):wikitext((floorsArg or frame:expandTemplate{title = "Research"})):done()
rows
:node(row)
:allDone()
i = i + 1
end
output
:tag('table'):addClass("wikitable"):cssText("text-align: center; width: 100%;")
:node(header)
:node(rows)
return tostring(output)
end
return p