Module:NationNamer: Difference between revisions
From Terra Invicta Official Wiki
Llamageddon (talk | contribs) added temporary test functions |
Llamageddon (talk | contribs) mNo edit summary |
||
| (11 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
-- For now this is just used by the NationDataNameRedirect template to convert nation displayNames to dataNames | -- For now this is just used by the NationDataNameRedirect template to convert nation displayNames to dataNames | ||
-- Another LUA module to avoid 100+ switch templates | -- Another LUA module to avoid 100+ switch templates | ||
-- Todo add 2070 page functionality | |||
local p = {} | local p = {} | ||
local nationData = mw.loadData( 'Module:NationNamer/dataNames' ) | local nationData = mw.loadData( 'Module:NationNamer/dataNames' ) | ||
-- /displayNames not currently used -- | |||
--local nationData = mw.loadData( 'Module:NationNamer/displayNames' )-- | |||
function p. | -- 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] | local nationName = frame.args[1] | ||
if not nationName then | if not nationName then | ||
return 'No | return 'No nation name specified' | ||
end | end | ||
if not nationData[nationName] then | if not nationData[nationName] then | ||
| Line 16: | Line 21: | ||
-- iconData[iconName][1] is the nation dataName (country code). | -- iconData[iconName][1] is the nation dataName (country code). | ||
return | return nationData[nationName][1] | ||
end | end | ||
function p. | -- Returns a string for a redirect based on arg 1 | ||
local | function p.Redirect( frame ) | ||
return ' | 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[nationName][1] is the nation dataName (country code). | |||
return '#REDIRECT [[' .. nationData[nationName][1] .. ']]' | |||
end | end | ||
function p. | function p.Test( frame ) | ||
local | local nationName = frame.args[1] | ||
return ' | 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 | end | ||
return p | return p | ||
Latest revision as of 11:24, 13 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
-- Todo add 2070 page functionality
local p = {}
local nationData = mw.loadData( 'Module:NationNamer/dataNames' )
-- /displayNames not currently used --
--local nationData = mw.loadData( 'Module:NationNamer/displayNames' )--
-- 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
-- Returns a string for a redirect based on arg 1
function p.Redirect( 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[nationName][1] is the nation dataName (country code).
return '#REDIRECT [[' .. 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


