From abe74f4f206cf6f09bf18b04450edd7d277840d3 Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Mon, 8 Nov 2021 05:21:19 +0100 Subject: [PATCH 1/3] Fix mechanic not being persistent --- .../BreakdownServicing/BreakdownServicing.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/data/modules/BreakdownServicing/BreakdownServicing.lua b/data/modules/BreakdownServicing/BreakdownServicing.lua index 94bb148d45b..6feeb05e97c 100644 --- a/data/modules/BreakdownServicing/BreakdownServicing.lua +++ b/data/modules/BreakdownServicing/BreakdownServicing.lua @@ -62,6 +62,7 @@ for i = 1,#flavours do f.response = l["FLAVOUR_" .. i-1 .. "_RESPONSE"] end +local mechanic = {} local ads = {} local service_history = { lastdate = 0, -- Default will be overwritten on game start @@ -131,7 +132,7 @@ local onChat = function (form, ref, option) if option == 0 then -- Initial proposal form:SetTitle(ad.title) - form:SetFace(Character.New({ female = ad.isfemale, seed = ad.faceseed, name = ad.name })) + form:SetFace(ad.mechanic) -- Replace token with details of last service (which might have -- been seconds ago) form:SetMessage(string.interp(message, { @@ -151,7 +152,7 @@ local onChat = function (form, ref, option) -- Yes please, service my engine form:Clear() form:SetTitle(ad.title) - form:SetFace(Character.New({ female = ad.isfemale, seed = ad.faceseed, name = ad.name })) + form:SetFace(ad.mechanic) if Game.player:GetMoney() >= price then -- We did check earlier, but... -- Say thanks form:SetMessage(ad.response) @@ -187,26 +188,23 @@ end local onCreateBB = function (station) local rand = Rand.New(station.seed + seedbump) local n = rand:Integer(1,#flavours) - local isfemale = rand:Integer(1) == 1 - local name = NameGen.FullName(isfemale,rand) + mechanic = Character.New() local ad = { - name = name, - isfemale = isfemale, + mechanic = mechanic, -- Only replace tokens which are not subject to further change title = string.interp(flavours[n].title, { name = station.label, - proprietor = name, + proprietor = mechanic.name, }), intro = string.interp(flavours[n].intro, { name = station.label, - proprietor = name, + proprietor = mechanic.name, }), price = flavours[n].price, yesplease = flavours[n].yesplease, response = flavours[n].response, station = station, - faceseed = rand:Integer(), strength = flavours[n].strength, baseprice = flavours[n].baseprice *rand:Number(0.8,1.2), -- A little per-station flavouring } From 3a930841bf88015b134dc7b563ebe048b838c93e Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Wed, 10 Nov 2021 17:34:43 +0100 Subject: [PATCH 2/3] Remove redundant code --- data/modules/BreakdownServicing/BreakdownServicing.lua | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/data/modules/BreakdownServicing/BreakdownServicing.lua b/data/modules/BreakdownServicing/BreakdownServicing.lua index 6feeb05e97c..1deefa1bcfa 100644 --- a/data/modules/BreakdownServicing/BreakdownServicing.lua +++ b/data/modules/BreakdownServicing/BreakdownServicing.lua @@ -62,7 +62,6 @@ for i = 1,#flavours do f.response = l["FLAVOUR_" .. i-1 .. "_RESPONSE"] end -local mechanic = {} local ads = {} local service_history = { lastdate = 0, -- Default will be overwritten on game start @@ -188,7 +187,7 @@ end local onCreateBB = function (station) local rand = Rand.New(station.seed + seedbump) local n = rand:Integer(1,#flavours) - mechanic = Character.New() + local mechanic = Character.New() local ad = { mechanic = mechanic, From 8371b933e1c5199152eb65f96493b4699ed5a5c3 Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Mon, 15 Nov 2021 22:02:04 +0100 Subject: [PATCH 3/3] More persistance --- data/modules/BreakdownServicing/BreakdownServicing.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/modules/BreakdownServicing/BreakdownServicing.lua b/data/modules/BreakdownServicing/BreakdownServicing.lua index 1deefa1bcfa..bc19383828f 100644 --- a/data/modules/BreakdownServicing/BreakdownServicing.lua +++ b/data/modules/BreakdownServicing/BreakdownServicing.lua @@ -187,7 +187,7 @@ end local onCreateBB = function (station) local rand = Rand.New(station.seed + seedbump) local n = rand:Integer(1,#flavours) - local mechanic = Character.New() + local mechanic = Character.New({seed=rand:Integer()}) local ad = { mechanic = mechanic,