Skip to content

Commit e2607af

Browse files
committed
Added support for "BALE PROCESSORS"
Added support for STRAW BLOWERS and TMR MIXERS - KUHN RA 142 - KUHN PRIMOR 15070 M - SILOKING TrailedLine 4.0 Premium 2218‑22 - FARESIN PF 2.24 Plus - Anderson Group PRO-CHOP 150 NOTES: - Straw Blowers cannot be unloaded - TMR Mixers will automatically maintain the correct ratios
1 parent a06b1eb commit e2607af

File tree

4 files changed

+150
-16
lines changed

4 files changed

+150
-16
lines changed

UniversalAutoload.lua

Lines changed: 122 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ function UniversalAutoload.initSpecialization()
101101
s.schema:register(XMLValueType.BOOL, s.key..".options#isBoxTrailer", "If trailer is enclosed with a rear door", false)
102102
s.schema:register(XMLValueType.BOOL, s.key..".options#isLogTrailer", "If trailer is a logging trailer - will load only logs, dropped from above", false)
103103
s.schema:register(XMLValueType.BOOL, s.key..".options#isBaleTrailer", "If trailer should use an automatic bale collection mode", false)
104+
s.schema:register(XMLValueType.BOOL, s.key..".options#isBaleProcessor", "If trailer should consume bales (e.g. TMR Mixer or Straw Blower)", false)
104105
s.schema:register(XMLValueType.BOOL, s.key..".options#isCurtainTrailer", "Automatically detect the available load side (if the trailer has curtain sides)", false)
105106
s.schema:register(XMLValueType.BOOL, s.key..".options#enableRearLoading", "Use the automatic rear loading trigger", false)
106107
s.schema:register(XMLValueType.BOOL, s.key..".options#enableSideLoading", "Use the automatic side loading triggers", false)
@@ -1548,6 +1549,7 @@ function UniversalAutoload:onLoad(savegame)
15481549
spec.isBoxTrailer = config.isBoxTrailer
15491550
spec.isLogTrailer = config.isLogTrailer
15501551
spec.isBaleTrailer = config.isBaleTrailer
1552+
spec.isBaleProcessor = config.isBaleProcessor
15511553
spec.isCurtainTrailer = config.isCurtainTrailer
15521554
spec.enableRearLoading = config.enableRearLoading
15531555
spec.enableSideLoading = config.enableSideLoading
@@ -1615,10 +1617,12 @@ function UniversalAutoload:onLoad(savegame)
16151617
j = j + 1
16161618
end
16171619
local isBaleTrailer = xmlFile:getValue(key..".options#isBaleTrailer", nil)
1620+
local isBaleProcessor = xmlFile:getValue(key..".options#isBaleProcessor", nil)
16181621
local horizontalLoading = xmlFile:getValue(key..".options#horizontalLoading", nil)
16191622

1620-
spec.horizontalLoading = horizontalLoading or isBaleTrailer or false
1623+
spec.horizontalLoading = horizontalLoading or isBaleTrailer or isBaleProcessor or false
16211624
spec.isBaleTrailer = isBaleTrailer or hasBaleHeight
1625+
spec.isBaleProcessor = isBaleProcessor
16221626

