Module:Calculator

local getArgs = require('Module:Arguments').getArgs local loader = require('Module:Loader')

local p = {}

-- For Template:Calculator/Ticks and Calculator:Ticks function p.miningSpeedToTicks( frame ) local args = getArgs(frame) local ms = tonumber(args.mining_speed) or 0 local bs = tonumber(args.block_strength) or 0 local bl = args.block or "Any other blocks" return p._miningSpeedToTicks(ms, bs, bl) end

-- Module Access Point function p._miningSpeedToTicks(mining_speed, block_strength, block) if mining_speed >= (block_strength * 60) then return 1 elseif string.match(string.lower(block), 'netherrack') and mining_speed >= (block_strength * 30) then return 1 else return math.max(('%.0f'):format(block_strength * 30 / mining_speed), 4) end end

-- For Template:Calculator/Mining Speed and Calculator:Mining Speed function p.ticksToMiningSpeed( frame ) local args = getArgs(frame) local tk = tonumber(args.ticks) or 0 local bs = tonumber(args.block_strength) or 0 local bl = args.block or "Any other blocks" return p._ticksToMiningSpeed(tk, bs, bl) end

-- Module Access Point function p._ticksToMiningSpeed(ticks, block_strength, block) if ticks == 1 and string.match(string.lower(block), 'netherrack') then return block_strength * 30 elseif ticks == 1 then return block_strength * 60 else return math.ceil(block_strength * 30 / (math.max(ticks, 4) + 0.49999)) end end

return p