Module:GameDesc: Difference between revisions

Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(8 intermediate revisions by the same user not shown)
Line 6: Line 6:
function p.main(frame)
function p.main(frame)
local args = getArgs(frame)
local args = getArgs(frame)
local category = args[1]:lower() --I.e. is it skill or item?
if not args[3] then
local game = args[2]:lower()
local game = ""
local thing = args[3]:lower()
if args[1] then
local dataTable = require("Module:Data/" .. capitalizeFirstLetter(category) .. "/" .. game)[category]
game = args[1]
local gameLink = frame:expandTemplate{ title = "Link", args = { "Game", game } }
end
local desc = ""
local desc = ""
if dataTable[thing]["description_ja"] and dataTable[thing]["description"] then
if args[2] then
desc = frame:expandTemplate{ title = "DescTransl", args = { dataTable[thing]["description_ja"], dataTable[thing]["description"] } }
desc = args[2]
elseif dataTable[thing]["description"] then
end
desc = dataTable[thing]["description"]
return "\n| style=\"text-align:center\" | " .. game .. "\n| " .. desc .. "[[Category:Pages using old GameDesc format]]\n|-"
else
else
error("Description of \"" .. thing .. "\" for " .. game .. " not found")
local category = args[1]:lower() --I.e. is it skill or item?
local game = args[2]:lower()
local thing = args[3]:lower()
local dataTable = require("Module:Data/" .. capitalizeFirstLetter(category) .. "/" .. game)[category]
local gameLink = frame:expandTemplate{ title = "Link", args = { "Game", game } }
if not dataTable[thing] then
error(capitalizeFirstLetter(category) .. " \"" .. thing .. "\" not defined for " .. game)
end
if dataTable[thing]["effect_note"] then
gameLink = gameLink .. frame:expandTemplate { title = 'exp', args = { dataTable[thing]["effect_note"] } }
elseif dataTable[thing]["name_note"] then
gameLink = gameLink .. frame:expandTemplate { title = 'exp', args = { dataTable[thing]["name_note"] } }
end
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
end
return "\n| style=\"text-align:center\" | " .. gameLink .. "\n| " .. desc .. "\n|-"
end
end


return p
return p

Latest revision as of 18:50, 11 December 2024

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

local getArgs = require('Module:Arguments').getArgs
local p = {}
local function capitalizeFirstLetter(inputText)
	return inputText:sub(1,1):upper() .. inputText:sub(2)
end
function p.main(frame)
	local args = getArgs(frame)
	if not args[3] then
		local game = ""
		if args[1] then
			game = args[1]
		end
		local desc = ""
		if args[2] then
			desc = args[2]
		end
		return "\n| style=\"text-align:center\" | " .. game .. "\n| " .. desc .. "[[Category:Pages using old GameDesc format]]\n|-"
	else
		local category = args[1]:lower() --I.e. is it skill or item?
		local game = args[2]:lower()
		local thing = args[3]:lower()
		local dataTable = require("Module:Data/" .. capitalizeFirstLetter(category) .. "/" .. game)[category]
		local gameLink = frame:expandTemplate{ title = "Link", args = { "Game", game } }
		if not dataTable[thing] then
			error(capitalizeFirstLetter(category) .. " \"" .. thing .. "\" not defined for " .. game)
		end
		if dataTable[thing]["effect_note"] then
			gameLink = gameLink .. frame:expandTemplate { title = 'exp', args = { dataTable[thing]["effect_note"] } }
		elseif dataTable[thing]["name_note"] then
			gameLink = gameLink .. frame:expandTemplate { title = 'exp', args = { dataTable[thing]["name_note"] } }
		end
		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
end

return p