Module:ASBInput

From JoJo's Bizarre Encyclopedia - JoJo Wiki
Jump to navigation Jump to search

Documentation for this module may be created at Module:ASBInput/doc

local p = {}

-- note this function isn't designed to be used in other modules w/out modification
function file(name, size)
	if name then
		return "[[File:" .. name .. "|" .. size .. "|link=]]"	
	else
		return nil
	end
end

-- retrieve input image associations
local inputFiles = mw.loadData("Module:ASBInput/Input_File_Data")

function p.main(frame)
	local final = ""
	
	for i, val in ipairs(frame:getParent().args) do
		if i ~= 1 then 
			final = final .. " + "
		end
		
		-- convert presets (could make this a Lua table instead at some point)
		if val == "ATK" then
			input = "L/M/H"
		else 
			input = val
		end
		
		-- loop through input symbols
		for i = 1, string.len(input), 1 do
			char = string.sub(input, i, i)
			final = final .. ( file(inputFiles[char], "25px") or char or "" )
		end
	end
	
	return final
end

return p