Please join this new Discord server!

Merge notice

Module:StatsTable

From Etrian Odyssey Wiki
Revision as of 01:17, 26 January 2019 by Moydow (talk | contribs) (Added functionality for EO5 INT/WIS split)

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