From b1c75900c97082c6be5db1b1394e59e31d0d2414 Mon Sep 17 00:00:00 2001 From: tn47 Date: Tue, 27 Dec 2022 14:36:20 +0100 Subject: [PATCH 1/8] added points for objects stored in objectStorage from GtX --- scripts/VictoryPointsUtil.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/VictoryPointsUtil.lua b/scripts/VictoryPointsUtil.lua index 66bf621..805d07b 100644 --- a/scripts/VictoryPointsUtil.lua +++ b/scripts/VictoryPointsUtil.lua @@ -36,6 +36,18 @@ function VictoryPointsUtil.getStorageAmount(farmId, maxFillLevel) end end + if g_isModLoaded.FS22_ObjectStorage then + local objectStorages = g_objectStorageManager:getStorages() + + for _, storage in pairs(objectStorages) do + for _, storageArea in pairs(storage.indexedStorageAreas) do + for _, objectAttributes in pairs(storageArea.objects) do + totalFillLevels[objectAttributes.fillType] = totalFillLevels[objectAttributes.fillType] + math.min(objectAttributes.fillLevel, maxFillLevel) + end + end + end + end + CmUtil.debug("Total storage of: %.2f", totalFillLevel ) return totalFillLevels end From b431c374b0a4c38db172830ad2a5be756f9af87f Mon Sep 17 00:00:00 2001 From: Tensuko Date: Wed, 4 Jan 2023 13:13:17 +0100 Subject: [PATCH 2/8] fixes the other max counted storage --- scripts/VictoryPointsUtil.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/VictoryPointsUtil.lua b/scripts/VictoryPointsUtil.lua index 66bf621..17e19d7 100644 --- a/scripts/VictoryPointsUtil.lua +++ b/scripts/VictoryPointsUtil.lua @@ -18,7 +18,7 @@ function VictoryPointsUtil.getStorageAmount(farmId, maxFillLevel) if totalFillLevels[fillType] == nil then totalFillLevels[fillType] = 0 end - totalFillLevels[fillType] = totalFillLevels[fillType] + math.min(v, maxFillLevel) + totalFillLevels[fillType] = math.min(totalFillLevels[fillType] + v, maxFillLevel) end end end @@ -32,7 +32,7 @@ function VictoryPointsUtil.getStorageAmount(farmId, maxFillLevel) if totalFillLevels[fillType] == nil then totalFillLevels[fillType] = 0 end - totalFillLevels[fillType] = totalFillLevels[fillType] + math.min(fillLevel, maxFillLevel) + totalFillLevels[fillType] = math.min(totalFillLevels[fillType] + fillLevel, maxFillLevel) end end @@ -58,7 +58,7 @@ function VictoryPointsUtil.getBaleAmount(farmId, maxFillLevel) if baleFillLevels[object.fillType] == nil then baleFillLevels[object.fillType] = 0 end - baleFillLevels[object.fillType] = baleFillLevels[object.fillType] + math.min(object.fillLevel, maxFillLevel) + baleFillLevels[object.fillType] = math.min(baleFillLevels[object.fillType] + object.fillLevel, maxFillLevel) end end return baleFillLevels @@ -77,7 +77,7 @@ function VictoryPointsUtil.getPalletAmount(farmId, maxFillLevel, totalFillLevels if totalFillLevels[fillType] == nil then totalFillLevels[fillType] = 0 end - totalFillLevels[fillType] = totalFillLevels[fillType] + math.min(fillLevel, maxFillLevel) + totalFillLevels[fillType] = math.min(totalFillLevels[fillType] + fillLevel, maxFillLevel) end end return totalFillLevels From 76908aabaf62db5c8c516d15124c3e7d25df2b66 Mon Sep 17 00:00:00 2001 From: Tim Nolle Date: Thu, 9 Feb 2023 15:06:17 +0100 Subject: [PATCH 3/8] added punishment for having loan --- ChallengeModConfig.xml | 1 + scripts/VictoryPointManager.lua | 6 ++++++ translations/translation_de.xml | 1 + translations/translation_en.xml | 1 + 4 files changed, 9 insertions(+) diff --git a/ChallengeModConfig.xml b/ChallengeModConfig.xml index 7cc9948..5130464 100644 --- a/ChallengeModConfig.xml +++ b/ChallengeModConfig.xml @@ -3,6 +3,7 @@ + diff --git a/scripts/VictoryPointManager.lua b/scripts/VictoryPointManager.lua index abb920f..734da66 100644 --- a/scripts/VictoryPointManager.lua +++ b/scripts/VictoryPointManager.lua @@ -180,6 +180,12 @@ function VictoryPointManager:addMoneyFactor(category, factorData, farmId) category:addElement(VictoryPoint.createFromXml(factorData, money)) end +function VictoryPointManager:addLoanFactor(category, factorData, farmId) + local farm = g_farmManager:getFarmById(farmId) + local loan = farm and farm.loan or 0 + category:addElement(VictoryPoint.createFromXml(factorData, loan)) +end + function VictoryPointManager:addAreaFactor(category, factorData, farmId) local area = VictoryPointsUtil.getTotalArea(farmId) category:addElement(VictoryPoint.createFromXml(factorData, area)) diff --git a/translations/translation_de.xml b/translations/translation_de.xml index d16beae..a0828bb 100644 --- a/translations/translation_de.xml +++ b/translations/translation_de.xml @@ -62,6 +62,7 @@ Eine Dauer von 0 Monaten deaktiviert das Zeitlimit." + diff --git a/translations/translation_en.xml b/translations/translation_en.xml index 6c5f372..e71da0e 100644 --- a/translations/translation_en.xml +++ b/translations/translation_en.xml @@ -61,6 +61,7 @@ A duration of 0 months will deactivate the time limit." + From 73ecd5f9bb5d49950d3651c086260bd81d5c7a00 Mon Sep 17 00:00:00 2001 From: Tim Nolle Date: Thu, 9 Feb 2023 15:15:27 +0100 Subject: [PATCH 4/8] prevent negative points for money --- scripts/VictoryPointManager.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/VictoryPointManager.lua b/scripts/VictoryPointManager.lua index 734da66..0b79b28 100644 --- a/scripts/VictoryPointManager.lua +++ b/scripts/VictoryPointManager.lua @@ -177,6 +177,8 @@ end function VictoryPointManager:addMoneyFactor(category, factorData, farmId) local farm = g_farmManager:getFarmById(farmId) local money = farm and farm.money - farm.loan or 0 + -- prevents negative points if loan is higher than money + money = math.max(money, 0) category:addElement(VictoryPoint.createFromXml(factorData, money)) end From 28828be7aa61366fd3602e3e9894fbcd8441c767 Mon Sep 17 00:00:00 2001 From: Tim Nolle Date: Thu, 9 Feb 2023 15:32:37 +0100 Subject: [PATCH 5/8] possible fix for getting points from loan --- ChallengeModConfig.xml | 2 +- scripts/VictoryPointManager.lua | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChallengeModConfig.xml b/ChallengeModConfig.xml index 5130464..0ee9995 100644 --- a/ChallengeModConfig.xml +++ b/ChallengeModConfig.xml @@ -3,7 +3,7 @@ - + diff --git a/scripts/VictoryPointManager.lua b/scripts/VictoryPointManager.lua index 0b79b28..038b1a3 100644 --- a/scripts/VictoryPointManager.lua +++ b/scripts/VictoryPointManager.lua @@ -185,6 +185,7 @@ end function VictoryPointManager:addLoanFactor(category, factorData, farmId) local farm = g_farmManager:getFarmById(farmId) local loan = farm and farm.loan or 0 + loan = -loan category:addElement(VictoryPoint.createFromXml(factorData, loan)) end From 4f8eea18cdd23e043d4a185394513b336f056e80 Mon Sep 17 00:00:00 2001 From: Tensuko Date: Thu, 9 Feb 2023 18:04:14 +0100 Subject: [PATCH 6/8] Add missing Translation --- translations/translation_de.xml | 2 +- translations/translation_en.xml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/translations/translation_de.xml b/translations/translation_de.xml index a0828bb..0053938 100644 --- a/translations/translation_de.xml +++ b/translations/translation_de.xml @@ -48,13 +48,13 @@ Eine Dauer von 0 Monaten deaktiviert das Zeitlimit." - + diff --git a/translations/translation_en.xml b/translations/translation_en.xml index e71da0e..1ca960b 100644 --- a/translations/translation_en.xml +++ b/translations/translation_en.xml @@ -54,6 +54,7 @@ A duration of 0 months will deactivate the time limit." + From 0590c27556d3ebd32811a9ea00172f480bc395e6 Mon Sep 17 00:00:00 2001 From: Tim Nolle Date: Mon, 13 Feb 2023 15:52:34 +0100 Subject: [PATCH 7/8] fixed limit calculation --- scripts/VictoryPointsUtil.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/VictoryPointsUtil.lua b/scripts/VictoryPointsUtil.lua index 16ab919..acc18e9 100644 --- a/scripts/VictoryPointsUtil.lua +++ b/scripts/VictoryPointsUtil.lua @@ -42,7 +42,7 @@ function VictoryPointsUtil.getStorageAmount(farmId, maxFillLevel) for _, storage in pairs(objectStorages) do for _, storageArea in pairs(storage.indexedStorageAreas) do for _, objectAttributes in pairs(storageArea.objects) do - totalFillLevels[objectAttributes.fillType] = totalFillLevels[objectAttributes.fillType] + math.min(objectAttributes.fillLevel, maxFillLevel) + totalFillLevels[objectAttributes.fillType] = math.min(totalFillLevels[objectAttributes.fillType] + objectAttributes.fillLevel, maxFillLevel) end end end From d27c8118ef77e6242ed98716642d631a779482bf Mon Sep 17 00:00:00 2001 From: Tim Nolle Date: Sun, 26 Feb 2023 18:36:06 +0100 Subject: [PATCH 8/8] added owner check --- scripts/VictoryPointsUtil.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/VictoryPointsUtil.lua b/scripts/VictoryPointsUtil.lua index acc18e9..b6fcd67 100644 --- a/scripts/VictoryPointsUtil.lua +++ b/scripts/VictoryPointsUtil.lua @@ -40,9 +40,11 @@ function VictoryPointsUtil.getStorageAmount(farmId, maxFillLevel) local objectStorages = g_objectStorageManager:getStorages() for _, storage in pairs(objectStorages) do - for _, storageArea in pairs(storage.indexedStorageAreas) do - for _, objectAttributes in pairs(storageArea.objects) do - totalFillLevels[objectAttributes.fillType] = math.min(totalFillLevels[objectAttributes.fillType] + objectAttributes.fillLevel, maxFillLevel) + if storage.ownerFarmId == farmId then + for _, storageArea in pairs(storage.indexedStorageAreas) do + for _, objectAttributes in pairs(storageArea.objects) do + totalFillLevels[objectAttributes.fillType] = math.min(totalFillLevels[objectAttributes.fillType] + objectAttributes.fillLevel, maxFillLevel) + end end end end