Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.The edit appears to have already been undone. Anti-spam check. Do not fill this in!local p = {} -- Finds the next key key <= or >= the given i. -- operator is ±1 local function findItemRange(data, i, operator) local bestIndex = nil i = i * operator for k, v in pairs(data) do local kop = type(k) == 'number' and k * operator if kop and kop <= i and (bestIndex == nil or kop > bestIndex * operator) then bestIndex = k end end if bestIndex then return data[bestIndex] else return nil end end local function load(datamodule, frame) local args = frame.args local data = mw.loadData(datamodule) for i = 1, 20 do if args[i] then data = data[tonumber(args[i]) or args[i]] elseif args[i .. ' lteq'] then data = findItemRange(data, tonumber(args[i .. ' lteq']), 1) elseif args[i .. ' gteq'] then data = findItemRange(data, tonumber(args[i .. ' gteq']), -1) else break end end if data == nil then return args['if_nil'] -- not a required argument, OK to return nil here. end if type(data) == 'table' then -- Put the table into another table because the return value of loadData -- is a "fake" table that only has certain metamethods. local realdata = {} for k, v in pairs(data) do realdata[k] = v end data = realdata else data = { data } end if args['template'] then return mw.text.unstripNoWiki(args['template']):format(unpack(data)) elseif args['preprocess'] then return frame:preprocess(mw.text.unstripNoWiki(args['preprocess']):format(unpack(data))) else return table.concat(data) end end return setmetatable({}, { __index = function(t, k) return function(frame) return load('Module:' .. k, frame) end end }) Summary: Please note that all contributions to Arcadian Odyssey Extended Universe may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here. You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Arcadian Odyssey Extended Universe:Copyrights for details). Do not submit copyrighted work without permission! Cancel Editing help (opens in new window)