diff --git a/hot-metals/prototypes/hot-metals.lua b/hot-metals/prototypes/hot-metals.lua index 03e55e3..e072372 100644 --- a/hot-metals/prototypes/hot-metals.lua +++ b/hot-metals/prototypes/hot-metals.lua @@ -1,52 +1,5 @@ local defaultSpoilTicks = settings.startup["hot-metals-time"].value * 60 ----@param name data.ItemID ----@return data.ItemPrototype? -function getItem(name) - if data.raw.item[name] then - return data.raw.item[name] --[[@as data.ItemPrototype]] - end - for item_type in pairs(defines.prototypes.item) do - local type_lookup = data.raw[item_type] - if type_lookup and type_lookup[name] then - return type_lookup[name] --[[@as data.ItemPrototype]] - end - end -end - ----@param table item ----@return number -function getWeight(item) - if type(item) == "string" then - item = getItem(item) - end - if item.weight then return item.weight end - local factor = item.ingredient_to_weight_coefficient or 0.5 - for _, recipe in pairs(data.raw.recipe) do - if recipe.results == nil then - goto continue - end - local function isResultMatch(result) - return result.name == item.name - end - local results = table.filter(recipe.results, isResultMatch) - if #results > 0 then - for _, ingredient in pairs(recipe.ingredients) do - if ingredient.type == "item" then - local weight = data.raw.item[ingredient.name].weight or getWeight(data.raw.item[ingredient.name]) - local amount = ingredient.amount - if ingredient.amount_min and ingredient.amount_max then - amount = (ingredient.amount_min + ingredient.amount_max) / 2 - end - return amount * weight * factor - end - end - end - ::continue:: - end - return 100 -end - function createHotVariant(config) local itemName = config local spoilTicks = defaultSpoilTicks @@ -58,7 +11,7 @@ function createHotVariant(config) iconFolder = config.iconFolder or iconFolder end local item = data.raw.item[itemName] - item.weight = getWeight(item) + item.weight = item.weight or 10000 -- Create new item local hotItem = table.deepcopy(data.raw.item[itemName])