Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Difficulties: Difference between revisions

From Obby Wiki
No edit summary
No edit summary
Tag: Reverted
Line 1: Line 1:
local p = {}
return {
    ['meta'] = {
        page_prefix = 'Difficulty/';
    };


local config = require('Module:Difficulties/config')
    ['difficulties'] = {
        ['effortless'] = {
            display = 'Effortless';
            color = '#A5A2A3';
            priority = 0;
        };


local function ucfirst(str)
        ['very_easy'] = {
    return str:sub(1,1):upper() .. str:sub(2)
            display = 'Very Easy';
end
            color = '#00FF00';
            priority = 0.3;
        };


function p.main(frame)
        ['easy'] = {
    local args = frame:getParent().args
            display = 'Easy';
    local difficulties = config.difficulties
            color = '#00FF00';
    local output = mw.html.create('table')
            priority = 1;
    output:addClass('wikitable')
        };
    output:addClass('center')
    output:addClass('full-width')
    output:attr('style', 'width:100%;')


    local header_row = output:tag('tr')
        ['normal'] = {
    header_row:tag('th'):wikitext('Icon')
            display = 'Normal';
    header_row:tag('th'):wikitext('Difficulty')
            color = '#FFFF00';
    header_row:tag('th'):wikitext('Stages')
            priority = 1.9;
    header_row:tag('th'):wikitext('Completion %')
        };
    header_row:tag('th'):wikitext('Rewards'):addClass('center')


    local difficulties_s = {}
        ['medium'] = {
            display = 'Medium';
            color = '#FFFF00';
            priority = 2;
        };


    for k, v in pairs(difficulties) do
         ['average'] = {
         table.insert(difficulties_s, {
             display = 'Average';
             key = k,
            color = '#000000';
             data = v
             priority = 3;
         })
         };
    end


    table.sort(difficulties_s, function(a,b)
        ['hard'] = {
        return a.data.priority < b.data.priority
            display = 'Hard';
    end)
            color = '#ff0000';
            priority = 4;
        };


        ['very_hard'] = {
            display = 'Very Hard';
            color = '#ff0000';
            priority = 4.1;
        };


    for _, entry in pairs(difficulties_s) do
        ['difficult'] = {
        local i = entry.key
            display = 'Difficult';
         local v = entry.data
            color = '#000000';
            priority = 5;
         };


         local difficulty_param_name = mw.text.trim(i)
         ['extreme'] = {
         local enabled_param = args[ucfirst(difficulty_param_name)] or args[difficulty_param_name]
            display = 'Extreme';
            color = '#000000';
            priority = 6;
         };


         if enabled_param and mw.text.trim(enabled_param):lower() == 'true' then
         ['challenging'] = {
             entry.data.priority = tonumber(args[difficulty_param_name .. '_priority']) or entry.data.priority
            display = 'Challenging';
         end
             color = '#000000';
    end
            priority = 7;
         };


    table.sort(difficulties_s, function(a,b)
        ['impossible'] = {
        return a.data.priority < b.data.priority
            display = 'Impossible';
    end)
            color = '#000000';
            priority = 8;
        };


    for _, entry in pairs(difficulties_s) do
        ['remorseless'] = {
        local i = entry.key
            display = 'Remorseless';
         local v = entry.data
            color = '#000000';
            priority = 9;
         };


         local difficulty_param_name = mw.text.trim(i)
         ['insane'] = {
         local enabled_param = args[ucfirst(difficulty_param_name)] or args[difficulty_param_name]
            display = 'Insane';
            color = '#000000';
            priority = 10;
         };


         if enabled_param and mw.text.trim(enabled_param):lower() == 'true' then
         ['terrifying'] = {
             local row = output:tag('tr')
            display = 'Terrifying';
             color = '#000000';
            priority = 11;
        };


            local icon_cell = row:tag('td')
        ['arduous'] = {
             local color_hex = args[difficulty_param_name .. '_hex']
             display = 'Arduous';
             local icon_file = args[difficulty_param_name .. '_file_name']
             color = '#000000';
             -- if v.file then
             priority = 12;
        };


            if icon_file then
        ['catastrophic'] = {
                icon_cell:wikitext('[[File:' .. icon_file .. '|48px|alt=Difficulty ' .. v.display .. ']]'):attr('style', 'border-radius: 8px; overflow: hidden; display:inline-block;')
            display = 'Catastrophic';
             else
             color = '#000000';
                icon_cell:tag('div')
            priority = 13;
                    :attr('style', 'width: 48px; height: 48px; background-color: ' .. ((color_hex and '#'.. color_hex) or v.color) .. '; vertical-align: middle; border-radius: 8px;')
        };
            end


            local name_cell = row:tag('td')
        ['unbeatable'] = {
            local page_link = config.meta.page_prefix .. v.display
             display = 'Unbeatable';
             if not v.display then
             color = '#000000';
                page_link = config.meta.page_prefix .. ucfirst(i)
             priority = 14;
            end
        };
 
     };
            -- name_cell:tag('a')
}
             name_cell:wikitext('[[' .. v.display .. ']]'):attr('style', 'color:'..v.color..';') -- maybe thats how this works
                -- :wikitext('[[' .. v.display .. ']]')
                -- :attr('href', mw.title.makeTitle('',page_link):fullUrl())
                -- :wikitext(v.display or ucfirst(i))
 
            local stage_cell = row:tag('td')
            local start_value = args[difficulty_param_name .. '_start']
            local end_value = args[difficulty_param_name .. '_end']
            local is_coming_soon = args[difficulty_param_name .. '_unreleased']
 
            if is_coming_soon then
                stage_cell:wikitext('\'\'Unreleased\'\'')
            else
                stage_cell:wikitext( (start_value or '??') .. ' - ' .. (end_value or '??'))
            end
 
            local completionp_cell = row:tag('td')
             local completionp_value = args[difficulty_param_name .. '_completion']
 
            completionp_cell:wikitext( (completionp_value or '??') .. '%')
 
            local rewards_cell = row:tag('td')
            local badge_param_name = difficulty_param_name .. '_badge'
            local badge_value = args[badge_param_name]
            if badge_value then
                -- badge_cell:tag('a')
                    -- :attr('href', 'https://roblox.com/badges' .. badge_value)
                    -- :attr('target', '_blank')
                    rewards_cell:wikitext('[[File:Icons Badge Small White.png|link=https://roblox.com/badges/' .. badge_value .. '/obbywikidifficultylink|alt=Badge|28px]]')
                    rewards_cell:attr('style', 'vertical-align: middle; margin-auto;')
                        -- :attr('src', mw.file.makeUrl('Icons Badge Small White.png'))
                        -- :attr('alt', 'Badge')
                        -- :attr('style', 'width: 20px; height: 20px; vertical-align: middle;')
            else
                rewards_cell:wikitext('\'\'None\'\'')
            end
        end
     end
 
    return tostring(output)
