Module:WeaponDPS: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 2: | Line 2: | ||
function p.dps(frame) | function p.dps(frame) | ||
-- Try | local args = frame.args | ||
local str = tonumber( | local parent = frame:getParent() | ||
tonumber( | |||
tonumber( | -- Try both frame and parent frame for robustness | ||
local str = tonumber(args.strength or parent.args.strength) or | |||
tonumber(args.magic or parent.args.magic) or | |||
tonumber(args.range or parent.args.range) | |||
local ticks = tonumber( | local ticks = tonumber(args.ticks or parent.args.ticks) | ||
if not str or not ticks or ticks == 0 then | if not str or not ticks or ticks == 0 then |
Revision as of 12:22, 8 June 2025
Documentation for this module may be created at Module:WeaponDPS/doc
local p = {}
function p.dps(frame)
local args = frame.args
local parent = frame:getParent()
-- Try both frame and parent frame for robustness
local str = tonumber(args.strength or parent.args.strength) or
tonumber(args.magic or parent.args.magic) or
tonumber(args.range or parent.args.range)
local ticks = tonumber(args.ticks or parent.args.ticks)
if not str or not ticks or ticks == 0 then
return "Invalid input"
end
local maxHit = str / 8
local seconds = ticks * 0.6
local dps = maxHit / seconds
return string.format("%.2f DPS (Max Hit: %.2f)", dps, maxHit)
end
return p