Please join this new Discord server!

Merge notice

Module:SkillTable

From Etrian Odyssey Wiki

Usage

{{#invoke:SkillTable|skill_table
|skill_name=Name of the Skill in English. Required.
|skill_name_jp=Name of the Skill in Japanese. Required.
|skill_name_hepburn=Name of the romanized Japanese Skill. Optional
|skill_type=Skill type (Class Skill, Weapon Skill, Passive Skill...). Required
|skill_desc=In-game skill description. Required.
|desc_notes=Additional information about this skill. Optional.
|prereq=List of prerequisite skills separated by "; ". Optional.
|prereq_level=List of prerequisite skills level separated by "; ". Optional.
|body_parts=Head, Arm or Leg. Optional.
|skill_stats=Stat used by the skill, STR, TEC, AGI. Optional.
|max_level=Max lvl of the skill (usually 1, 5, 10 or 20). Required.
|tp_cost=TP Cost for every level separated by "; ". Optional.
|param1=Additional parameter for the skill. Can be Damage, Accuracy, Ailment rate, Speed value, HP recovery, Stat increase.... Optional.
|param2=Same as param1. Use param1 to param8 if they are several additional parameters. Optional.
|param3=
|param4=
|param5=
|param6=
|param7=
|param8=
|param9=
|param1_type=Add % if we should add % behind number in param1. For example for damage. Optional.
|param2_type=
|param3_type=
|param4_type=
|param5_type=
|param6_type=
|param7_type=
|param8_type=
|param9_type=
|param1_value=Value of param1 for each level separated by "; ". Do not add % behind this number since it is supposed to be filled in param1_type. Error "attempt to concatenate field '?' (a nil value)" if there is less item in this parameter than the max_level, it can happen if you write ";" instead of "; ". Optional.
|param2_value=
|param3_value=
|param4_value=
|param5_value=
|param6_value=
|param7_value=
|param8_value=
|param9_value=
}}

Example

Skill Name
多元抜刀
Skill Type

Description

Desc Notes


  • Body part used: Arm, Leg, Head

  • Stat(s) used: TEC, STR

Prerequisite skill(s):

  • Prereq1, lv. 5
  • Prereq2, lv. 3
Level12345678910
TP Cost15
Damage140%145%150%155%160%165%175%190%250%
Sub-Effect 140%50%70%
HP Recovery (Base Value)3456789101112

local p = {}

