Module:Sandbox

From Nookipedia, the Animal Crossing wiki

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

local p = {}

local function getArgs(frame)
    local args = {}
    for key, value in pairs(frame:getParent().args) do
        args[key] = value
    end
    for key, value in pairs(frame.args) do
        args[key] = value
    end
    return args
end

function p.main(frame)
    local args      = getArgs(frame)
    local num1      = args[1] or args.num1 or ''
    local num2      = args[2] or args.num2 or ''
    local num3      = args[3] or args.num3 or ''
    return p.calc(num1, num2, num3)
end

function p.calc(num1, num2, num3)
	local finalNum
	local a = tonumber(num1)
	local b = tonumber(num2)
	local c = tonumber(num3)
	finalNum = a + b + c
	return finalNum
end

return p