Модуль:Prototypes/Машина/Станок: различия между версиями

мНет описания правки
мНет описания правки
Строка 63: Строка 63:


function p.main(frame)
function p.main(frame)
-- Подключение CSS
local cssLink = frame:extensionTag('templatestyles', '', {
src = 'Шаблон:Research/styles.css'
})
     local latheId = frame.args[1] or ""
     local latheId = frame.args[1] or ""
     if latheId == "" then
     if latheId == "" then
Строка 90: Строка 95:
     end
     end


     local output = ''
     local out = cssLink
     local recipes = {}
     local recipes = {}


Строка 132: Строка 137:
            })
            })
        else
        else
            output = output .. '<div style="color:red;">Ошибка: Рецепт с ID "' .. recipeId .. '" не найден или поле result отсутствует.</div>'
            out = out .. '<div style="color:red;">Ошибка: Рецепт с ID "' .. recipeId .. '" не найден или поле result отсутствует.</div>'
        end
        end
    end
    end
Строка 222: Строка 227:


     for _, recipe in ipairs(recipes) do
     for _, recipe in ipairs(recipes) do
         output = output .. '{{Шаблон:Prototypes/Машина/Станок|product=' .. recipe.result
         out = out .. '{{Шаблон:Prototypes/Машина/Станок|product=' .. recipe.result
         output = output .. '|complete-time=' .. format_seconds_to_short_string(recipe.completetime)
         out = out .. '|complete-time=' .. format_seconds_to_short_string(recipe.completetime)
         output = output .. '|materials='
         out = out .. '|materials='


         if next(recipe.materials) then
         if next(recipe.materials) then
Строка 230: Строка 235:
                 local stackEntity = materialMapping[material] or material
                 local stackEntity = materialMapping[material] or material
                 local scaledAmount = amount / 100
                 local scaledAmount = amount / 100
                 output = output .. '<b>[[File:' .. stackEntity .. '.png|32x32px|link=]] ' .. scaledAmount .. ' {{#invoke:Entity Lookup|getname|' .. stackEntity .. '}}</b>'
                 out = out .. '<b>[[File:' .. stackEntity .. '.png|32x32px|link=]] ' .. scaledAmount .. ' {{#invoke:Entity Lookup|getname|' .. stackEntity .. '}}</b>'
             end
             end
         else
         else
             output = output .. 'Нет данных о материалах'
             out = out .. 'Нет данных о материалах'
         end
         end
          
          
Строка 240: Строка 245:
         local tierColor = tierColors[recipe.tier] or "#FFFFFF"
         local tierColor = tierColors[recipe.tier] or "#FFFFFF"
        
        
             output = output .. '|info=<div>[[File:' .. recipe.discipline .. '.png|16x16px|link=]] [[Руководство по исследованию и разработке|{{#invoke:Ftl|main|translation|' .. recipe.researchName
             out = out .. '|info=<div>[[File:' .. recipe.discipline .. '.png|16x16px|link=]] [[Руководство по исследованию и разработке|{{#invoke:Ftl|main|translation|' .. recipe.researchName
             output = output .. '}}]], уровень: <span style="color: ' .. tierColor .. '">' .. recipe.tier .. '</span> </div>'
             out = out .. '}}]], уровень: <span style="color: ' .. tierColor .. '">' .. recipe.tier .. '</span> </div>'
         end
         end
          
          
         -- При взломе EMAG
         -- При взломе EMAG
         if recipe.isEmag then
         if recipe.isEmag then
             output = output .. '|mode-emag=1'
             out = out .. '|mode-emag=1'
         end
         end
          
          
Строка 259: Строка 264:
end
end
output = output .. '|icons=' .. icon
out = out .. '|icons=' .. icon


output = output .. '}}'
out = out .. '}}'
     end
     end


     return mw.getCurrentFrame():preprocess(output)
     return mw.getCurrentFrame():preprocess(out)
end
end


return p
return p