Module:Experience: Difference between revisions

77 bytes added ,  Thursday at 10:40
Handle commas in xp arg since they can be quite large
(Created page with "require('strict') local data = mw.loadData('Module:Experience/data') local p = {} function p.total_xp(frame) local args = frame:getParent().args return p._total_xp(args[1]) end --Returns the total experience needed to reach a level (from 0) function p._total_xp(level) level = tonumber(level) or 0 local floor = math.floor(level) local frac = level - floor if frac ~= 0 then -- Linearly interpolate things like "level 100.5" as "halfway between level 100 and...")
 
(Handle commas in xp arg since they can be quite large)
 
Line 67:
]]
function p._level_at(xp)
if type(xp) == 'string' then
xp = xp:gsub(',', '') -- Remove commas
end
xp = tonumber(xp) or 0
if xp >= data.level[500] then
697

edits