end
 
return p

Revision as of 04:30, 10 April 2025

Documentation for this module may be created at Module:Difficulties/doc

return {
    ['meta'] = {
        page_prefix = 'Difficulty/';
    };

    ['difficulties'] = {
        ['effortless'] = {
            display = 'Effortless';
            color = '#A5A2A3';
            priority = 0;
        };

        ['very_easy'] = {
            display = 'Very Easy';
            color = '#00FF00';
            priority = 0.3;
        };

        ['easy'] = {
            display = 'Easy';
            color = '#00FF00';
            priority = 1;
        };

        ['normal'] = {
            display = 'Normal';
            color = '#FFFF00';
            priority = 1.9;
        };

        ['medium'] = {
            display = 'Medium';
            color = '#FFFF00';
            priority = 2;
        };

        ['average'] = {
            display = 'Average';
            color = '#000000';
            priority = 3;
        };

        ['hard'] = {
            display = 'Hard';
            color = '#ff0000';
            priority = 4;
        };

        ['very_hard'] = {
            display = 'Very Hard';
            color = '#ff0000';
            priority = 4.1;
        };

        ['difficult'] = {
            display = 'Difficult';
            color = '#000000';
            priority = 5;
        };

        ['extreme'] = {
            display = 'Extreme';
            color = '#000000';
            priority = 6;
        };

        ['challenging'] = {
            display = 'Challenging';
            color = '#000000';
            priority = 7;
        };

        ['impossible'] = {
            display = 'Impossible';
            color = '#000000';
            priority = 8;
        };

        ['remorseless'] = {
            display = 'Remorseless';
            color = '#000000';
            priority = 9;
        };

        ['insane'] = {
            display = 'Insane';
            color = '#000000';
            priority = 10;
        };

        ['terrifying'] = {
            display = 'Terrifying';
            color = '#000000';
            priority = 11;
        };

        ['arduous'] = {
            display = 'Arduous';
            color = '#000000';
            priority = 12;
        };

        ['catastrophic'] = {
            display = 'Catastrophic';
            color = '#000000';
            priority = 13;
        };

        ['unbeatable'] = {
            display = 'Unbeatable';
            color = '#000000';
            priority = 14;
        };
    };
}