Модуль:Entity Sprite: различия между версиями

мНет описания правки
Нет описания правки
Строка 20: Строка 20:
     end
     end
      
      
     local result = ""
     local template = string.format(
   
        [[
    --result = result .. '<div class="entity-sprite__strings">'
== Краткое описание ==
   
{{Файл
    result = result .. '== Краткое описание ==/n'
|Описание =  
    result = result .. '{{Файл /n'
|Id      = %s
    result = result .. '|Описание = /n'
|Сервера  = {{abb|SS14}}
    result = result .. '|Id      = ' .. entry.id .. '/n'
|Источник =  
    result = result .. '|Сервера  = {{abb|SS14}}/n'
|Путь    = Resources/Textures/%s
    result = result .. '|Источник = /n'
|Теги    =  
    result = result .. '|Путь    = Resources/Textures/' .. entry.Sprite.sprite .. '/n'
}}
    result = result .. '|Теги    = /n'
 
    result = result .. '}}/n/n'
== Лицензирование ==
   
{{CC-BY-SA-3.0}}
    result = result .. '== Лицензирование ==/n'
]],
    result = result .. '{{CC-BY-SA-3.0}}/n'
        entry.id,
    --result = result .. '</div>'
        entry.Sprite.sprite
    )
      
      
    --result = result .. '<div class="copy-icon">📋</div>'
     return template
 
     return result
end
end


-- Основная функция модуля
-- Основная функция модуля
function p.main(frame)
function p.main(frame)
     local filePath = frame.args[1] -- Путь к JSON
     -- Загрузка данных из JSON-файла
    if not filePath then
     local data = loadData('User:IanComradeBot/prototypes/entity sprite.json')
        return "Ошибка: Укажите путь к JSON-файлу."
     if not data or type(data) ~= 'table' then
    end
         return 'Ошибка: Невозможно загрузить данные из JSON.'
   
     local data = loadData(filePath)
     if not data or type(data) ~= "table" then
         return "Ошибка: Невозможно загрузить данные из JSON."
     end
     end
      
      
    -- Создание результата
     local result = {}
     local result = {}
   
     for _, entry in ipairs(data) do
     for _, entry in ipairs(data) do
         local template = generateTemplate(entry)
         local template = generateTemplate(entry)
Строка 64: Строка 59:
     end
     end
      
      
     return table.concat(result, "\n")
    -- Возврат собранного результата
     return table.concat(result, '/n')
end
end


return p
return p