Module:InfoboxCharacter: Difference between revisions

From Elwiki
No edit summary
No edit summary
(36 intermediate revisions by the same user not shown)
Line 1: Line 1:
require('Module:CommonFunctions')
require('Module:CommonFunctions')
require('Module:InfoboxProto');
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local p = {}
local p = {}
Line 6: Line 7:
function p.main(frame)
function p.main(frame)
     local args = getArgs(frame);
     local args = getArgs(frame);
    local infobox = require('Module:InfoboxProto').main(frame, args.class);
    infobox:addClass('infobox-character');


     if args.textcolor == nil then
     local fields = {
         args.textcolor = 'white';
        {
    else
            id = 'name',
         args.textcolor = 'black';
            localize = args.l_name,
     end
            dual = true
        },
        {
            id = 'class',
            localize = args.l_class
        },
         {
            id = 'classes',
            localize = args.l_classes,
            dual = true,
            special = true
        },
        {
            id = 'weapon',
            localize = args.l_weapon,
            dual = true
        },
        {
            id = 'age',
            localize = args.l_age,
            dual = true
        },
        {
            id = 'race',
            localize = args.l_race,
            dual = true
        },
        {
            id = 'Birth',
            localize = args.l_birth,
            dual = true
        },
        {
            id = 'Height',
            localize = args.l_height,
            dual = true
        },
        {
            id = 'Weight',
            localize = args.l_weight,
            dual = true
        },
        {
            id = 'Blood',
            localize = args.l_blood,
            dual = true
        },
        {
            id = 'ESP',
            localize = args.l_esp
        },
        {
            id = 'tree',
            localize = args.l_tree
        },
        {
            id = 'groups',
            localize = args.l_groups,
            collapsed = true,
            dual = true
        },
        {
            id = 'VA',
            localize = args.l_va,
            dual = true,
            collapsed = true
        },
        {
            id = 'RD',
            localize = args.l_rd,
            collapsed = true
        },
        {
            id = 'TRD',
            localize = args.l_trd,
            collapsed = true
        },
        {
            id = 'MRD',
            localize = args.l_mrd,
            collapsed = true
        },
        {
            id = 'theme',
            localize = args.l_theme
        },
         {
            id = 'video',
            localize = args.l_video
        },
        {
            id = 'stat',
            localize = args.l_stat
        }
     }


     if args.fullname == nil then
     addFields(fields);
        args.fullname = args.name;
    end
 
    local infobox = mw.html.create('div'):addClass('infobox-character');
    infobox:tag('div'):addClass('infobox-character-header'):css('background-color', args.color:gsub("%#", "#")):css(
        'color', args.textcolor):wikitext(args.class:gsub("%[%[a%]%]", ""));
    infobox:tag('div'):addClass('infobox-character-image'):wikitext(args.image);
 
    function addField(param, field_name)
        if args[param] ~= nil then
            local row = infobox:tag('div'):addClass('infobox-row');
            if field_name == nil then
                field_name = titleCase(param);
            end
            row:tag('div'):addClass('infobox-row-title'):wikitext(field_name);
            if (param == 'video' or param == 'tree' or param == 'stats') then
                row:tag('div'):addClass('infobox-row-content'):wikitext(args[param]);
            else
                row:tag('div'):addClass('infobox-row-content'):tag('span'):wikitext(args[param]);
            end
        end
    end
 
    function addField2(param, field_name)
        if args[param .. '1'] ~= nil and args[param .. '2'] ~= nil then
            local row = infobox:tag('div'):addClass('infobox-row'):addClass('infobox-double-row');
            if field_name == nil then
                field_name = titleCase(param):gsub("%d+", '');
            end
            row:tag('div'):addClass('infobox-row-title'):wikitext(field_name);
            row:tag('div'):addClass('infobox-row-content'):tag('span'):wikitext(args[param .. '1']);
            row:tag('div'):addClass('infobox-row-content'):tag('span'):wikitext(args[param .. '2']);
        end
    end
 
    addField('fullname', 'Full Name');
    addField2('fullname', 'Full Name');
    addField('class');
    addField2('classes', 'Classes');
    addField('weapon');
    addField2('weapon');
    addField('age');
    addField2('age');
    addField('race');
    addField2('race');
    addField('Birth', 'Birthday');
    addField2('Birth', 'Birthday');
    addField('Height');
    addField2('Height');
    addField('Weight');
    addField2('Weight');
    addField('Blood', 'Blood Type');
    addField2('Blood', 'Blood Type');
    addField('ESP', '[[El Search Party Collection|ESP Collection]]');
    addField('tree', 'Class Tree');
    addField('VA', 'Voice Actors');
    addField2('VA', 'Voice Actors');
    addField('RD', 'Release Date');
    addField('TRD', 'Transcendence Release Date');
    addField('MRD', 'Master Class Release Date');
    addField('theme');
    addField('video', 'Job Path Story Movie');
    addField('stat', 'Statistics');
      
      
     return frame:preprocess(tostring(infobox));
     return tostring(infobox);


end
end


return p
return p

Revision as of 21:13, 18 September 2023

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

require('Module:CommonFunctions')
require('Module:InfoboxProto');
local getArgs = require('Module:Arguments').getArgs
local p = {}

-- Main process
function p.main(frame)
    local args = getArgs(frame);
    local infobox = require('Module:InfoboxProto').main(frame, args.class);
    infobox:addClass('infobox-character');

    local fields = {
        {
            id = 'name',
            localize = args.l_name,
            dual = true
        },
        {
            id = 'class',
            localize = args.l_class
        },
        {
            id = 'classes',
            localize = args.l_classes,
            dual = true,
            special = true
        },
        {
            id = 'weapon',
            localize = args.l_weapon,
            dual = true
        },
        {
            id = 'age',
            localize = args.l_age,
            dual = true
        },
        {
            id = 'race',
            localize = args.l_race,
            dual = true
        },
        {
            id = 'Birth',
            localize = args.l_birth,
            dual = true
        },
        {
            id = 'Height',
            localize = args.l_height,
            dual = true
        },
        {
            id = 'Weight',
            localize = args.l_weight,
            dual = true
        },
        {
            id = 'Blood',
            localize = args.l_blood,
            dual = true
        },
        {
            id = 'ESP',
            localize = args.l_esp
        },
        {
            id = 'tree',
            localize = args.l_tree
        },
        {
            id = 'groups',
            localize = args.l_groups,
            collapsed = true,
            dual = true
        },
        {
            id = 'VA',
            localize = args.l_va,
            dual = true,
            collapsed = true
        },
        {
            id = 'RD',
            localize = args.l_rd,
            collapsed = true
        },
        {
            id = 'TRD',
            localize = args.l_trd,
            collapsed = true
        },
        {
            id = 'MRD',
            localize = args.l_mrd,
            collapsed = true
        },
        {
            id = 'theme',
            localize = args.l_theme
        },
        {
            id = 'video',
            localize = args.l_video
        },
        {
            id = 'stat',
            localize = args.l_stat
        }
    }

    addFields(fields);
    
    return tostring(infobox);

end

return p