Module:QuarterMaster

From Lotro-Wiki.com
Jump to navigation Jump to search

A lua script by Sagarmatha.


local p = {}

local args = {}
local origArgs
local root

function p.box(frame)
    if frame == mw.getCurrentFrame() then
        origArgs = frame:getParent().args
    else
        origArgs = frame
    end

    root = mw.html.create()

    for i = 1,10 do
        arg_name = "frame.args.group" .. i .. "-name"
        if arg_name == nil then
            break
        end
        mw.log("arg_name: ", arg_name)
        -- group_name = frame.args.group .. i .. "-name"
    end
    -- return tostring(root)
    return "return value from Module:QuarterMaster"
end

function p.asc(frame)
    items = splitLine( frame.args[1] );
    table.sort( items );
    return table.concat( items, "\n" );    
end

function p.desc(frame)
    items = splitLine( frame.args[1] );
    table.sort( items, revComp );
    return table.concat( items, "\n" );
end

function splitLine( text )
    return mw.text.split( text, "\n", true );    
end

function revComp( a, b )
    return a > b;
end

return p