Module:Damage: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 4: Line 4:
function string.starts(String, Start)
function string.starts(String, Start)
     return string.sub(String, 1, string.len(Start)) == Start
     return string.sub(String, 1, string.len(Start)) == Start
end
-- Function wrapper for vardefine syntax in MW.
function var(name, dmg)
    return '{{#vardefine:{{formatnum:' .. name .. '|' .. round(dmg) .. '}}%}}'
end
end


Line 26: Line 21:
                 return true
                 return true
             end
             end
        end
    end
    -- Function wrapper for vardefine syntax in MW.
    function var(name, dmg)
        if (args.format == 'false') then
            return '{{#vardefine:' .. name .. '|' .. round(dmg) .. '}}'
        else
            return '{{#vardefine:{{formatnum:' .. name .. '|' .. round(dmg) .. '}}%}}'
         end
         end
     end
     end


     -- Handle trait table
     -- Handle trait table
     local traits, vars = {}
     local traits = {}


     if (inArgs('heavy')) then
     if (inArgs('heavy')) then
Line 202: Line 206:
     end
     end


     local fvals = list(true)
     local out = list(false)
    local pvp = list(true)
 
    -- Merge the output to a unified table.
    tableMerge(out, pvp)


     -- Get the actual variables with MW syntax.
     -- Get the actual variables with MW syntax.
    local vars = {}
    for k, v in spairs(out) do
        table.insert(vars, var(k, v))
    end
    -- Dump all values.
    -- local ret = {}
     -- for k, v in spairs(fvals) do
     -- for k, v in spairs(fvals) do
     --    table.insert(vars, var(k, v))
     --    table.insert(ret, k .. ': ' .. v)
     -- end
     -- end


     -- Dump all values.
     -- return frame:preprocess(table.concat(ret, "<br/>"))
    local ret = {}
    for k, v in spairs(fvals) do
        table.insert(ret, k .. ': ' .. v)
    end
 
    return frame:preprocess(table.concat(ret, "<br/>"))


     -- Dump all variables
     -- Dump all variables
     -- return table.concat(vars)
     return table.concat(vars)


     -- Parse all variables
     -- Parse all variables