Script v1.7.1.0
- AI
- AIDriveStrategy
- AIDriveStrategyBaler
- AIDriveStrategyCollision
- AIDriveStrategyCombine
- AIDriveStrategyConveyor
- AIDriveStrategyStraight
- AITurnStrategy
- AITurnStrategyBulb1
- AITurnStrategyBulb1Revers...
- AITurnStrategyBulb2
- AITurnStrategyBulb2Revers...
- AITurnStrategyBulb3
- AITurnStrategyBulb3Revers...
- AITurnStrategyDefault
- AITurnStrategyDefaultReve...
- AITurnStrategyHalfCircle
- AITurnStrategyHalfCircleR...
- HelperManager
- NPCManager
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
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 | 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 |
79 | 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
83 | function AIDriveStrategyBaler:updateDriving(dt) |
84 | end |