Module:DPSCalculator

-- damage * attackspeed

local p = {}

function Calculate(Damage, DamageMin, DamageMax, Speed, SpeedMin, SpeedMax) if Damage == 0 then Damage = nil else Damage = 1 - Damage end if DamageMin == 0 then DamageMin = nil else DamageMin = 1 - Damage end if DamageMax == 0 then DamageMax = nil else DamageMin = 1 - Damage end if Speed == 0 then Speed = nil else Speed = 1 - Speed end if SpeedMin == 0 then SpeedMin = nil else SpeedMin = 1 - SpeedMin end if SpeedMax == 0 then SpeedMax = nil else SpeedMax = 1 - SpeedMax end

-- Single addition and single Speediply if Damage and not DamageMin and not DamageMax and Speed and not SpeedMin and not SpeedMax then local as = Damage * Speed return math.floor(as*100)/100, math.floor(1/as*100)/100 -- Single addition, range Speediply elseif Damage and not DamageMin and not DamageMax and not Speed and SpeedMin and SpeedMax then local as1 = Damage * SpeedMin local as2 = Damage * SpeedMax return math.floor(as1*100)/100, math.floor(as2*100)/100, math.floor(1/as1*100)/100, math.floor(1/as2*100)/100 -- Range addition, single Speediply elseif not Damage and DamageMin and DamageMax and Speed and not SpeedMin and not SpeedMax then local as1 = DamageMin * Speed local as2 = DamageMax * Speed return math.floor(as1*100)/100, math.floor(as2*100)/100, math.floor(1/as1*100)/100, math.floor(1/as2*100)/100 -- Range addition, range Speediply elseif not Damage and DamageMin and DamageMax and not Speed and SpeedMin and SpeedMax then local as1 = DamageMin * SpeedMin local as2 = DamageMax * SpeedMax return math.floor(as1*100)/100, math.floor(as2*100)/100, math.floor(1/as1*100)/100, math.floor(1/as2*100)/100 -- Bruh else return "Invalid input!", "Invalid Input!" end end

p.Calculate = function(frame) local as1, as2, as3, as4 = Calculate(tonumber(frame.args[1]), tonumber(frame.args[2]), tonumber(frame.args[3]), tonumber(frame.args[4])) if as3 then return string.format("%s - %s", frame:callParserFunction("#tip-text", as1, string.format("%s strikes per second", as3)), frame:callParserFunction("#tip-text", as2, string.format("%s strikes per second", as4))) else return frame:callParserFunction("#tip-text", as1, string.format("%s seconds per strike", as2)) end end

return p -- print(Calculate(tonumber(arg[1]), tonumber(arg[2]), tonumber(arg[3]), tonumber(arg[4])))