Module:Sandbox: Difference between revisions

From Path of Exile 2 Wiki
Jump to navigation Jump to search
>OmegaK2
No edit summary
m (257 revisions imported)
 
(47 intermediate revisions by 4 users not shown)
Line 1: Line 1:
local p = {}
-- This is not an actual module. Do not add code.
local g_frame
local getArgs = require('Module:Arguments').getArgs
 
-- local quest_data = mw.loadData('Module:QuestReward/data')
local quest_data = require('Module:QuestReward/data')
 
local poe_classes = {'Marauder', 'Templar', 'Witch', 'Shadow', 'Ranger', 'Duelist', 'Scion'}
local poe_difficulties = {'Normal', 'Cruel', 'Merciless'}
local data_keys = {'reward', 'type', 'class', 'difficulty', 'quest', 'quest_id', 'act', 'itemlevel', 'rarity', 'sockets', 'page_link'}
local supported_compares = {'eq', 'neq', 'lt', 'gt', 'le', 'ge'}
 
function p.table(frame)
    --if not getArgs then
-- getArgs = require('Module:Arguments').getArgs
--end
    -- TODO: Remove
    --if frame == nil then
    --    frame = mw.getCurrentFrame()
    --end
   
    local args = getArgs(frame, {
parentFirst = true
})
    g_frame = frame
   
    args.filter_by_difficulty = args.filter_by_difficulty or 1
    --args.filter_by_act = args.filter_by_act or 1
    --args.filter_by_quest_id = args.quest_id or 1
    args.display_style = args.display_style or args.displayStyle or args.DisplayStyle or 'full'
   
    args.order_by_difficulty = args.order_by_difficulty or 'le'
    args.order_by_act = args.order_by_act or 'le'
    args.order_by_quest_id = args.order_by_quest_id or 'le'
   
    local out = ''
   
    if args.order_priority == nil then
        args.order_priority = {'difficulty', 'act', 'quest_id'}
    else
        local temp = split(args.order_priority)
        local out = {}
        for _, key1 in ipairs(temp) do
            if in_array(data_keys, key1) then
                table.insert(out, key1)
            else
                error("Invalid key in order priority" .. key1)
            end
        end
        args.order_priority = out
    end
   
    local filter_keys = {}
    local search_keys = {}
   
    for _, key in ipairs(data_keys) do
        if args['filter_by_' .. key] ~= nil then
            filter_keys[key] = args['filter_by_' .. key]
        end
        if args['order_by_' .. key] ~= nil then
            comp = args['order_by_' .. key]
            if in_array(supported_compares, comp) then
                table.insert(search_keys, {key=key, cmp=comp})
            else
                error("Invalid compare: " .. comp)
            end
        end
    end
   
    return out
end
function in_array(array, key)
    for _, v in ipairs(array) do
        if v == key then return true end
    end
    return false
end
return p

Latest revision as of 01:33, 23 September 2024

Module documentation[view] [edit] [history] [purge]


This page is not an actual Scribunto module. It exists to provide editors a place to create experimental modules.

Naming your modules

To keep things tidy, please use the following format to name your experimental modules:

Module:Sandbox/Your username/Module name

Cleaning up unused modules

Experimental modules may be deleted by admins upon request or after a long period of inactivity.

List of modules in this area

For a list of the experimental modules under Module:Sandbox, see Special:PrefixIndex/Module:Sandbox/.

-- This is not an actual module. Do not add code.