Module:Ability progression

local p = {} local lib      = require('Module:Feature')

function p.get(frame) local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end values="" i=1 local temp,a,b,c local round=args["round"] or 2 while args[i]~=nil do       if i==7 then return  Error. Maximum size of 6 exceeded. Details  end if string.find(args[i],"%:")~=nil and string.find(args[i],"%<")==nil then start,finish,times=args[i]:match"([^:]*): *([^ ]*) *(.*)" start=tonumber(expr(start)) finish=tonumber(expr(finish)) if times=="" or times==nil then times=5 end times=tonumber(expr(times)) if times>=7 then return  Error. Maximum size of 6 exceeded. Details  end x=1 while x<=times do               formula=start+(finish-start)/(times-1)*(x-1) if values=="" then values=fd(rounding(formula,round)) else values=values.." / "..fd(rounding(formula,round)) end x=x+1 end else if values=="" then values=fd(rounding(args[i],round)) else values=values.." / "..fd(rounding(args[i],round)) end end i=i+1 end return values end function expr(val) val=string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(string.gsub(val," ",""),"%/"," / "),"%*"," * "),"%+"," + "),"%-"," - "),"%^ %- ","^-"),"%( %- ","(-"),"%^"," %^ ") local i=1 local j=1 local a,b,switcher,temp while i>0 do       while j>0 do            temp=val if string.find(val,"%)")~=nil then               switchertemp=mw.text.split( val, "%)") temp=last(switchertemp[1],"%(")           end            if string.find(temp," %^ ")~=nil then                a=mw.text.split(temp," %^ ")                b=mw.text.split(a[2]," ")                switcher=last( a[1]," ")                switcher2=b[1]                switcher3=switcher^switcher2                if string.find(switcher2,"%-")~=nil then                     switcher2="%-"..switcher2*(-1)                end                val=string.gsub(val,switcher.." %^ "..switcher2,switcher3)                break            end            if string.find(temp," %/ ")~=nil then                a=mw.text.split(temp," %/ ")                b=mw.text.split(a[2]," ")                switcher=last( a[1]," ")                switcher2=b[1]                switcher3=switcher/switcher2                if string.find(switcher2,"%-")~=nil then                     switcher2="%-"..switcher2*(-1) end val=string.gsub(val,switcher.." %/ "..switcher2,switcher3) break end if string.find(temp," %* ")~=nil then a=mw.text.split( temp," %* ") b=mw.text.split(a[2]," ") switcher=last( a[1]," ") switcher2=b[1] switcher3=switcher*switcher2 if string.find(switcher2,"%-")~=nil then switcher2="%-"..switcher2*(-1) end val=string.gsub(val,switcher.." %* "..switcher2,switcher3) break end if string.find(temp," %- ")~=nil then a=mw.text.split( temp," %- ") b=mw.text.split(a[2]," ") switcher=last( a[1]," ") switcher2=b[1] switcher3=switcher-switcher2 if string.find(switcher2,"%-")~=nil then switcher2="%-"..switcher2*(-1) end val=string.gsub(val,switcher.." %- "..switcher2,switcher3) break end if string.find(temp," %+ ")~=nil then a=mw.text.split( temp," %+ ") b=mw.text.split(a[2]," ") switcher=last( a[1]," ") switcher2=b[1] switcher3=switcher+switcher2 if string.find(switcher2,"%-")~=nil then switcher2="%-"..switcher2*(-1) end val=string.gsub(val,switcher.." %+ "..switcher2,switcher3) break end if string.find(val,"%)")~=nil then               if string.find(temp,"%-")~=nil then                     temp="%-"..temp*(-1)                end                val=string.gsub(val,"%("..temp.."%)",temp)                break            else                i=0            end            break        end    end    return temp end function last(val,sign)    local a=mw.text.split(val,sign)    local j=1    while j>0 do        if (a[j] ~=nil) and ((a[j]~="") or (sign=="%(")) then j=j+1 else break end end return a[j-1] end function fd(val) if string.find(val,"[0-9]")==nil then return val end local a,b,c local val=tostring(val) if string.find(val,"%.")==nil then return val else if string.find(val,"span")~=nil then a,b = val:match"([^.]*).(.*)" b = '. ' .. b.. ' '       c="" else a,b,c = val:match"([^.]*).([0-9]*)(.*)" b = '. ' .. b.. ' '       end end return a..b..c end function rounding(num, numDecimalPlaces) if string.find(num,"[0-9]")==nil or string.find(num,"<span")~=nil then return num end local a,b,c local val=tostring(num) if string.find(val,"%.")==nil then a,c = val:match"([0-9]*)(.*)" b="" if c==nil then c="" end else a,b,c = val:match"([^.]*).([0-9]*)(.*)" b = "."..b   end val=tonumber(a..b)   local mult = 10^(numDecimalPlaces) local round=math.floor(val * mult + 0.5) / mult return round..c end return p