Module:Sandbox/Raph Williams65/CalculateAlchValue

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
-- usage: {{#invoke:Module:Sandbox/Raph Williams65/CalculateAlchValue|main|value}}
local p = {}

function p.main(frame)
     local shop_value_str = frame.args[1]
     local shop_value = tonumber(shop_value_str)

 -- :expandTemplate
-- Check he the conversion went successful
     if not shop_value then
        return '<span class="error">Error: Invalid or missing shop value. Received: </span>' .. tostring(shop_value_str)
     end

     local percentage = 1.3754
     local result = math.ceil((shop_value * percentage)-0.5)

     return tostring(result)
end

return p