Module:NationNamer: Difference between revisions

From Terra Invicta Official Wiki
Llamageddon (talk | contribs)
Module to (hopefully) generate nation display name page redirects
 
Llamageddon (talk | contribs)
m Changed funtion name to start uppercase
Line 6: Line 6:
local nationData = mw.loadData( 'Module:NationNamer/dataNames' )
local nationData = mw.loadData( 'Module:NationNamer/dataNames' )


function p.redirect( frame )
function p.Redirect( frame )
local nationName = frame.args[1]
local nationName = frame.args[1]
if not nationName then
if not nationName then

Revision as of 22:33, 4 December 2025

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

-- For now this is just used by the NationDataNameRedirect template to convert nation displayNames to dataNames
-- Another LUA module to avoid 100+ switch templates

local p = {}

local nationData = mw.loadData( 'Module:NationNamer/dataNames' )

function p.Redirect( frame )
	local nationName = frame.args[1]
	if not nationName then
		return 'No such nation name'	
	end
	if not nationData[nationName] then
		return 'No such nation name'	
	end
	
	local retstart = '#REDIRECT [['
	local retend = ']]'
	
	-- iconData[iconName][1] is the nation dataName (country code).
	return retstart .. nationData[nationName][1] .. retend
end

return p