Skip to content

Commit

Permalink
bugfix silage mission bales
Browse files Browse the repository at this point in the history
bug fix: silage mission bales are not fermenting. onChangedFilltype() now calls updBales() withparm "wasFermenting" only if it's not a misssion bale
  • Loading branch information
Mmtrx committed Jul 11, 2022
1 parent b62fe93 commit 64c16b9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions BaleSee.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
-- v2.1.0.0 30.06.2021 MULTIPLAYER! / handle all bale types, (e.g. Maizeplus forage extension)
-- v3.0.0.0 30.04.2022 port to FS22
-- v3.0.0.1 15.06.2022 bale / pallet detection moved to update(dt). Inspired by GtX EDC
-- v3.0.0.2 11.07.2022 bug fix: silage mission bales are not fermenting
--=======================================================================================================

function debugPrint(text, ...)
Expand Down
2 changes: 1 addition & 1 deletion modDesc.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<modDesc descVersion="66">
<author> Mmtrx</author>
<version>3.0.0.1</version>
<version>3.0.0.2</version>
<title>
<en>See Bales</en>
<de>Ballen Sehen</de>
Expand Down
5 changes: 3 additions & 2 deletions scripts/helper.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
-- v2.0.0.1 19.06.2020 handle all pallet types, (e.g. straw harvest)
-- v2.1.0.0 30.06.2021 MULTIPLAYER! / handle all bale types, (e.g. Maizeplus forage extension)
-- v3.0.0.1 15.06.2022 bale / pallet detection moved to update(dt). Inspired by GtX EDC
-- v3.0.0.2 11.07.2022 bug fix: silage mission bales are not fermenting
--=======================================================================================================
function BaleSee:getSize(typ, size)
-- return icon / dotmarker size in u.v coordinates
Expand Down Expand Up @@ -111,7 +112,7 @@ function BaleSee:toggleSize(size)
hs.icon:resetDimensions() -- reset hud scaling effects
end
end;
function BaleSee:updBales(object,farmId,ft,inc,fermenting)
function BaleSee:updBales(object,farmId,ft,inc,wasFermenting)
-- adjust count in self.bales[farm].
local isRound = object.diameter > 0 -- works, if it's a bale
local size = object.length *100 -- length in cm
Expand All @@ -135,7 +136,7 @@ function BaleSee:updBales(object,farmId,ft,inc,fermenting)
self.baleIdToHash[object.id] = hash
else
self.baleIdToHash[object.id] = nil
if fermenting then hash = -hash end
if wasFermenting then hash = -hash end
end
self.bales[farmId][hash].number = self.bales[farmId][hash].number +inc -- update bale type
self.numBales[farmId] = self.numBales[farmId] + inc -- update bales sum
Expand Down
5 changes: 4 additions & 1 deletion scripts/hotspots.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
-- v2.0.0.1 19.06.2020 handle all pallet types, (e.g. straw harvest)
-- v2.1.0.0 30.06.2021 MULTIPLAYER! / handle all bale types, (e.g. Maizeplus forage extension)
-- v3.0.0.1 15.06.2022 bale / pallet detection moved to update(dt). Inspired by GtX EDC
-- v3.0.0.2 11.07.2022 bug fix: silage mission bales are not fermenting
--=======================================================================================================
-- ---------------Hotspot class -----------------------------------------------------------
BaleSeeHotspot = {}
Expand Down Expand Up @@ -334,7 +335,9 @@ function BaleSee:onChangedFillType(obj)
bs.bHotspots[hotspot] = {obj, color, fillType}
bs.baleToHotspot[obj] = {hotspot, color, fillType}
-- adjust bale counts, old filltype -1, new fillType +1:
bs:updBales(obj, farm, oldFillType , -1, true) -- decr old filltype
-- only possible change is GRASS_WINDROW -> SILAGE
-- wasFermenting is only true if not a mission bale
bs:updBales(obj, farm, oldFillType , -1, not obj.isMissionBale) -- decr old filltype
bs:updBales(obj, farm, fillType , 1) -- incr new filltype
end
end

0 comments on commit 64c16b9

Please sign in to comment.