Module:NHVer
From Nookipedia, the Animal Crossing wiki
Module documentation (view)
Usage
This Lua module outputs the Animal Crossing: New Horizons version name, which is declared through {{NHVer}}. Please refer to the documentation of that template for more information.
local p = {}
local getArgs = require('Module:Arguments').getArgs
function p.main(frame)
local args = getArgs(frame)
local args1 = args[1] or ''
local args2 = args[2] or ''
return p.outputNHVer(args1, args2)
end
function p.outputNHVer(args1, args2)
local function isEmpty(s)
return s == nil or s == ''
end
local function tableEmpty(s)
return next(s) == nil
end
local patches = {
["1.1.1"] = "1.1.0",
["1.1.2"] = "1.1.0",
["1.1.3"] = "1.1.0",
["1.1.4"] = "1.1.0",
["1.2.1"] = "1.2.0",
["1.3.1"] = "1.3.0",
["1.4.1"] = "1.4.0",
["1.4.2"] = "1.4.0",
["1.5.1"] = "1.5.0",
["1.11.1"] = "1.11.0",
["2.0.1"] = "2.0",
["2.0.2"] = "2.0",
["2.0.3"] = "2.0",
["2.0.4"] = "2.0",
["2.0.5"] = "2.0",
}
local names = {
["1.0.0"] = "initial release",
["1.1.0"] = "First Update",
["1.1.1"] = "First Update",
["1.1.2"] = "First Update",
["1.1.3"] = "First Update",
["1.1.4"] = "First Update",
["1.2.0"] = "April Free Update",
["1.2.1"] = "April Free Update",
["1.3.0"] = "Free Summer Update (Wave 1)",
["1.3.1"] = "Free Summer Update (Wave 1)",
["1.4.0"] = "Summer Update (Wave 2)",
["1.4.1"] = "Summer Update (Wave 2)",
["1.4.2"] = "Summer Update (Wave 2)",
["1.5.0"] = "Fall Update",
["1.5.1"] = "Fall Update",
["1.6.0"] = "Free Winter Update"
}
local print = ''
if not isEmpty(args1) then
if args1 == "1.0.0" then
print = print .. "[[Animal Crossing: New Horizons|1.0.0]]"
else
if not isEmpty(patches[args1]) then
print = print .. "[[Animal Crossing: New Horizons/Update history/" .. patches[args1] .. "|" .. args1 .. "]]"
else
print = print .. "[[Animal Crossing: New Horizons/Update history/" .. args1 .. "|" .. args1 .. "]]"
end
end
-- If args2 has full, then append full name
if not isEmpty(args2) then
print = print .. " "
if not isEmpty(names[args1]) then
print = print .. names[args1]
else
print = print .. "Free Update"
end
end
end
return print
end
return p