Die Dokumentation für dieses Modul kann unter Modul:Ability progression/Doku erstellt werden

-- <pre>
local p = {}
local lib       = require('Module:Feature')

function p.test(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
        return expr(args[1])
end

function p.get(frame)
    local args; if frame.args == nil then args = lib.arguments(frame) else args = lib.arguments(frame.args) end
    values=""
    count=7
     if args["skill"]=="R" then
        fill=3
    else
        fill=5
    end
    i=1
    local temp,a,b,c
    local round=args["round"] or 2
    while args[i]~=nil do
        if string.find(args[i],"to")~=nil and string.find(args[i],"%<")==nil then
            start,finish,times=args[i]:match"(.*) *to *([^ ]*) *([^ ]*)"
            if start~=nil and finish~=nil and pcall(expr,start.."*2")~=false and pcall(expr,finish.."*2")~=false then
                start=tonumber(expr(start))
                finish=tonumber(expr(finish))
                if times=="" or times==nil then
                    times=fill
                    fill=0
                else
                    times=tonumber(expr(times))  
                end
                x=1
                while x<=times do
                    count=count-1
                    if count==0 then
                        i=-1
                        break
                    end
                    if x==1 then
                        formula=start
                    else
                        formula=formula+(finish-start)/(times-1)
                    end
                    if values=="" then
                        values=fd(rounding(formula,round))
                    else
                        values=values.." / "..fd(rounding(formula,round))
                    end
                    x=x+1
                end
            else
                count=count-1
                if count==0 then
                    break
                end
                if values=="" then
                    values=fd(rounding(args[i],round))
                else
                    values=values.." / "..fd(rounding(args[i],round))
                end
            end
        else
            count=count-1
            if count==0 then
                break
            end
            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," ",""),"%/"," / "),"%*"," * "),"%+"," + "),"%-"," - "),"%^"," %^ "),"([^%d%(%)]) %- ","%1-"),"([^%d%(%)]) %+ ","%1+")
    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]
                if switcher=="" then
                    if string.find(switcher2,"%-")~=nil then 
                        switcher2="%-"..switcher2*(-1)
                    end
                    val=string.gsub(val," %- "..switcher2,"%-"..switcher2)
                    break  
                else
                    switcher3=switcher-switcher2
                    if string.find(switcher2,"%-")~=nil then 
                        switcher2="%-"..switcher2*(-1)
                    end
                    val=string.gsub(val,switcher.." %- "..switcher2,switcher3)
                    break
                end
            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]
                if switcher=="" then
                    if string.find(switcher2,"%-")~=nil then 
                        switcher2="%-"..switcher2*(-1)
                    end
                    val=string.gsub(val," %+ "..switcher2,switcher2)
                    break  
                else
                    switcher3=switcher+switcher2
                    if string.find(switcher2,"%-")~=nil then 
                        switcher2="%-"..switcher2*(-1)
                    end
                    val=string.gsub(val,switcher.." %+ "..switcher2,switcher3)
                    break
                end
            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 then
            j=j+1
        else
        break
        end
    end
    return a[j-1]
end
function fd(val)
    if string.find(val,"[0-9]")==nil or (string.find(val,"%.")==nil and string.find(val,"%,")==nil) then
        return val
    end
    local a,b,c,values
    if string.find(val,"span")~=nil then
            a,b,c = val:match"([^,]*),(.*)</span>(.*)"
            if string.find(tostring(b),"[0-9]")==nil then
                values=val
            else
                if string.find(val,"span")<=string.find(val,"%,") then
                    values= a..",<small>"..b.."</small></span>"..c
                else
                    values= a..",<small>"..b.."</span></small>"..c
                end
            end
    else
        a,b,c = val:match"([^,]*),([0-9]*)(.*)"
        if string.find(tostring(b),"[0-9]")==nil then
            values= val
        else
        values= a..",<small>"..b.."</small>"..c
        end
    end
    if string.find(values,"span")~=nil then
        a,b,c = values:match"([^.]*)%.(.*)</span>(.*)"
        if string.find(tostring(b),"[0-9]")==nil then
            return values
        else
            if string.find(values,"span")<=string.find(values,"%.") then
                return a..",<small>"..b.."</small></span>"..c 
            else
                return a..",<small>"..b.."</span></small>"..c
            end
        end
    else
        a,b,c = values:match"([^.]*)%.([0-9]*)(.*)"
        if string.find(tostring(b),"[0-9]")==nil then
            return values
        else
        return a..",<small>"..b.."</small>"..c
        end
    end
end
function rounding(val, numDecimalPlaces)
    val=tostring(val)
    if string.find(val,"[0-9]")==nil or string.find(val,"<span")~=nil or (string.find(val,"%.")==nil and string.find(val,"%,")==nil) then
        return val
    end
    local a,b,c,d,values,round
    local mult = 10^(numDecimalPlaces)
        a,b,c,d = val:match"([^0-9]*)([0-9]*),([0-9]*)(.*)"
        if string.find(tostring(c),"[0-9]")==nil then
            values=val
        else
            val=tonumber(b.."."..c)
            round=math.floor(val * mult + 0.5) / mult
            values=a..round..d
        end
        a,b,c,d = values:match"([^0-9]*)([0-9]*).([0-9]*)(.*)"
        if string.find(tostring(c),"[0-9]")==nil then
            return values
        else
            val=tonumber(b.."."..c)
            round=math.floor(val * mult + 0.5) / mult
            return a..round..d
        end
end
return p

-- </pre>
--[[Category:Lua]]
Nutzung von Community-Inhalten gemäß CC-BY-SA, sofern nicht anders angegeben.