Script v1_7_1_0
- AI
- AIDriveStrategy
- AIDriveStrategyBaler
- AIDriveStrategyCollision
- AIDriveStrategyCombine
- AIDriveStrategyConveyor
- AIDriveStrategyStonePicke...
- AIDriveStrategyStraight
- AIJobTypeManager
- AISystem
- AITurnStrategy
- AITurnStrategyBulb1
- AITurnStrategyBulb1Revers...
- AITurnStrategyBulb2
- AITurnStrategyBulb2Revers...
- AITurnStrategyBulb3
- AITurnStrategyBulb3Revers...
- AITurnStrategyDefault
- AITurnStrategyDefaultReve...
- AITurnStrategyHalfCircle
- AITurnStrategyHalfCircleR...
- HelperManager
- NPCManager
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
AIDriveStrategyBaler
Descriptiondrive strategy to - automatic bale dropping while ai is active Copyright (C) GIANTS Software GmbH, Confidential, All Rights Reserved.Parent
AIDriveStrategyFunctions
getDriveData
DescriptionDefinitiongetDriveData()Code
49 | function 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 | if not spec.nonStopBaling then |
57 | local fillLevel = baler:getFillUnitFillLevel(spec.fillUnitIndex) |
58 | local capacity = baler:getFillUnitCapacity(spec.fillUnitIndex) |
59 | |
60 | local freeFillLevel = capacity - fillLevel |
61 | if freeFillLevel < self.slowDownFillLevel then |
62 | -- we want to drive at least 2 km/h to avoid baler stops too early |
63 | maxSpeed = 2 + (freeFillLevel / self.slowDownFillLevel) * self.slowDownStartSpeed |
64 | |
65 | if VehicleDebug.state == VehicleDebug.DEBUG_AI then |
66 | self.vehicle:addAIDebugText(string.format("BALER -> Slow down because nearly full: %.2f", maxSpeed)) |
67 | end |
68 | end |
69 | |
70 | if fillLevel == capacity or spec.unloadingState ~= Baler.UNLOADING_CLOSED then |
71 | allowedToDrive = false |
72 | end |
73 | else |
74 | if spec.platformDropInProgress then |
75 | maxSpeed = spec.platformAIDropSpeed |
76 | |
77 | if VehicleDebug.state == VehicleDebug.DEBUG_AI then |
78 | self.vehicle:addAIDebugText(string.format("BALER -> Platform dropping active, reducing speed to %.1f km/h", spec.platformAIDropSpeed)) |
79 | end |
80 | end |
81 | end |
82 | end |
83 | |
84 | if not allowedToDrive then |
85 | return 0, 1, true, 0, math.huge |
86 | else |
87 | return nil, nil, nil, maxSpeed, nil |
88 | end |
89 | end |
new
DescriptionDefinitionnew()Code
12 | function 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 |
25 | end |
setAIVehicle
DescriptionDefinitionsetAIVehicle()Code
29 | function 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 |
40 | end |
update
DescriptionDefinitionupdate()Code
44 | function AIDriveStrategyBaler:update(dt) |
45 | end |
updateDriving
DescriptionDefinitionupdateDriving()Code
93 | function AIDriveStrategyBaler:updateDriving(dt) |
94 | end |