Script v1_7_1_0
- AI
- 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
- AIConveyorBelt
- AIDrivable
- AIFieldWorker
- AIImplement
- AIJobVehicle
- AIVehicle
- AIVehicleObstacle
- AnimatedVehicle
- ArticulatedAxis
- Attachable
- AttacherJointControl
- AttacherJoints
- AutoLoader
- BaleGrab
- BaleLoader
- Baler
- BaleWrapper
- BaseMaterial
- BigBag
- BunkerSiloCompacter
- BunkerSiloInteractor
- CCTDrivable
- Combine
- ConnectionHoses
- ConveyorBelt
- Cover
- CrabSteering
- Crawlers
- CropSensor
- Cultivator
- Cutter
- Cylindered
- CylinderedFoldable
- Dashboard
- Dischargeable
- Drivable
- DynamicallyLoadedParts
- DynamicMountAttacher
- Enterable
- ExtendedAIVehicle
- ExtendedCombine
- ExtendedMotorized
- ExtendedMower
- ExtendedSowingMachine
- ExtendedSprayer
- ExtendedWearable
- FertilizingCultivator
- FertilizingSowingMachine
- FillTriggerVehicle
- FillUnit
- FillVolume
- Foldable
- FoliageBending
- ForageWagon
- FrontloaderAttacher
- FruitPreparer
- GroundAdjustedNodes
- GroundReference
- HeadlandAnimation
- Honk
- HookLiftContainer
- HookLiftTrailer
- IKChains
- InlineWrapper
- JigglingParts
- Leveler
- LicensePlates
- Lights
- LivestockTrailer
- Locomotive
- LogGrab
- ManureBarrel
- ManureSensor
- MixerWagon
- Motorized
- Mountable
- Mower
- Mulcher
- MultipleItemPurchase
- Pallet
- Pickup
- Pipe
- PlaceableAI
- PlaceableAnimatedObjects
- PlaceableBeehive
- PlaceableBeehivePalletSpa...
- PlaceableBunkerSilo
- PlaceableBuyingStation
- PlaceableCartridgePlayer
- PlaceableChargingStation
- PlaceableClearAreas
- PlaceableColorable
- PlaceableDeletedNodes
- PlaceableDoghouse
- PlaceableDynamicallyLoade...
- PlaceableFarmhouse
- PlaceableFence
- PlaceableFoliageAreas
- PlaceableGreenhouse
- PlaceableHighPressureWash...
- PlaceableHotspots
- PlaceableHusbandry
- PlaceableHusbandryAnimals
- PlaceableHusbandryFeeding...
- PlaceableHusbandryFence
- PlaceableHusbandryFood
- PlaceableHusbandryLiquidM...
- PlaceableHusbandryMilk
- PlaceableHusbandryPallets
- PlaceableHusbandryStraw
- PlaceableHusbandryWater
- PlaceableIncomePerHour
- PlaceableIndoorAreas
- PlaceableInfoTrigger
- PlaceableLeveling
- PlaceableLights
- PlaceableManureHeap
- PlaceablePlacement
- PlaceableProductionPoint
- PlaceableSellingStation
- PlaceableSilo
- PlaceableSiloExtension
- PlaceableSolarPanels
- PlaceableTipOcclusionArea...
- PlaceableTrainSystem
- PlaceableTriggerMarkers
- PlaceableVine
- PlaceableWardrobe
- PlaceableWeatherStation
- PlaceableWeighingStation
- PlaceableWindTurbine
- PlaceableWorkshop
- Plow
- PlowPacker
- PowerConsumer
- PowerTakeOffs
- PrecisionFarmingStatistic
- PushHandTool
- RandomlyMovingParts
- ReceivingHopper
- ReverseDriving
- Rideable
- RidgeMarker
- Roller
- Ropes
- RTKStation
- SaltSpreader
- SemiTrailerFront
- Shovel
- SlopeCompensation
- SmartAttach
- SoilSampler
- SowingMachine
- SpeedRotatingParts
- SplineVehicle
- Sprayer
- StonePicker
- StrawBlower
- StumpCutter
- SupportVehicle
- Suspensions
- Tedder
- TensionBeltObject
- TensionBelts
- TestAreas
- TipOccluder
- Trailer
- TreePlanter
- TreeSaplingPallet
- TreeSaw
- TurnOnVehicle
- VariableWorkWidth
- VehicleSettings
- VineCutter
- VineDetector
- VinePrepruner
- Washable
- WaterTrailer
- Wearable
- Weeder
- WeedSpotSpray
- Wheels
- WindBending
- Windrower
- Wipers
- WoodCrusher
- WoodHarvester
- WorkArea
- WorkMode
- WorkParticles
- 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
WaterTrailer
DescriptionSpecialization for water trailer allowing it to also be filled at any water plane in the worldFunctions
- getDrawFirstFillText
- initSpecialization
- onDelete
- onLoad
- onPreDetach
- onReadStream
- onUpdateTick
- onWriteStream
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
- setIsWaterTrailerFilling
getDrawFirstFillText
DescriptionDefinitiongetDrawFirstFillText()Code
166 | function WaterTrailer:getDrawFirstFillText(superFunc) |
167 | local spec = self.spec_waterTrailer |
168 | if self.isClient then |
169 | if self:getIsActiveForInput() and self:getIsSelected() then |
170 | if self:getFillUnitFillLevel(spec.fillUnitIndex) <= 0 and self:getFillUnitCapacity(spec.fillUnitIndex) ~= 0 then |
171 | return true |
172 | end |
173 | end |
174 | end |
175 | |
176 | return superFunc(self) |
177 | end |
initSpecialization
DescriptionDefinitioninitSpecialization()Code
22 | function WaterTrailer.initSpecialization() |
23 | local schema = Vehicle.xmlSchema |
24 | schema:setXMLSpecializationType("WaterTrailer") |
25 | |
26 | schema:register(XMLValueType.INT, "vehicle.waterTrailer#fillUnitIndex", "Fill unit index") |
27 | schema:register(XMLValueType.FLOAT, "vehicle.waterTrailer#fillLitersPerSecond", "Fill liters per second", 500) |
28 | schema:register(XMLValueType.NODE_INDEX, "vehicle.waterTrailer#fillNode", "Fill node", "Root component") |
29 | |
30 | SoundManager.registerSampleXMLPaths(schema, "vehicle.waterTrailer.sounds", "refill") |
31 | |
32 | schema:setXMLSpecializationType() |
33 | end |
onDelete
DescriptionCalled on deletingDefinition
onDelete()Code
82 | function WaterTrailer:onDelete() |
83 | local spec = self.spec_waterTrailer |
84 | g_currentMission.activatableObjectsSystem:removeActivatable(spec.activatable) |
85 | |
86 | g_soundManager:deleteSamples(spec.samples) |
87 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
61 | function WaterTrailer:onLoad(savegame) |
62 | local spec = self.spec_waterTrailer |
63 | |
64 | local fillUnitIndex = self.xmlFile:getValue("vehicle.waterTrailer#fillUnitIndex") |
65 | if fillUnitIndex ~= nil then |
66 | spec.fillUnitIndex = fillUnitIndex |
67 | spec.fillLitersPerSecond = self.xmlFile:getValue("vehicle.waterTrailer#fillLitersPerSecond", 500) |
68 | spec.waterFillNode = self.xmlFile:getValue("vehicle.waterTrailer#fillNode", self.components[1].node, self.components, self.i3dMappings) |
69 | end |
70 | |
71 | spec.isFilling = false |
72 | spec.activatable = WaterTrailerActivatable.new(self) |
73 | |
74 | if self.isClient then |
75 | spec.samples = {} |
76 | spec.samples.refill = g_soundManager:loadSampleFromXML(self.xmlFile, "vehicle.waterTrailer.sounds", "refill", self.baseDirectory, self.components, 0, AudioGroup.VEHICLE, self.i3dMappings, self) |
77 | end |
78 | end |
onPreDetach
DescriptionCalled if vehicle gets detachedDefinition
onPreDetach(table attacherVehicle, table implement)Arguments
table | attacherVehicle | attacher vehicle |
table | implement | implement |
183 | function WaterTrailer:onPreDetach(attacherVehicle, implement) |
184 | local spec = self.spec_waterTrailer |
185 | g_currentMission.activatableObjectsSystem:removeActivatable(spec.activatable) |
186 | end |
onReadStream
DescriptionCalled on client side on joinDefinition
onReadStream(integer streamId, integer connection)Arguments
integer | streamId | streamId |
integer | connection | connection |
93 | function WaterTrailer:onReadStream(streamId, connection) |
94 | local isFilling = streamReadBool(streamId) |
95 | self:setIsWaterTrailerFilling(isFilling, true) |
96 | end |
onUpdateTick
DescriptionCalled on update tickDefinition
onUpdateTick(float dt, boolean isActiveForInput, boolean isSelected)Arguments
float | dt | time since last call in ms |
boolean | isActiveForInput | true if vehicle is active for input |
boolean | isSelected | true if vehicle is selected |
112 | function WaterTrailer:onUpdateTick(dt, isActiveForInput, isActiveForInputIgnoreSelection, isSelected) |
113 | local spec = self.spec_waterTrailer |
114 | |
115 | local _, y, _ = getWorldTranslation(spec.waterFillNode) |
116 | local isNearWater = (y <= self.waterY + 0.2) |
117 | |
118 | if isNearWater then |
119 | g_currentMission.activatableObjectsSystem:addActivatable(spec.activatable) |
120 | else |
121 | g_currentMission.activatableObjectsSystem:removeActivatable(spec.activatable) |
122 | end |
123 | |
124 | if self.isServer then |
125 | if spec.isFilling then |
126 | -- stop filling if not near the water anymore |
127 | if not isNearWater then |
128 | self:setIsWaterTrailerFilling(false) |
129 | end |
130 | end |
131 | |
132 | if spec.isFilling then |
133 | if self:getFillUnitAllowsFillType(spec.fillUnitIndex, FillType.WATER) then |
134 | local delta = self:addFillUnitFillLevel(self:getOwnerFarmId(), spec.fillUnitIndex, spec.fillLitersPerSecond*dt*0.001, FillType.WATER, ToolType.TRIGGER, nil) |
135 | if delta <= 0 then |
136 | self:setIsWaterTrailerFilling(false) |
137 | end |
138 | end |
139 | end |
140 | end |
141 | end |
onWriteStream
DescriptionCalled on server side on joinDefinition
onWriteStream(integer streamId, integer connection)Arguments
integer | streamId | streamId |
integer | connection | connection |
102 | function WaterTrailer:onWriteStream(streamId, connection) |
103 | local spec = self.spec_waterTrailer |
104 | streamWriteBool(streamId, spec.isFilling) |
105 | end |
prerequisitesPresent
DescriptionChecks if all prerequisite specializations are loadedDefinition
prerequisitesPresent(table specializations)Arguments
table | specializations | specializations |
boolean | hasPrerequisite | true if all prerequisite specializations are loaded |
16 | function WaterTrailer.prerequisitesPresent(specializations) |
17 | return SpecializationUtil.hasSpecialization(FillUnit, specializations) |
18 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
49 | function WaterTrailer.registerEventListeners(vehicleType) |
50 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", WaterTrailer) |
51 | SpecializationUtil.registerEventListener(vehicleType, "onDelete", WaterTrailer) |
52 | SpecializationUtil.registerEventListener(vehicleType, "onReadStream", WaterTrailer) |
53 | SpecializationUtil.registerEventListener(vehicleType, "onWriteStream", WaterTrailer) |
54 | SpecializationUtil.registerEventListener(vehicleType, "onUpdateTick", WaterTrailer) |
55 | SpecializationUtil.registerEventListener(vehicleType, "onPreDetach", WaterTrailer) |
56 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
37 | function WaterTrailer.registerFunctions(vehicleType) |
38 | SpecializationUtil.registerFunction(vehicleType, "setIsWaterTrailerFilling", WaterTrailer.setIsWaterTrailerFilling) |
39 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
43 | function WaterTrailer.registerOverwrittenFunctions(vehicleType) |
44 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getDrawFirstFillText", WaterTrailer.getDrawFirstFillText) |
45 | end |
setIsWaterTrailerFilling
DescriptionSet is water trailer filling stateDefinition
setIsWaterTrailerFilling(boolean isFilling, boolean noEventSend)Arguments
boolean | isFilling | new is filling state |
boolean | noEventSend | no event send |
147 | function WaterTrailer:setIsWaterTrailerFilling(isFilling, noEventSend) |
148 | local spec = self.spec_waterTrailer |
149 | if isFilling ~= spec.isFilling then |
150 | WaterTrailerSetIsFillingEvent.sendEvent(self, isFilling, noEventSend) |
151 | |
152 | spec.isFilling = isFilling |
153 | |
154 | if self.isClient then |
155 | if isFilling then |
156 | g_soundManager:playSample(spec.samples.refill) |
157 | else |
158 | g_soundManager:stopSample(spec.samples.refill) |
159 | end |
160 | end |
161 | end |
162 | end |