From 2cd53c60d8164c3ff193f6f4beb80f211cde53ee Mon Sep 17 00:00:00 2001 From: Brevven Date: Mon, 14 Jun 2021 23:50:06 -0700 Subject: [PATCH] fix k2 realistic weapons off --- changelog.txt | 5 +++++ info.json | 2 +- tungsten-util.lua | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/changelog.txt b/changelog.txt index 3753c1a..b3716a8 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ --------------------------------------------------------------------------------------------------- +Version: 0.1.5 +Date: 2021-06-15 + Fixes: + - Fix K2 Issue when more realistic weapons is off, and more general duplicate fix. +--------------------------------------------------------------------------------------------------- Version: 0.1.4 Date: 2021-06-15 Features: diff --git a/info.json b/info.json index 8ab4f6f..24c22c3 100644 --- a/info.json +++ b/info.json @@ -1,6 +1,6 @@ { "name": "bztungsten", - "version": "0.1.4", + "version": "0.1.5", "factorio_version": "1.1", "title": "Tungsten", "author": "Brevven", diff --git a/tungsten-util.lua b/tungsten-util.lua index 4ee501e..ebcc475 100644 --- a/tungsten-util.lua +++ b/tungsten-util.lua @@ -96,6 +96,12 @@ end function add_ingredient(recipe, ingredient, quantity) if recipe ~= nil and recipe.ingredients ~= nil then + for i, existing in pairs(recipe.ingredients) do + if existing[1] == ingredient or existing.name == ingredient then + log("Not adding "..ingredient.." -- duplicate") + return + end + end table.insert(recipe.ingredients, {ingredient, quantity}) end end @@ -127,6 +133,12 @@ end function replace_ingredient(recipe, old, new) if recipe ~= nil and recipe.ingredients ~= nil then + for i, existing in pairs(recipe.ingredients) do + if existing[1] == new or existing.name == new then + log("Not adding "..new.." -- duplicate") + return + end + end for i, ingredient in pairs(recipe.ingredients) do if ingredient.name == old then ingredient.name = new end if ingredient[1] == old then ingredient[1] = new end @@ -170,6 +182,12 @@ end function replace_some_ingredient(recipe, old, old_amount, new, new_amount) if recipe ~= nil and recipe.ingredients ~= nil then + for i, existing in pairs(recipe.ingredients) do + if existing[1] == new or existing.name == new then + log("Not adding "..new.." -- duplicate") + return + end + end for i, ingredient in pairs(recipe.ingredients) do -- For final fixes if ingredient.name == old then