Difference between revisions of "Module:CapitalizationCheck"
From Nookipedia, the Animal Crossing wiki
PanchamBro (talk | contribs) m |
PanchamBro (talk | contribs) m |
||
Line 49: | Line 49: | ||
if compare == firstToUpper(data.firstGen[compare:lower()]) then | if compare == firstToUpper(data.firstGen[compare:lower()]) then | ||
return print | return print | ||
− | elseif compare | + | elseif compare == data.firstGen[compare:lower()] then |
return print | return print | ||
else | else | ||
Line 58: | Line 58: | ||
if compare == firstToUpper(data.wildWorld[compare:lower()]) then | if compare == firstToUpper(data.wildWorld[compare:lower()]) then | ||
return print | return print | ||
− | elseif compare | + | elseif compare == data.wildWorld[compare:lower()] then |
return print | return print | ||
else | else | ||
Line 65: | Line 65: | ||
end | end | ||
elseif game == "NH" or game == "New Horizons" then | elseif game == "NH" or game == "New Horizons" then | ||
− | |||
− | |||
if compare == firstToUpper(data.newHorizons[compare:lower()]) then | if compare == firstToUpper(data.newHorizons[compare:lower()]) then | ||
return print | return print | ||
− | elseif compare | + | elseif compare == data.newHorizons[compare:lower()] then |
return print | return print | ||
else | else |
Revision as of 12:24, November 19, 2022
Documentation for this module may be created at Module:CapitalizationCheck/doc
local p = {}
local getArgs = require('Module:Arguments').getArgs
data = mw.loadData("Module:CapitalizationCheck/Data")
function checkFirstGen(s)
if s == "DnM" then
return true
elseif s == "Doubutsu no Mori" then
return true
elseif s == "DnM+" then
return true
elseif s == "Doubutsu no Mori+" then
return true
elseif s == "PG" then
return true
elseif s == "Animal Crossing" then
return true
elseif s == "DnMe+" then
return true
elseif s == "Doubutsu no Mori e+" then
return true
elseif s == "iQue" then
return true
elseif s == "Dòngwù Sēnlín" then
return true
elseif s == "Dongwu Senlin" then
return true
else
return false
end
end
function p.main(frame)
local args = getArgs(frame)
local compare = args[1] or ''
local game = args[2] or ''
return p.checkCaps(compare, game)
end
-- https://stackoverflow.com/questions/2421695/first-character-uppercase-lua
function firstToUpper(str)
return (str:gsub("^%l", string.upper))
end
function p.checkCaps(compare, game)
local print = ''
local sentenceCase = ""
if checkFirstGen(game) then
if compare == firstToUpper(data.firstGen[compare:lower()]) then
return print
elseif compare == data.firstGen[compare:lower()] then
return print
else
print = print .. "Wrong.[[Category:Pages with item names improperly capitalized]]"
return print
end
elseif game == "WW" or game == "Wild World" then
if compare == firstToUpper(data.wildWorld[compare:lower()]) then
return print
elseif compare == data.wildWorld[compare:lower()] then
return print
else
print = print .. "Wrong.[[Category:Pages with item names improperly capitalized]]"
return print
end
elseif game == "NH" or game == "New Horizons" then
if compare == firstToUpper(data.newHorizons[compare:lower()]) then
return print
elseif compare == data.newHorizons[compare:lower()] then
return print
else
print = print .. "Wrong.[[Category:Pages with item names improperly capitalized]]"
return print
end
end
end
return p