|
|
| Ligne 8 : |
Ligne 8 : |
| local PageName = frame.args[1] | | local PageName = frame.args[1] |
| | | |
| -- Normaliser les apostrophes dans le nom de la page | | -- Débogage : afficher les codes des caractères |
| PageName = Utils.NormalizeApostrophes(PageName) | | local DebugInfo = 'PageName : "' .. PageName .. '"<br>' |
| | DebugInfo = DebugInfo .. 'Codes bytes : ' |
| | for i = 1, #PageName do |
| | DebugInfo = DebugInfo .. string.byte(PageName, i) .. ' ' |
| | end |
| | DebugInfo = DebugInfo .. '<br><br>' |
| | |
| | -- Afficher aussi ce qu'on cherche |
| | local ExpectedName = "Lingot d'or" |
| | DebugInfo = DebugInfo .. 'Expected : "' .. ExpectedName .. '"<br>' |
| | DebugInfo = DebugInfo .. 'Codes bytes expected : ' |
| | for i = 1, #ExpectedName do |
| | DebugInfo = DebugInfo .. string.byte(ExpectedName, i) .. ' ' |
| | end |
| | DebugInfo = DebugInfo .. '<br><br>' |
| | | |
| local ItemName | | local ItemName |
| | local Lang = Utils.getLanguageName() |
| | | |
| if (Lang == 'English') then | | if (Lang == 'English') then |
| Ligne 19 : |
Ligne 34 : |
| end | | end |
| | | |
| -- Vérifier si ItemName existe | | DebugInfo = DebugInfo .. 'ItemName trouvé : "' .. (ItemName or "nil") .. '"<br>' |
| if not ItemName or ItemName == "" or ItemName == "None" then
| |
| return '<div class="alert alert-danger">Erreur : Impossible de trouver l\'objet "' .. PageName .. '"</div>'
| |
| end
| |
|
| |
| local ItemData = require("Module:ItemData")
| |
| local Item = ItemData.items[ItemName]
| |
|
| |
| -- Vérifier si Item existe
| |
| if not Item then
| |
| return '<div class="alert alert-danger">Erreur : L\'objet "' .. ItemName .. '" n\'existe pas dans ItemData</div>'
| |
| end
| |
|
| |
| local WikiText = ''
| |
|
| |
| WikiText = WikiText .. '__NOTOC__'
| |
| WikiText = WikiText .. 'Nom de page : ' .. PageName .. '</br>'
| |
| WikiText = WikiText .. 'Nom d\'objet trouvé : ' .. ItemName .. '</br>'
| |
|
| |
| WikiText = WikiText .. '<div class="row gy-4 gx-5"><div class="col-md-6">'
| |
|
| |
| WikiText = WikiText .. '</div>'
| |
| WikiText = WikiText .. '<div class="col-md-6"><div class="card border-primary"><div class="card-body">'
| |
| WikiText = WikiText .. '<h2 class="card-title fs-40">' .. IconUtils.main{name = Item.Name[Lang], id = Item.ID , size = 48, style = 1} .. ' ' .. Item.Name[Lang] .. '</h2>'
| |
| WikiText = WikiText .. '<p class="col-lg-10 card-text">' .. Item.Description[Lang] .. '</p>'
| |
|
| |
| WikiText = WikiText .. '</div></div></div></div>'
| |
|
| |
| local RecipeItemCraft = RecipeUtils.ItemCraft(ItemName)
| |
| if (RecipeItemCraft ~= "") then
| |
| WikiText = WikiText .. '<h3>' .. Utils.Translate("Crafted At") .. ' :</h3>'
| |
| WikiText = WikiText .. RecipeUtils.CraftTable(RecipeItemCraft)
| |
| end
| |
|
| |
| local RecipeItemIngredient = RecipeUtils.ItemIngredient(ItemName)
| |
| if (RecipeItemIngredient ~= "") then
| |
| WikiText = WikiText .. '<h3>' .. Utils.Translate("Used in") .. ' :</h3>'
| |
| WikiText = WikiText .. RecipeUtils.CraftTable(RecipeItemIngredient)
| |
| end
| |
|
| |
| local ItemTagList = Utils.ItemTags(Item.Tags)
| |
| if (ItemTagList ~= "") then
| |
| WikiText = WikiText .. '<h3>' .. Utils.Translate("Tags Applying to") .. ' :</h3>'
| |
| WikiText = WikiText .. ItemTagList
| |
| end
| |
|
| |
| local RecipeTagsIngredient = RecipeUtils.TagsIngredient(Item.Tags)
| |
| if (RecipeTagsIngredient ~= "") then
| |
| WikiText = WikiText .. '<h3>Utilisé comme objet étiquette dans :</h3>'
| |
| WikiText = WikiText .. RecipeUtils.CraftTable(RecipeTagsIngredient)
| |
| end
| |
|
| |
| WikiText = WikiText .. '<h3>Utilisation de l\'icône :</h3>'
| |
| WikiText = WikiText .. '<p>L\'icône de ' .. Item.Name[Lang] .. ' peut être utilisée sur n\'importe quel panneau supportant du texte, y compris sur les [[Vehicules|Véhicules]] :</br>'
| |
| WikiText = WikiText .. 'Icône avec fond : <icon name="' .. Item.ID .. '"></br>'
| |
| WikiText = WikiText .. 'Icône sans fond : <icon name="' .. Item.ID .. '" type="nobg"></p>'
| |
|
| |
| if (Lang ~= 'English') then WikiText = WikiText .. '[[en:' .. Item.Name.English .. ']]' end
| |
| if (Lang ~= 'Russian') then WikiText = WikiText .. '[[ru:' .. Item.Name.Russian .. ']]' end
| |
| if (Lang ~= 'German') then WikiText = WikiText .. '[[de:' .. Item.Name.German .. ']]' end
| |
| if (Lang ~= 'French') then WikiText = WikiText .. '[[fr:' .. Item.Name.French .. ']]' end
| |
| | | |
| return WikiText | | return '<div class="alert alert-info">' .. DebugInfo .. '</div>' |
| end | | end |
|
| |
|
| return p | | return p |
La documentation pour ce module peut être créée à Module:ItemInfoCard/doc
local p = {}
local Utils = require('Module:Utils')
local RecipeUtils = require('Module:RecipeUtils')
local IconUtils = require('Module:IconUtils')
local Lang = Utils.getLanguageName()
function p.main(frame)
local PageName = frame.args[1]
-- Débogage : afficher les codes des caractères
local DebugInfo = 'PageName : "' .. PageName .. '"<br>'
DebugInfo = DebugInfo .. 'Codes bytes : '
for i = 1, #PageName do
DebugInfo = DebugInfo .. string.byte(PageName, i) .. ' '
end
DebugInfo = DebugInfo .. '<br><br>'
-- Afficher aussi ce qu'on cherche
local ExpectedName = "Lingot d'or"
DebugInfo = DebugInfo .. 'Expected : "' .. ExpectedName .. '"<br>'
DebugInfo = DebugInfo .. 'Codes bytes expected : '
for i = 1, #ExpectedName do
DebugInfo = DebugInfo .. string.byte(ExpectedName, i) .. ' '
end
DebugInfo = DebugInfo .. '<br><br>'
local ItemName
local Lang = Utils.getLanguageName()
if (Lang == 'English') then
ItemName = PageName
else
ItemName = Utils.ItemSearch(PageName)
end
DebugInfo = DebugInfo .. 'ItemName trouvé : "' .. (ItemName or "nil") .. '"<br>'
return '<div class="alert alert-info">' .. DebugInfo .. '</div>'
end
return p