Module:GameDesc

Revision as of 22:10, 15 October 2024 by Billy Mitchell (talk | contribs) (Created page with "local getArgs = require('Module:Arguments').getArgs local p = {} local function capitalizeFirstLetter(input) return input:sub(1,1):upper() .. input:sub(2) end function p.main(frame) local args = getArgs(frame) local category = args[1]:lower() --I.e. is it skill or item? local game = args[2]:lower() local thing = args[3]:lower() local data = require("Module:Data/" .. capitalizeFirstLetter(category) .. "/" .. game) local dataTable = data[category] local gameLink =...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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

local getArgs = require('Module:Arguments').getArgs
local p = {}
local function capitalizeFirstLetter(input)
	return input:sub(1,1):upper() .. input:sub(2)
end
function p.main(frame)
	local args = getArgs(frame)
	local category = args[1]:lower() --I.e. is it skill or item?
	local game = args[2]:lower()
	local thing = args[3]:lower()
	local data = require("Module:Data/" .. capitalizeFirstLetter(category) .. "/" .. game)
	local dataTable = data[category]
	local gameLink = frame:expandTemplate{ title = "Link", args = { "Game", game } }
	local desc = ""
	if dataTable[thing]["description_ja"] and dataTable[thing]["description"] then
		desc = frame:expandTemplate{ title = "DescTransl", args = { dataTable[thing]["description_ja"], dataTable[thing]["description"] } }
	elseif dataTable[thing]["description"] then
		desc = dataTable[thing]["description"]
	else
		error("Description of \"" .. thing .. "\" for " .. game .. " not found")
	end
	return "\n| style=\"text-align:center\" | " .. gameLink .. "\n| " .. desc .. "\n|-"
end

return p