16231627
spec.isBoxTrailer = xmlFile:getValue(key..".options#isBoxTrailer", false)
16241628
spec.isLogTrailer = xmlFile:getValue(key..".options#isLogTrailer", false)
@@ -2353,6 +2357,7 @@ function UniversalAutoload:onReadStream(streamId, connection)
23532357
spec.isBoxTrailer = streamReadBool(streamId)
23542358
spec.isLogTrailer = streamReadBool(streamId)
23552359
spec.isBaleTrailer = streamReadBool(streamId)
2360+
spec.isBaleProcessor = streamReadBool(streamId)
23562361
spec.isCurtainTrailer = streamReadBool(streamId)
23572362
spec.rearUnloadingOnly = streamReadBool(streamId)
23582363
spec.frontUnloadingOnly = streamReadBool(streamId)
@@ -2386,6 +2391,7 @@ function UniversalAutoload:onWriteStream(streamId, connection)
23862391
spec.isBoxTrailer = spec.isBoxTrailer or false
23872392
spec.isLogTrailer = spec.isLogTrailer or false
23882393
spec.isBaleTrailer = spec.isBaleTrailer or false
2394+
spec.isBaleProcessor = spec.isBaleProcessor or false
23892395
spec.isCurtainTrailer = spec.isCurtainTrailer or false
23902396
spec.rearUnloadingOnly = spec.rearUnloadingOnly or false
23912397
spec.frontUnloadingOnly = spec.frontUnloadingOnly or false
@@ -2405,6 +2411,7 @@ function UniversalAutoload:onWriteStream(streamId, connection)
24052411
streamWriteBool(streamId, spec.isBoxTrailer)
24062412
streamWriteBool(streamId, spec.isLogTrailer)
24072413
streamWriteBool(streamId, spec.isBaleTrailer)
2414+
streamWriteBool(streamId, spec.isBaleProcessor)
24082415
streamWriteBool(streamId, spec.isCurtainTrailer)
24092416
streamWriteBool(streamId, spec.rearUnloadingOnly)
24102417
streamWriteBool(streamId, spec.frontUnloadingOnly)
@@ -2537,6 +2544,62 @@ function UniversalAutoload:onUpdate(dt, isActiveForInput, isActiveForInputIgnore
25372544
end
25382545
end
25392546

2547+
-- CHECK STATUS OF MIXER WAGONS
2548+
if spec.isBaleProcessor and self.spec_mixerWagon then
2549+
if self.spec_mixerWagon.baleTriggers then
2550+
2551+
local fillTypes = self.spec_mixerWagon.fillTypeToMixerWagonFillType
2552+
local totalFillLevel = self.spec_fillUnit.fillUnits[1].fillLevel
2553+
local totalCapacity = self.spec_fillUnit.fillUnits[1].capacity
2554+
2555+
local function requiresMore(fillType)
2556+
local fillTypeData = fillTypes[fillType]
2557+
local ratio = fillTypeData.ratio
2558+
local fillLevel = fillTypeData.fillLevel
2559+
local minPercentage = fillTypeData.minPercentage
2560+
local maxPercentage = fillTypeData.maxPercentage
2561+
local avgPercentage = (minPercentage + maxPercentage) / 2
2562+
2563+
if totalCapacity > 0 then
2564+
local percentage = fillLevel / totalCapacity
2565+
if percentage > avgPercentage then
2566+
return false
2567+
end
2568+
end
2569+
2570+
if totalFillLevel > 0 then
2571+
local percentage = fillLevel / totalFillLevel
2572+
if percentage > 0.99*maxPercentage then
2573+
return false
2574+
end
2575+
end
2576+
2577+
return true
2578+
end
2579+
2580+
for _, object in pairs(spec.loadedObjects) do
2581+
if object ~= nil and object.isRoundbale~=nil then
2582+
local hasBale = false
2583+
for _, baleTrigger in ipairs(self.spec_mixerWagon.baleTriggers) do
2584+
for bale, _ in pairs(baleTrigger.balesInTrigger) do
2585+
if object == bale then
2586+
hasBale = true
2587+
if not requiresMore(bale.fillType) then
2588+
baleTrigger.balesInTrigger[bale] = nil
2589+
end
2590+
end
2591+
end
2592+
end
2593+
if hasBale == false and requiresMore(object.fillType) then
2594+
local baleTrigger = self.spec_mixerWagon.baleTriggers[1]
2595+
baleTrigger.balesInTrigger[object] = baleTrigger.balesInTrigger[object] or 1
2596+
end
2597+
end
2598+
end
2599+
2600+
end
2601+
end
2602+
25402603
-- CREATE AND LOAD BALES (IF REQUESTED)
25412604
if spec.spawnBales then
25422605
spec.spawnBalesDelayTime = spec.spawnBalesDelayTime or 0
@@ -2759,6 +2822,7 @@ function UniversalAutoload:onUpdate(dt, isActiveForInput, isActiveForInputIgnore
27592822
end
27602823
end
27612824
lastObject = object
2825+
if debugLoading then print("TRY LOADING OBJECT: "..object.i3dFilename) end
27622826
if UniversalAutoload.loadObject(self, object, true) then
27632827
loadedObject = true
27642828
if spec.firstAttemptToLoad then
@@ -2771,6 +2835,7 @@ function UniversalAutoload:onUpdate(dt, isActiveForInput, isActiveForInputIgnore
27712835
break
27722836
end
27732837
if not loadedObject then
2838+
if debugLoading then print("...FAILED LOADING OBJECT") end
27742839
if #spec.sortedObjectsToLoad > 0 and lastObject ~= nil then
27752840
local i = #spec.sortedObjectsToLoad
27762841
for _ = 1, #spec.sortedObjectsToLoad do
@@ -3004,15 +3069,36 @@ function UniversalAutoload:isValidForLoading(object)
30043069
return false
30053070
end
30063071
end
3072+
3073+
if spec.isBaleProcessor and self.spec_mixerWagon then
3074+
local fillTypes = self.spec_mixerWagon.fillTypeToMixerWagonFillType
3075+
if not fillTypes or not fillTypes[object.fillType] then
3076+
return false
3077+
end
3078+
end
30073079

30083080
--if debugPallets then print(object.i3dFilename, "Valid For Loading") end
30093081
return true
30103082
end
30113083
--
30123084
function UniversalAutoload:isValidForUnloading(object)
30133085
local spec = self.spec_universalAutoload
3086+
3087+
if not UniversalAutoload.getPalletIsSelectedMaterial(self, object) then
3088+
return false
3089+
end
3090+
if not UniversalAutoload.getPalletIsSelectedContainer(self, object) then
3091+
return false
3092+
end
3093+
if spec.autoLoadingObjects[object] ~= nil then
3094+
return false
3095+
end
3096+
if spec.isBaleProcessor and not object.allowPickup then
3097+
--DebugUtil.printTableRecursively(object, "--", 0, 1)
3098+
return false
3099+
end
30143100

3015-
return UniversalAutoload.getPalletIsSelectedMaterial(self, object) and UniversalAutoload.getPalletIsSelectedContainer(self, object) and spec.autoLoadingObjects[object] == nil
3101+
return true
30163102
end
30173103
--
30183104
function UniversalAutoload.isValidForManualLoading(object)
@@ -3210,17 +3296,38 @@ function UniversalAutoload:loadObject(object, chargeForLoading)
32103296
end
32113297
return true
32123298
end
3299+
else
3300+
if debugLoading then print("NO LOAD PLACE FOUND: "..containerType.name) end
32133301
end
32143302

32153303
end
3216-
3304+
3305+
if debugLoading then
3306+
if not UniversalAutoload.getIsLoadingVehicleAllowed(self) then
3307+
print("*** LOADING NOT ALLOWED ***")
3308+
end
3309+
if not UniversalAutoload.isValidForLoading(self, object) then
3310+
print("*** OBJECT IS NOT VALID ***")
3311+
end
3312+
end
32173313
return false
32183314
end
32193315
--
32203316
function UniversalAutoload:unloadObject(object, unloadPlace)
3221-
-- print("UniversalAutoload - unloadObject")
3317+
local spec = self.spec_universalAutoload
3318+
32223319
if object ~= nil and UniversalAutoload.isValidForUnloading(self, object) then
32233320

3321+
if spec.isBaleProcessor then
3322+
if self.spec_mixerWagon and self.spec_mixerWagon.baleTriggers then
3323+
for _, baleTrigger in ipairs(self.spec_mixerWagon.baleTriggers) do
3324+
if baleTrigger.balesInTrigger[object] then
3325+
baleTrigger.balesInTrigger[object] = nil
3326+
end
3327+
end
3328+
end
3329+
end
3330+
32243331
if UniversalAutoload.moveObjectNodes(self, object, unloadPlace, false, false) then
32253332
UniversalAutoload.clearPalletFromAllVehicles(self, object)
32263333
return true
@@ -3625,6 +3732,7 @@ end
36253732
--
36263733
function UniversalAutoload:resetLoadingArea()
36273734
local spec = self.spec_universalAutoload
3735+
if debugLoading then print("RESET AREA") end
36283736
UniversalAutoload.resetLoadingLayer(self)
36293737
UniversalAutoload.resetLoadingPattern(self)
36303738
spec.trailerIsFull = false
@@ -3636,6 +3744,7 @@ function UniversalAutoload:getLoadPlace(containerType, object)
36363744
local spec = self.spec_universalAutoload
36373745

36383746
if containerType==nil or (spec.trailerIsFull and not spec.partiallyUnloaded) then
3747+
if debugLoading then print("containerType==nil or trailerIsFull") end
36393748
return
36403749
end
36413750

@@ -3975,31 +4084,31 @@ function UniversalAutoload:getIsLoadingVehicleAllowed()
39754084
if debugVehicles then print(self:getFullName() .. ": UAL DISABLED - getIsLoadingVehicleAllowed") end
39764085
return false
39774086
end
3978-
3979-
if self:ualGetIsFilled() then
3980-
-- print("ualGetIsFilled")
4087+
4088+
if self:ualGetIsFilled() and not spec.isBaleProcessor then
4089+
if debugLoading then print(self:getFullName() .. " - NO LOADING IF FILLED") end
39814090
return false
39824091
end
39834092
if spec.noLoadingIfFolded and (self:ualGetIsFolding() or not self:getIsUnfolded()) then
3984-
-- print("noLoadingIfFolded")
4093+
if debugLoading then print(self:getFullName() .. " - NO LOADING IF FOLDED") end
39854094
return false
39864095
end
39874096
if spec.noLoadingIfUnfolded and (self:ualGetIsFolding() or self:getIsUnfolded()) then
3988-
-- print("noLoadingIfUnfolded")
4097+
if debugLoading then print(self:getFullName() .. " - NO LOADING IF UNFOLDED") end
39894098
return false
39904099
end
39914100
if spec.noLoadingIfCovered and self:ualGetIsCovered() then
3992-
-- print("noLoadingIfCovered")
4101+
if debugLoading then print(self:getFullName() .. " - NO LOADING IF COVERED") end
39934102
return false
39944103
end
39954104
if spec.noLoadingIfUncovered and not self:ualGetIsCovered() then
3996-
-- print("noLoadingIfUncovered")
4105+
if debugLoading then print(self:getFullName() .. " - NO LOADING IF UNCOVERED") end
39974106
return false
39984107
end
39994108

40004109
local node = UniversalAutoload.getObjectPositionNode( self )
40014110
if node == nil then
4002-
-- print("node == nil")
4111+
if debugLoading then print(self:getFullName() .. " - NO LOADING IF node == nil") end
40034112
return false
40044113
end
40054114

@@ -4008,7 +4117,7 @@ function UniversalAutoload:getIsLoadingVehicleAllowed()
40084117
local _, y1, _ = getWorldTranslation(node)
40094118
local _, y2, _ = localToWorld(node, 0, 1, 0)
40104119
if y2 - y1 < 0.5 then
4011-
-- print("NO LOADING IF FALLEN OVER")
4120+
if debugLoading then print(self:getFullName() .. " - NO LOADING IF FALLEN OVER") end
40124121
return false
40134122
end
40144123
end

UniversalAutoloadInstaller.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,10 +260,12 @@ function UniversalAutoloadManager.ImportVehicleConfigurations(xmlFilename, overw
260260
end
261261

262262
local isBaleTrailer = xmlFile:getValue(configKey..".options#isBaleTrailer", nil)
263+
local isBaleProcessor = xmlFile:getValue(configKey..".options#isBaleProcessor", nil)
263264
local horizontalLoading = xmlFile:getValue(configKey..".options#horizontalLoading", nil)
264265

265-
config.horizontalLoading = horizontalLoading or isBaleTrailer or false
266+
config.horizontalLoading = horizontalLoading or isBaleTrailer or isBaleProcessor or false
266267
config.isBaleTrailer = isBaleTrailer or hasBaleHeight
268+
config.isBaleProcessor = isBaleProcessor
267269

268270
config.isBoxTrailer = xmlFile:getValue(configKey..".options#isBoxTrailer", false)
269271
config.isLogTrailer = xmlFile:getValue(configKey..".options#isLogTrailer", false)

config/SupportedVehicles.xml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,29 @@
128128
<loadingArea offset="0 1.9 -3.75" width="2.6" height="2.0" length="5.6"/>
129129
<options isLogTrailer="true"/>
130130
</vehicleConfiguration>
131+
132+
133+
<!-- SUPPORTED STRAW BLOWERS AND TMR MIXERS -->
134+
<vehicleConfiguration configFileName="data/vehicles/kuhn/ra142/ra142.xml">
135+
<loadingArea offset="0 1.5 0" width="2.0" height="2.20" length="3.5"/>
136+
<options isBaleProcessor="true"/>
137+
</vehicleConfiguration>
138+
<vehicleConfiguration configFileName="data/vehicles/kuhn/primor15070/primor15070.xml">
139+
<loadingArea offset="0 1.1 -0.65" width="1.6" height="2.65" length="4.2"/>
140+
<options isBaleProcessor="true"/>
141+
</vehicleConfiguration>
142+
<vehicleConfiguration configFileName="data/vehicles/siloking/tl4Premium/tl4Premium.xml">
143+
<loadingArea offset="0 1.2 -1.2" width="1.75" height="2.65" length="3.75"/>
144+
<options isBaleProcessor="true"/>
145+
</vehicleConfiguration>
146+
<vehicleConfiguration configFileName="data/vehicles/faresin/pf224/pf224.xml">
147+
<loadingArea offset="0 1.2 0.1" width="2.0" height="2.65" length="4.0"/>
148+
<options isBaleProcessor="true"/>
149+
</vehicleConfiguration>
150+
<vehicleConfiguration configFileName="data/vehicles/andersonGroup/proChop150/proChop150.xml">
151+
<loadingArea offset="0 1.1 -0.55" width="1.6" height="1.65" length="1.8"/>
152+
<options isBaleProcessor="true"/>
153+
</vehicleConfiguration>
131154

132155

133156
<!-- SUPPORTED DLCs -->

modDesc.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
2-
<modDesc descVersion="79">
2+
<modDesc descVersion="80">
33

44
<author>loki_79</author>
5-
<version>1.5.1.8</version>
5+
<version>1.5.2.0</version>
66

77
<title>
88
<en>Universal Autoload</en>

0 commit comments

Comments
 (0)