Basculer le menu
Changer de menu des préférences
Basculer le menu personnel
Non connecté(e)
Votre adresse IP sera visible au public si vous faites des modifications.

« Module:Infobox/Configs » : différence entre les versions

De Nefald
Hiob (discussion | contributions)
Page créée avec « return { edifice = { title = "Edifice", headerColor = "#D2691E", -- Couleur construction headerClass = "edifice", fields = { {key = "auteur", label = "Auteur"}, {key = "fonction", label = "Fonction", optional = true}, {key = "monde", label = "Monde", format = "link", optional = true}, {key = "ville", label = "Ville", format = "link", optional = true}, {key = "guilde",... »
Balises : Modification par mobile Modification par le web mobile
 
Hiob (discussion | contributions)
mAucun résumé des modifications
 
(20 versions intermédiaires par 2 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
return {
local configs = {}
    edifice = {
        title = "Edifice",
        headerColor = "#D2691E", -- Couleur construction
        headerClass = "edifice",
        fields = {
            {key = "auteur", label = "Auteur"},
            {key = "fonction", label = "Fonction", optional = true},
            {key = "monde", label = "Monde", format = "link", optional = true},
            {key = "ville", label = "Ville", format = "link", optional = true},
            {key = "guilde", label = "Guilde", format = "link", optional = true},
            {key = "x", label = "X", optional = true},
            {key = "y", label = "Y", optional = true},
            {key = "z", label = "Z", optional = true}
        },
        sections = {
            {title = "Définition", fields = {"auteur", "fonction"}},
            {title = "Géographie", fields = {"monde", "ville", "guilde", "coordonnees"}}
        }
    },


     monde = {
-- Charge dynamiquement les configurations depuis les sous-pages
        title = "Monde",
local function loadConfig(configName)
        headerColor = "#86C705",
     local success, config = pcall(require, 'Module:Infobox/Configs/' .. configName)
        headerClass = "monde",
    if success then
         fields = {
         return config
            {key = "seed", label = "Seed", format = "seed"},
    else
            {key = "type", label = "Type"},
         -- Fallback en cas d'erreur
            {key = "status", label = "Status", optional = true},
         mw.log('Erreur lors du chargement de la configuration: ' .. configName)
            {key = "difficulte", label = "Difficulté", optional = true},
         return nil
            {key = "x", label = "X", optional = true},
     end
            {key = "y", label = "Y", optional = true},
end
            {key = "z", label = "Z", optional = true},
            {key = "monde", label = "Monde", optional = true}
         },
         sections = {
            {title = "Spécificités", fields = {"seed", "type", "spawn"}},
            {title = "Autres infos", fields = {"status", "difficulte"}}
         }
     },


    ville = {
-- Charge toutes les configurations disponibles (manuellement)
        title = "Ville",
configs.localite = loadConfig('Localite')
        headerColor = "#20B2AA", -- Couleur ville (à définir selon votre CSS)
configs.monde = loadConfig('Monde')
        headerClass = "ville",
configs.plugin = loadConfig('Plugin')  
        fields = {
 
            {key = "fondation", label = "Fondation"},
-- Fonction pour ajouter dynamiquement d'autres configurations (automatiquement)
            {key = "bourgmestre", label = "Bourgmestre"},
function configs.load(configName)
            {key = "guilde", label = "Guilde(s)", optional = true},
    if not configs[configName:lower()] then
            {key = "spec", label = "Spécificité(s)"},
         configs[configName:lower()] = loadConfig(configName)
            {key = "projet", label = "Projet", optional = true},
    end
            {key = "production", label = "Production", optional = true},
    return configs[configName:lower()]
            {key = "commerce", label = "Liens commerciaux", optional = true},
end
            {key = "monde", label = "Monde", format = "link", optional = true},
 
            {key = "region", label = "Région(s)", optional = true},
return configs
            {key = "biome", label = "Biome(s)", optional = true},
            {key = "x", label = "X", optional = true},
            {key = "y", label = "Y", optional = true},
            {key = "z", label = "Z", optional = true},
            {key = "carte", label = "Carte", optional = true},
            {key = "taillecarte", label = "Taille carte", optional = true}
         },
        sections = {
            {title = "Informations générales", fields = {"fondation", "bourgmestre", "guilde", "spec", "projet"}},
            {title = "Économie", fields = {"production", "commerce"}},
            {title = "Géographie", fields = {"carte", "monde", "region", "coordonnees", "biome"}}
        }
    }
}

Dernière version du 1 octobre 2025 à 12:50

La documentation pour ce module peut être créée à Module:Infobox/Configs/doc

local configs = {}

-- Charge dynamiquement les configurations depuis les sous-pages
local function loadConfig(configName)
    local success, config = pcall(require, 'Module:Infobox/Configs/' .. configName)
    if success then
        return config
    else
        -- Fallback en cas d'erreur
        mw.log('Erreur lors du chargement de la configuration: ' .. configName)
        return nil
    end
end

-- Charge toutes les configurations disponibles (manuellement)
configs.localite = loadConfig('Localite')
configs.monde = loadConfig('Monde')
configs.plugin = loadConfig('Plugin') 

-- Fonction pour ajouter dynamiquement d'autres configurations (automatiquement)
function configs.load(configName)
    if not configs[configName:lower()] then
        configs[configName:lower()] = loadConfig(configName)
    end
    return configs[configName:lower()]
end

return configs