FANDOM


-- Calculator - Easily add arithmetic operations to wiki pages
-- Written by Shining-Armor
-- Version 0.1
 
local p = {}
 
function p.empty( s )
    if s == nil or s == '' then 
        return true
    else
        return false
    end
end
 
function p.addition( frame )
    if p.empty( frame.args[1] ) or p.empty( frame.args[2] ) then
        return '<span class="lua-calc-nodule-error">Must provide 2 values for operation</span>'
    else
        return tonumber( frame.args[1] ) + tonumber( frame.args[2] )
    end
end
 
function p.division( frame )
    if p.empty( frame.args[1] ) or p.empty( frame.args[2] ) then
        return '<span class="lua-calc-nodule-error">Must provide 2 values for operation</span>'
    else 
        return tonumber( frame.args[1] ) / tonumber( frame.args[2] )
    end
end
 
function p.modulo( frame )
    if p.empty( frame.args[1] ) or p.empty( frame.args[2] ) then
        return '<span class="lua-calc-nodule-error">Must provide 2 values for operation</span>'
    else
        return tonumber( frame.args[1] ) % tonumber( frame.args[2] )
    end
end
 
function p.multiplication( frame )
    if p.empty( frame.args[1] ) or p.empty( frame.args[2] ) then
        return '<span class="lua-calc-nodule-error">Must provide 2 values for operation</span>'
    else
        return tonumber( frame.args[1] ) * tonumber( frame.args[2] )
    end
end
 
function p.subtraction( frame )
    if p.empty( frame.args[1] ) or p.empty( frame.args[2] ) then
        return '<span class="lua-calc-nodule-error">Must provide 2 values for operation</span>'
    else
        return tonumber( frame.args[1] ) - tonumber( frame.args[2] )
    end
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.