Please join this new Discord server!
Difference between revisions of "Module:StatsTable"
From Etrian Odyssey Wiki
m |
(Added functionality for EO5 INT/WIS split) |
||
Line 4: | Line 4: | ||
-- Name input for convenience | -- Name input for convenience | ||
local in_args = frame:getParent().args | local in_args = frame:getParent().args | ||
local int_wis = frame.args.int_wis | |||
-- Set up variables for building the table | |||
local tbl_width = "60%" | |||
local col_width = "13%" | |||
local stats = {"HP", "TP", "STR", "TEC", "VIT", "AGI", "LUC"} | |||
-- If the game has the INT/WIS split (EO5 on), adjust for that | |||
if int_wis ~= nil then | |||
tbl_width = "70%" | |||
col_width = "11.375%" | |||
stats = {"HP", "TP", "STR", "INT", "VIT", "WIS", "AGI", "LUC"} | |||
end | |||
-- Start building the output table | -- Start building the output table | ||
out_table = mw.html.create("table") | out_table = mw.html.create("table") | ||
:addClass("wikitable"):css("width", | :addClass("wikitable"):css("width", tbl_width) | ||
:tag("tr") | :tag("tr") | ||
:tag("th"):css("width", "9%"):wikitext("Lv."):done() | :tag("th"):css("width", "9%"):wikitext("Lv."):done() | ||
for i = 1, #stats do | |||
out_table:tag("th"):css("width", col_width):wikitext(stats[i]):done() | |||
end | |||
out_table:done() | |||
-- Loop for each level to add the stats to the table | -- Loop for each level to add the stats to the table | ||
for i = 1, 99 do | for i = 1, 99 do | ||
out_table:tag("tr") | local tr = out_table:tag("tr") | ||
:tag("th"):wikitext(i):done() | :tag("th"):wikitext(i):done() | ||
for s = 1, #stats do | |||
:tag("td"):wikitext(in_args[ | tr:tag("td"):wikitext(in_args[s + (#stats * (i - 1))]):done() | ||
end | |||
tr:done() | |||
:done() | |||
-- Show the headings again after every 10 levels, makes it easier to read | -- Show the headings again after every 10 levels, makes it easier to read | ||
if i % 10 == 0 then | if i % 10 == 0 then | ||
out_table:tag("tr") | tr = out_table:tag("tr") | ||
:tag("th"):css("width", "9%"):wikitext("Lv."):done() | :tag("th"):css("width", "9%"):wikitext("Lv."):done() | ||
for i = 1, #stats do | |||
tr:tag("th"):css("width", col_width):wikitext(stats[i]):done() | |||
end | |||
tr:done() | |||
:done() | |||
end | end | ||
end | end |
Revision as of 01:17, 26 January 2019
Documentation for this module may be created at Module:StatsTable/doc
local p = {}
function p.stats_table(frame)
-- Name input for convenience
local in_args = frame:getParent().args
local int_wis = frame.args.int_wis
-- Set up variables for building the table
local tbl_width = "60%"
local col_width = "13%"
local stats = {"HP", "TP", "STR", "TEC", "VIT", "AGI", "LUC"}
-- If the game has the INT/WIS split (EO5 on), adjust for that
if int_wis ~= nil then
tbl_width = "70%"
col_width = "11.375%"
stats = {"HP", "TP", "STR", "INT", "VIT", "WIS", "AGI", "LUC"}
end
-- Start building the output table
out_table = mw.html.create("table")
:addClass("wikitable"):css("width", tbl_width)
:tag("tr")
:tag("th"):css("width", "9%"):wikitext("Lv."):done()
for i = 1, #stats do
out_table:tag("th"):css("width", col_width):wikitext(stats[i]):done()
end
out_table:done()
-- Loop for each level to add the stats to the table
for i = 1, 99 do
local tr = out_table:tag("tr")
:tag("th"):wikitext(i):done()
for s = 1, #stats do
tr:tag("td"):wikitext(in_args[s + (#stats * (i - 1))]):done()
end
tr:done()
-- Show the headings again after every 10 levels, makes it easier to read
if i % 10 == 0 then
tr = out_table:tag("tr")
:tag("th"):css("width", "9%"):wikitext("Lv."):done()
for i = 1, #stats do
tr:tag("th"):css("width", col_width):wikitext(stats[i]):done()
end
tr:done()
end
end
return out_table:done()
end
return p