function p.skill_table(frame)
	-- Adds anchors for linking
	local skill_name = "<span id='" .. frame.args["skill_name"] .. "'></span>" .. frame.args["skill_name"]
	
	if frame.args["skill_name_jp"] ~= nil and frame.args["skill_name_jp"] ~= "" then
		skill_name = skill_name .. "<br>"
		if frame.args["skill_name_hepburn"] ~= nil and frame.args["skill_name_hepburn"] ~= "" then
			skill_name = skill_name .. "<span class=\"explain\" title=\"" .. frame.args["skill_name_hepburn"] .. ">" .. frame.args["skill_name_jp"] .. "</span>"
		else 
			skill_name = skill_name .. frame.args["skill_name_jp"]
		end
	end
	
	-- Frame arguments are strings, but we need this one as a number
    local max_lv = tonumber(frame.args["max_level"])

	-- Split up TP cost input
	hasTp = frame.args["tp_cost"] ~= nil and frame.args["tp_cost"] ~= ""
    if hasTp then
        tp_costs = mw.text.split(frame.args["tp_cost"], ";%s")
    end
    
    local skill_desc = frame.args["skill_desc"] .. "\n"
    
    if frame.args["skill_type"] ~= nil and frame.args["skill_type"] ~= "" then
        skill_desc =  "''" .. frame.args["skill_type"] .. "''<br><br>" .. skill_desc
    end
    
    -- Add additional notes to skill description
    if frame.args["desc_notes"] ~= nil and frame.args["desc_notes"] ~= "" then
    	skill_desc = skill_desc .. "----\n" .. frame.args["desc_notes"] .. "\n"
    end
    
    -- Add body parts/stats used to skill description
    if frame.args["body_parts"] ~= nil and frame.args["body_parts"] ~= "" then
    	skill_desc = skill_desc .. "----\n* '''Body part used:''' " .. frame.args["body_parts"] .. "\n"
    end
    
    if frame.args["skill_stats"] ~= nil and frame.args["skill_stats"] ~= "" then
    	skill_desc = skill_desc .. "----\n* '''Stat(s) used:''' " .. frame.args["skill_stats"] .. "\n"
    end
    
    -- Split up prerequisite input, and add to skill description
    if frame.args["prereq"] ~= nil and frame.args["prereq"] ~= "" then
        prereq = mw.text.split(frame.args["prereq"], ";%s")
    	prereq_lv = mw.text.split(frame.args["prereq_level"], ";%s")
    	local prereq_data = ""
	    for i = 1, #prereq do
	    	prereq_data = prereq_data .. "\n* " .. prereq[i] .. ", lv. " .. prereq_lv[i]
	    end
	    skill_desc = skill_desc .. "----\n'''Prerequisite skill(s):'''" .. prereq_data
    end
    
	-- Split up skill parameter input and convert to a table for easier usage
    params = {}
    maxParam = 0
    for i = 1, 9 do
        if frame.args["param"..i] ~= nil and frame.args["param"..i] ~= "" then
        	maxParam = i
        	if frame.args["param"..i.."_type"] ~= nil then
	            params[i] = {
	                frame.args["param"..i],
	                frame.args["param"..i.."_type"],
	            	mw.text.split(frame.args["param"..i.."_value"], ";%s")
	            }
	        else
	        	params[i] = {
	                frame.args["param"..i],
	                " ",
	            	mw.text.split(frame.args["param"..i.."_value"], ";%s")
	            }
	        end
        end
    end

	-- Start building the output table
    out_table = mw.html.create("table")
    	-- If the skill doesn't have 10 levels, make the table narrower, it looks better this way
        -- :addClass("wikitable"):css("width", math.min(math.max(100 / (10 / max_lv), 75), 100) .. "%")
        :addClass("wikitable"):css("width", "100%")
        :tag("tr")
            :tag("th"):attr("colspan", math.min(max_lv, 10) + 1):wikitext(skill_name):done()
        :done()
            :tag("td"):attr("colspan", math.min(max_lv, 10) + 1):wikitext(skill_desc):done()
        :done():tag("tr")

	-- Loop for skills with levels up to 20
	hasLevelTable = max_lv > 1 or hasTp or maxParam > 0
	
	if hasLevelTable then 
		for i20 = 1, math.max((2 * (max_lv / 20)), 1) do
			out_table:tag("th"):css("width", "20%"):wikitext("Level"):done()
			-- Add level headings
		    for i = 1 + (10 * (i20 - 1)), math.min(max_lv, 10 * i20) do
		        out_table:tag("th"):css("width", (80 / math.min(max_lv, 10)) .."%"):wikitext(i):done()
		    end
		
			-- If skill has a TP cost, add it to the table
		    if tp_costs ~= nil then
		        local tr = out_table:tag("tr")
		            :tag("th"):wikitext("TP Cost"):done()
		        -- Loop through each item and merge identical adjacent values into a single cell
		        local colspan = 0
		        local prev_value = tp_costs[1 + (10 * (i20 - 1))]
		        for i = 1 + (10 * (i20 - 1)), math.min(max_lv, 10 * i20) do
		        	if prev_value == tp_costs[i] then
		        		colspan = colspan + 1
		        	else
		        		tr:tag("td"):css("text-align", "center"):attr("colspan", colspan):wikitext(tp_costs[i-1]):done()
		        		prev_value = tp_costs[i]
		        		colspan = 1
		        	end
		        end
		        tr:tag("td"):css("text-align", "center"):attr("colspan", colspan):wikitext(tp_costs[math.min(max_lv, 10 * i20)]):done()
		        tr:done()
		    end
		
			-- For each parameter input, add to the table
		    for i = 1, #params do
		        local tr = out_table:tag("tr")
		            :tag("th"):wikitext(params[i][1]):done()
		        -- Loop through each item and merge identical adjacent values into a single cell
				local colspan = 0
		        local prev_value = params[i][3][1 + (10 * (i20 - 1))] .. params[i][2]
		        for j = 1 + (10 * (i20 - 1)), math.min(max_lv, 10 * i20) do
		        	if prev_value == params[i][3][j] .. params[i][2] then
		        		colspan = colspan + 1
		        	else
		        		tr:tag("td"):css("text-align", "center"):attr("colspan", colspan):wikitext(params[i][3][j-1] .. params[i][2]):done()
		        		prev_value = params[i][3][j] .. params[i][2]
		        		colspan = 1
		        	end
		        end
				tr:tag("td"):css("text-align", "center"):attr("colspan", colspan):wikitext(params[i][3][math.min(max_lv, 10 * i20)] .. params[i][2]):done()
		        tr:done()
		    end
		end
	end

    return out_table:done()
end

return p