Module:NationNamer

From Terra Invicta Official Wiki
Revision as of 01:21, 5 December 2025 by Llamageddon (talk | contribs)

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' )

-- This is the simplest implementation of this module.
-- It returns a country code if argument 1 matches a country name.
function p.Dataname( frame )
	local nationName = frame.args[1]
	if not nationName then
		return 'No nation name specified'	
	end
	if not nationData[nationName] then
		return 'No such nation name'	
	end
	
	-- iconData[iconName][1] is the nation dataName (country code).
	return nationData[nationName][1]
end

function p.Test( 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
	
	-- this will output what the function returns preformatted for scrutiny.
	return '<pre>' .. nationData[nationName][1] .. '</pre>'
end
return p