From 8bcac1da00a96a99521e3d35f98b86625ab9be23 Mon Sep 17 00:00:00 2001 From: Mmtrx Date: Wed, 18 Jan 2023 16:51:11 +0100 Subject: [PATCH] v1.2.6.5 add setting "toDeliver": harvest contract success factor --- betterContracts.lua | 9 +++++++++ l10n/l10n_br.xml | 3 +++ l10n/l10n_cs.xml | 3 +++ l10n/l10n_cz.xml | 3 +++ l10n/l10n_de.xml | 2 ++ l10n/l10n_en.xml | 2 ++ l10n/l10n_fr.xml | 3 +++ l10n/l10n_it.xml | 3 +++ l10n/l10n_jp.xml | 3 +++ l10n/l10n_pl.xml | 3 +++ l10n/l10n_ru.xml | 3 +++ modDesc.xml | 2 +- scripts/settings.lua | 20 ++++++++++++++++++-- 13 files changed, 56 insertions(+), 3 deletions(-) diff --git a/betterContracts.lua b/betterContracts.lua index 9a354bc..bbaed1b 100644 --- a/betterContracts.lua +++ b/betterContracts.lua @@ -37,6 +37,8 @@ -- v1.2.6.1 05.12.2022 initGui(): utf8ToUpper(). Addtnl l10n translations from github -- v1.2.6.2 16.12.2022 don't act onFarmlandStateChanged() before mission started. Smaller menu icon -- v1.2.6.3 02.01.2023 onClickBuyFarmland, missionVehicles (userdefined) fixed +-- v1.2.6.4 17.01.2023 fix issue #88: onClickBuyFarmland() if discountMode off +-- v1.2.6.5 18.01.2023 add setting "toDeliver": harvest contract success factor --======================================================================================================= SC = { FERTILIZER = 1, -- prices index @@ -173,6 +175,7 @@ function registerXML(self) self.xmlSchema:register(XMLValueType.INT, self.baseXmlKey.."#refreshMP") self.xmlSchema:register(XMLValueType.FLOAT, self.baseXmlKey.."#reward") self.xmlSchema:register(XMLValueType.FLOAT, self.baseXmlKey.."#lease") + self.xmlSchema:register(XMLValueType.FLOAT, self.baseXmlKey.."#deliver") local key = self.baseXmlKey..".lazyNPC" self.xmlSchema:register(XMLValueType.BOOL, key.."#harvest") @@ -204,6 +207,7 @@ function readconfig(self) self.config.maxActive = xmlFile:getValue(key.."#maxActive", 3) self.config.multReward= xmlFile:getValue(key.."#reward", 1.) self.config.multLease = xmlFile:getValue(key.."#lease", 1.) + self.config.toDeliver = xmlFile:getValue(key.."#deliver", 0.93) self.config.refreshMP = xmlFile:getValue(key.."#refreshMP", 2) self.config.lazyNPC = xmlFile:getValue(key.."#lazyNPC", false) self.config.hardMode = xmlFile:getValue(key.."#hard", false) @@ -380,6 +384,7 @@ function BetterContracts:initialize() maxActive = 3, -- max active contracts multReward = 1., -- general reward multiplier multLease = 1., -- general lease cost multiplier + toDeliver = 0.93, -- HarvestMission.SUCCESS_FACTOR refreshMP = SC.ADMIN, -- necessary permission to refresh contract list (MP) lazyNPC = false, -- adjust NPC field work activity hardMode = false, -- penalty for canceled missions @@ -534,6 +539,9 @@ function BetterContracts:onPostLoadMap(mapNode, mapFile) addConsoleCommand("gsMissionHarvestField", "Harvest a field and print the liters", "consoleHarvestField", g_missionManager) addConsoleCommand("gsMissionTestHarvests", "Run an expansive tests for harvest missions", "consoleHarvestTests", g_missionManager) end + -- init HarvestMission.SUCCESS_FACTOR + HarvestMission.SUCCESS_FACTOR = self.config.toDeliver + -- adjust max missions local fieldsAmount = table.size(g_fieldManager.fields) local adjustedFieldsAmount = math.max(fieldsAmount, 45) @@ -587,6 +595,7 @@ function BetterContracts:onPostSaveSavegame(saveDir, savegameIndex) xmlFile:setInt ( key.."#maxActive",conf.maxActive) xmlFile:setFloat( key.."#reward", conf.multReward) xmlFile:setFloat( key.."#lease", conf.multLease) + xmlFile:setFloat( key.."#deliver", conf.toDeliver) xmlFile:setInt ( key.."#refreshMP",conf.refreshMP) xmlFile:setBool ( key.."#lazyNPC", conf.lazyNPC) xmlFile:setBool ( key.."#discount", conf.discountMode) diff --git a/l10n/l10n_br.xml b/l10n/l10n_br.xml index 1f651c7..4f37cab 100644 --- a/l10n/l10n_br.xml +++ b/l10n/l10n_br.xml @@ -94,5 +94,8 @@ + + + diff --git a/l10n/l10n_cs.xml b/l10n/l10n_cs.xml index 5e74101..f4e3a21 100644 --- a/l10n/l10n_cs.xml +++ b/l10n/l10n_cs.xml @@ -96,5 +96,8 @@ + + + diff --git a/l10n/l10n_cz.xml b/l10n/l10n_cz.xml index 132277d..f4a2e82 100644 --- a/l10n/l10n_cz.xml +++ b/l10n/l10n_cz.xml @@ -95,5 +95,8 @@ + + + diff --git a/l10n/l10n_de.xml b/l10n/l10n_de.xml index d8d0b15..bf76b7c 100644 --- a/l10n/l10n_de.xml +++ b/l10n/l10n_de.xml @@ -64,6 +64,8 @@ + + diff --git a/l10n/l10n_en.xml b/l10n/l10n_en.xml index 498ccee..5bebfb7 100644 --- a/l10n/l10n_en.xml +++ b/l10n/l10n_en.xml @@ -64,6 +64,8 @@ + + diff --git a/l10n/l10n_fr.xml b/l10n/l10n_fr.xml index ee4efc3..90147da 100644 --- a/l10n/l10n_fr.xml +++ b/l10n/l10n_fr.xml @@ -95,5 +95,8 @@ + + + diff --git a/l10n/l10n_it.xml b/l10n/l10n_it.xml index bd367c6..3e2e963 100644 --- a/l10n/l10n_it.xml +++ b/l10n/l10n_it.xml @@ -95,5 +95,8 @@ + + + diff --git a/l10n/l10n_jp.xml b/l10n/l10n_jp.xml index 394bd15..92af5d0 100644 --- a/l10n/l10n_jp.xml +++ b/l10n/l10n_jp.xml @@ -95,5 +95,8 @@ + + + diff --git a/l10n/l10n_pl.xml b/l10n/l10n_pl.xml index 6cc5db9..449a6fc 100644 --- a/l10n/l10n_pl.xml +++ b/l10n/l10n_pl.xml @@ -95,5 +95,8 @@ + + + diff --git a/l10n/l10n_ru.xml b/l10n/l10n_ru.xml index bb9954f..418a298 100644 --- a/l10n/l10n_ru.xml +++ b/l10n/l10n_ru.xml @@ -94,5 +94,8 @@ + + + diff --git a/modDesc.xml b/modDesc.xml index 879d2d7..fcf6b32 100644 --- a/modDesc.xml +++ b/modDesc.xml @@ -1,7 +1,7 @@  Mmtrx - 1.2.6.4 + 1.2.6.5 <en>Better Contracts</en> diff --git a/scripts/settings.lua b/scripts/settings.lua index ad3a3e9..ccec8d0 100644 --- a/scripts/settings.lua +++ b/scripts/settings.lua @@ -5,6 +5,7 @@ -- Author: Mmtrx -- Changelog: -- v1.2.6.0 30.11.2022 UI for all settings +-- v1.2.6.5 18.01.2023 add setting "toDeliver": harvest contract success factor --======================================================================================================= local function lazyNPCDisabled() return not BetterContracts.config.lazyNPC @@ -39,9 +40,20 @@ BCSettingsBySubtitle = { {name = "maxActive", values = {0,1,2, 3, 4, 5, 6, 7, 8, 9, 10}, texts = {"unlimited", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10"}, - default = 4, + default = 1, title = "bc_maxActive", tooltip = "bc_maxActive_tooltip", + noTranslate = true + }, + {name = "toDeliver", + values = {.85,.87,.89,.91,.93}, + texts = {"85 %","87 %","89 %","91 %","standard"}, + default = 5, + title = "bc_toDeliver", + tooltip = "bc_toDeliver_tooltip", + actionFunc = function(self,ix) + HarvestMission.SUCCESS_FACTOR = self.values[ix] + end, noTranslate = true }, {name = "refreshMP", @@ -214,6 +226,7 @@ function BCsetting.new(data, customMt) -- index of the previous value/text self.previous = 1 self.isDisabledFunc = data.isDisabledFunc + self.actionFunc = data.actionFunc self.guiElement = nil return self end @@ -225,7 +238,7 @@ function BCsetting.init(bc) local setting = BCsetting.new(data) setting:setValue(bc.config[setting.name]) table.insert(settings, setting) - bc.settingsByName[setting.name] = setting -- do we still need this? + bc.settingsByName[setting.name] = setting -- needed for SettingsEvent:readStream() end end return settings @@ -273,6 +286,9 @@ function BCsetting:setIx(ix) self.previous = self.current self.current = ix conf[self.name] = self.values[ix] + if self.actionFunc ~= nil then + self:actionFunc(ix) + end debugPrint("** %s set to %s **", self.name,self.values[ix]) end end