Модуль:Песочница/Pok: различия между версиями

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


local lathe = nil
local lathe = nil
for _, data in ipairs(latheData) do
for _, data in pairs(latheData) do
if data.id == latheId then
if data.id == latheId then
lathe = data
lathe = data
Строка 86: Строка 86:


local function getRecipeDetails(recipeId)
local function getRecipeDetails(recipeId)
    for _, recipe in ipairs(recipeData) do
    for _, recipe in pairs(recipeData) do
        if recipe.id == recipeId then
        if recipe.id == recipeId then
            return recipe
            return recipe
Строка 95: Строка 95:


local function findInResearch(recipeId)
local function findInResearch(recipeId)
for _, research in ipairs(researchData) do
for _, research in pairs(researchData) do
if research.technology and research.technology.recipeUnlocks then
if research.technology and research.technology.recipeUnlocks then
for _, unlock in ipairs(research.technology.recipeUnlocks) do
for _, unlock in pairs(research.technology.recipeUnlocks) do
if unlock == recipeId then
if unlock == recipeId then
return {
return {
Строка 113: Строка 113:
-- Обработка staticRecipes
-- Обработка staticRecipes
if lathe.Lathe.staticRecipes then
if lathe.Lathe.staticRecipes then
for _, recipeId in ipairs(lathe.Lathe.staticRecipes) do
for _, recipeId in pairs(lathe.Lathe.staticRecipes) do
local recipe = getRecipeDetails(recipeId)
local recipe = getRecipeDetails(recipeId)
if recipe and recipe.result then
if recipe and recipe.result then
Строка 143: Строка 143:
-- Обработка dynamicRecipes
-- Обработка dynamicRecipes
if lathe.Lathe.dynamicRecipes then
if lathe.Lathe.dynamicRecipes then
for _, recipeId in ipairs(lathe.Lathe.dynamicRecipes) do
for _, recipeId in pairs(lathe.Lathe.dynamicRecipes) do
local recipe = getRecipeDetails(recipeId)
local recipe = getRecipeDetails(recipeId)
if recipe then
if recipe then
Строка 163: Строка 163:
-- Обработка emagStaticRecipes
-- Обработка emagStaticRecipes
if lathe.EmagLatheRecipes and lathe.EmagLatheRecipes.emagStaticRecipes then
if lathe.EmagLatheRecipes and lathe.EmagLatheRecipes.emagStaticRecipes then
for _, recipeId in ipairs(lathe.EmagLatheRecipes.emagStaticRecipes) do
for _, recipeId in pairs(lathe.EmagLatheRecipes.emagStaticRecipes) do
local recipe = getRecipeDetails(recipeId)
local recipe = getRecipeDetails(recipeId)
if recipe then
if recipe then
Строка 180: Строка 180:
-- Обработка emagDynamicRecipes  
-- Обработка emagDynamicRecipes  
if lathe.EmagLatheRecipes and lathe.EmagLatheRecipes.emagDynamicRecipes then
if lathe.EmagLatheRecipes and lathe.EmagLatheRecipes.emagDynamicRecipes then
for _, recipeId in ipairs(lathe.EmagLatheRecipes.emagDynamicRecipes) do
for _, recipeId in pairs(lathe.EmagLatheRecipes.emagDynamicRecipes) do
local recipe = getRecipeDetails(recipeId)
local recipe = getRecipeDetails(recipeId)
if recipe then
if recipe then
Строка 219: Строка 219:
local timeMultiplier = lathe.Lathe.timeMultiplier or 1
local timeMultiplier = lathe.Lathe.timeMultiplier or 1


for _, recipe in ipairs(recipes) do
for _, recipe in pairs(recipes) do
local scaledTime = format_seconds_to_short_string(recipe.completetime * timeMultiplier)
local scaledTime = format_seconds_to_short_string(recipe.completetime * timeMultiplier)
out = out .. '{{Шаблон:Prototypes/Машина/Станок|product=' .. recipe.result
out = out .. '{{Шаблон:Prototypes/Машина/Станок|product=' .. recipe.result