From 4255e2d9f8ee5fcb7c3c544f46381d8f7fb0b6bc Mon Sep 17 00:00:00 2001 From: Brevven Date: Mon, 10 Apr 2023 00:21:58 -0700 Subject: [PATCH] up --- control-util.lua | 6 +++++ data-util.lua | 68 ++++++++++++++++++++++++++++-------------------- 2 files changed, 46 insertions(+), 28 deletions(-) diff --git a/control-util.lua b/control-util.lua index 968b924..cd2b0f2 100644 --- a/control-util.lua +++ b/control-util.lua @@ -20,4 +20,10 @@ function util.get_list() end end +function util.force_enable_recipe(event, recipe_name) + if game.players[event.player_index].force.recipes[recipe_name] then + game.players[event.player_index].force.recipes[recipe_name].enabled=true + end +end + return util diff --git a/data-util.lua b/data-util.lua index 68cc881..6b923b4 100644 --- a/data-util.lua +++ b/data-util.lua @@ -130,33 +130,35 @@ function util.k2matter(params) if not params.k2matter.minimum_conversion_quantity then params.k2matter.minimum_conversion_quantity = 10 end - data:extend( - { + if not data.raw.technology[params.k2matter.unlocked_by_technology] then + data:extend( { - type = "technology", - name = params.k2matter.unlocked_by_technology, - icons = { + type = "technology", + name = params.k2matter.unlocked_by_technology, + icons = { - icon = util.k2assets().."/technologies/matter-"..params.k2baseicon..".png", - icon_size = 256, + { + icon = util.k2assets().."/technologies/matter-"..params.k2baseicon..".png", + icon_size = 256, + }, + params.icon, }, - params.icon, + prerequisites = {"kr-matter-processing"}, + unit = + { + count = 350, + ingredients = + { + {"production-science-pack", 1}, + {"utility-science-pack", 1}, + {"matter-tech-card", 1} + }, + time = 45, + } }, - prerequisites = {"kr-matter-processing"}, - unit = - { - count = 350, - ingredients = - { - {"production-science-pack", 1}, - {"utility-science-pack", 1}, - {"matter-tech-card", 1} - }, - time = 45, - } - }, - }) + }) + end matter.createMatterRecipe(params.k2matter) end @@ -533,13 +535,16 @@ end function add_product(recipe, product) if recipe ~= nil then - if not recipe.normal then - if recipe.results == nil then - recipe.results = {{recipe.result, recipe.result_count and recipe.result_count or 1}} + if (product[1] and data.raw.item[product[1]]) or + (product.name and data.raw[product.type][product.name]) then + if not recipe.normal then + if recipe.results == nil then + recipe.results = {{recipe.result, recipe.result_count and recipe.result_count or 1}} + end + recipe.result = nil + recipe.result_count = nil + table.insert(recipe.results, product) end - recipe.result = nil - recipe.result_count = nil - table.insert(recipe.results, product) end end end @@ -1045,6 +1050,13 @@ function util.add_icon(recipe_name, icon, options) icon_size=data.raw.item[data.raw.recipe[recipe_name].result].icon_size, icon_mipmaps=data.raw.item[data.raw.recipe[recipe_name].result].icon_mipmaps, }} + elseif data.raw.recipe[recipe_name].normal and + data.raw.item[data.raw.recipe[recipe_name].normal.result] then + data.raw.recipe[recipe_name].icons = {{ + icon=data.raw.item[data.raw.recipe[recipe_name].normal.result].icon, + icon_size=data.raw.item[data.raw.recipe[recipe_name].normal.result].icon_size, + icon_mipmaps=data.raw.item[data.raw.recipe[recipe_name].normal.result].icon_mipmaps, + }} end data.raw.recipe[recipe_name].icon = nil data.raw.recipe[recipe_name].icon_size = nil