LUADOC - Farming Simulator 19

Script v1.7.1.0

Engine v1.7.1.0

Foundation Reference

AIDriveStrategyBaler

Description
drive strategy to - automatic bale dropping while ai is active Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.
Parent
AIDriveStrategy
Functions

getDriveData

Description
Definition
getDriveData()
Code
49function AIDriveStrategyBaler:getDriveData(dt, vX,vY,vZ)
50 local allowedToDrive = true
51 local maxSpeed = math.huge
52
53 for _, baler in pairs(self.balers) do
54 local spec = baler.spec_baler
55
56 local fillLevel = baler:getFillUnitFillLevel(spec.fillUnitIndex)
57 local capacity = baler:getFillUnitCapacity(spec.fillUnitIndex)
58
59 local freeFillLevel = capacity - fillLevel
60 if freeFillLevel < self.slowDownFillLevel then
61 -- we want to drive at least 2 km/h to avoid baler stops too early
62 maxSpeed = 2 + (freeFillLevel / self.slowDownFillLevel) * self.slowDownStartSpeed
63
64 if VehicleDebug.state == VehicleDebug.DEBUG_AI then
65 self.vehicle:addAIDebugText(string.format("BALER -> Slow down because nearly full: %.2f", maxSpeed))
66 end
67 end
68
69 if fillLevel == capacity or spec.unloadingState ~= Baler.UNLOADING_CLOSED then
70 allowedToDrive = false
71 end
72 end
73
74 if not allowedToDrive then
75 return 0, 1, true, 0, math.huge
76 else
77 return nil, nil, nil, maxSpeed, nil
78 end
79end

new

Description
Definition
new()
Code
12function AIDriveStrategyBaler:new(customMt)
13 if customMt == nil then
14 customMt = AIDriveStrategyBaler_mt
15 end
16
17 local self = AIDriveStrategy:new(customMt)
18
19 self.balers = {}
20
21 self.slowDownFillLevel = 200
22 self.slowDownStartSpeed = 20
23
24 return self
25end

setAIVehicle

Description
Definition
setAIVehicle()
Code
29function AIDriveStrategyBaler:setAIVehicle(vehicle)
30 AIDriveStrategyBaler:superClass().setAIVehicle(self, vehicle)
31
32 if SpecializationUtil.hasSpecialization(Baler, self.vehicle.specializations) then
33 table.insert(self.balers, self.vehicle)
34 end
35 for _,implement in pairs(self.vehicle:getAttachedAIImplements()) do
36 if SpecializationUtil.hasSpecialization(Baler, implement.object.specializations) then
37 table.insert(self.balers, implement.object)
38 end
39 end
40end

update

Description
Definition
update()
Code
44function AIDriveStrategyBaler:update(dt)
45end

updateDriving

Description
Definition
updateDriving()
Code
83function AIDriveStrategyBaler:updateDriving(dt)
84end