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
PlaceableHighPressureWasher
DescriptionSpecialization for placeablesFunctions
- canBeSold
- deactivateHighPressureWasher
- getHighPressureWasherIsPlayerInRange
- getHighPressureWasherLoad
- onDelete
- onHighPressureWasherLanceDeleted
- onHighPressureWasherLanceEquipped
- onHighPressureWasherPlayerDeleted
- onInfoTriggerEnter
- onInfoTriggerLeave
- onLoad
- onReadStream
- onUpdate
- onUpdateTick
- onWriteStream
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
- registerXMLPaths
- setIsHighPressureWasherTurnedOn
canBeSold
DescriptionDefinitioncanBeSold()Code
310 | function PlaceableHighPressureWasher:canBeSold(superFunc) |
311 | local canBeSold, warning = superFunc(self) |
312 | if not canBeSold then |
313 | return canBeSold, warning |
314 | end |
315 | |
316 | local spec = self.spec_highPressureWasher |
317 | if spec.currentPlayer ~= nil then |
318 | warning = g_i18n:getText("shop_messageReturnVehicleInUse") |
319 | return false, warning |
320 | end |
321 | |
322 | return true, nil |
323 | end |
deactivateHighPressureWasher
DescriptionDefinitiondeactivateHighPressureWasher()Code
285 | function PlaceableHighPressureWasher:deactivateHighPressureWasher() |
286 | local spec = self.spec_highPressureWasher |
287 | if self.isClient then |
288 | g_soundManager:playSample(spec.samples.switch) |
289 | spec.isTurningOff = true |
290 | spec.turnOffTime = g_currentMission.time + spec.turnOffDuration |
291 | end |
292 | |
293 | spec.isTurnedOn = false |
294 | if spec.lanceNode ~= nil then |
295 | setVisibility(spec.lanceNode, true) |
296 | end |
297 | |
298 | if spec.currentPlayer ~= nil then |
299 | if spec.currentPlayer:hasHandtoolEquipped() then |
300 | spec.currentPlayer.baseInformation.currentHandtool:removeDeleteListener(self, "onHighPressureWasherLanceDeleted") |
301 | spec.currentPlayer:unequipHandtool() |
302 | end |
303 | spec.currentPlayer:removeDeleteListener(self, "onHighPressureWasherPlayerDeleted") |
304 | spec.currentPlayer = nil |
305 | end |
306 | end |
getHighPressureWasherIsPlayerInRange
DescriptionDefinitiongetHighPressureWasherIsPlayerInRange()Code
327 | function PlaceableHighPressureWasher:getHighPressureWasherIsPlayerInRange(actionRadius, player) |
328 | if self.rootNode ~= nil then |
329 | local distance = calcDistanceFrom(player.rootNode, self.rootNode) |
330 | return distance < actionRadius, player, distance |
331 | end |
332 | |
333 | return false, nil, 0 |
334 | end |
getHighPressureWasherLoad
DescriptionDefinitiongetHighPressureWasherLoad()Code
202 | function PlaceableHighPressureWasher:getHighPressureWasherLoad() |
203 | local spec = self.spec_highPressureWasher |
204 | if spec.isTurningOff then |
205 | if g_currentMission.time < spec.turnOffTime then |
206 | return MathUtil.clamp((spec.turnOffTime - g_currentMission.time) / spec.turnOffDuration, 0, 1) |
207 | end |
208 | |
209 | return 0 |
210 | end |
211 | |
212 | return 1 |
213 | end |
onDelete
DescriptionDefinitiononDelete()Code
97 | function PlaceableHighPressureWasher:onDelete() |
98 | local spec = self.spec_highPressureWasher |
99 | |
100 | if spec.isTurnedOn then |
101 | self:setIsHighPressureWasherTurnedOn(false, nil, false) |
102 | end |
103 | |
104 | g_soundManager:deleteSamples(spec.samples) |
105 | g_currentMission.activatableObjectsSystem:removeActivatable(spec.activatable) |
106 | end |
onHighPressureWasherLanceDeleted
DescriptionDefinitiononHighPressureWasherLanceDeleted()Code
277 | function PlaceableHighPressureWasher:onHighPressureWasherLanceDeleted() |
278 | local spec = self.spec_highPressureWasher |
279 | spec.currentPlayer = nil |
280 | self:setIsHighPressureWasherTurnedOn(false, nil, nil) |
281 | end |
onHighPressureWasherLanceEquipped
DescriptionDefinitiononHighPressureWasherLanceEquipped()Code
263 | function PlaceableHighPressureWasher:onHighPressureWasherLanceEquipped(handTool) |
264 | handTool:addDeleteListener(self, "onHighPressureWasherLanceDeleted") |
265 | end |
onHighPressureWasherPlayerDeleted
DescriptionDefinitiononHighPressureWasherPlayerDeleted()Code
269 | function PlaceableHighPressureWasher:onHighPressureWasherPlayerDeleted() |
270 | local spec = self.spec_highPressureWasher |
271 | spec.currentPlayer = nil |
272 | self:setIsHighPressureWasherTurnedOn(false, nil, nil) |
273 | end |
onInfoTriggerEnter
DescriptionDefinitiononInfoTriggerEnter()Code
187 | function PlaceableHighPressureWasher:onInfoTriggerEnter() |
188 | local spec = self.spec_highPressureWasher |
189 | spec.isPlayerInTrigger = true |
190 | self:raiseActive() |
191 | end |
onInfoTriggerLeave
DescriptionDefinitiononInfoTriggerLeave()Code
195 | function PlaceableHighPressureWasher:onInfoTriggerLeave() |
196 | local spec = self.spec_highPressureWasher |
197 | spec.isPlayerInTrigger = false |
198 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
72 | function PlaceableHighPressureWasher:onLoad(savegame) |
73 | local spec = self.spec_highPressureWasher |
74 | local xmlFile = self.xmlFile |
75 | |
76 | spec.lanceNode = xmlFile:getValue("placeable.highPressureWasher.lance#node", nil, self.components, self.i3dMappings) |
77 | spec.handtoolXML = Utils.getFilename(xmlFile:getValue("placeable.highPressureWasher.handtool#filename"), self.baseDirectory) |
78 | spec.playerInRangeDistance = xmlFile:getValue("placeable.highPressureWasher.playerInRangeDistance", 3) |
79 | spec.actionRadius = xmlFile:getValue("placeable.highPressureWasher.actionRadius#distance", 10) |
80 | |
81 | if self.isClient then |
82 | spec.samples = {} |
83 | spec.samples.compressor = g_soundManager:loadSampleFromXML(xmlFile, "placeable.highPressureWasher.sounds", "compressor", self.baseDirectory, self.components, 0, AudioGroup.VEHICLE, self.i3dMappings, self) |
84 | spec.samples.switch = g_soundManager:loadSampleFromXML(xmlFile, "placeable.highPressureWasher.sounds", "switch", self.baseDirectory, self.components, 1, AudioGroup.VEHICLE, self.i3dMappings, self) |
85 | end |
86 | |
87 | spec.isTurnedOn = false |
88 | spec.isTurningOff = false |
89 | spec.turnOffTime = 0 |
90 | spec.turnOffDuration = 500 |
91 | spec.numPlayersInTrigger = 0 |
92 | spec.activatable = HighPressureWasherActivatable.new(self) |
93 | end |
onReadStream
DescriptionCalled on client side on joinDefinition
onReadStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
112 | function PlaceableHighPressureWasher:onReadStream(streamId, connection) |
113 | local isTurnedOn = streamReadBool(streamId) |
114 | if isTurnedOn then |
115 | local player = NetworkUtil.readNodeObject(streamId) |
116 | if player ~= nil then |
117 | self:setIsHighPressureWasherTurnedOn(isTurnedOn, player, true) |
118 | end |
119 | end |
120 | end |
onUpdate
DescriptionDefinitiononUpdate()Code
136 | function PlaceableHighPressureWasher:onUpdate(dt) |
137 | local spec = self.spec_highPressureWasher |
138 | if spec.currentPlayer ~= nil then |
139 | local isPlayerInRange, _, distance = self:getHighPressureWasherIsPlayerInRange(spec.actionRadius, spec.currentPlayer) |
140 | if not isPlayerInRange then |
141 | local maxRadius = spec.actionRadius + 5 |
142 | local distanceLeft = maxRadius - distance |
143 | |
144 | if distanceLeft > 0 then |
145 | if spec.currentPlayer == g_currentMission.player then |
146 | g_currentMission:showBlinkingWarning(string.format(g_i18n:getText("warning_hpwRangeRestriction"), distanceLeft), 100) |
147 | end |
148 | else |
149 | if self.isServer then |
150 | self:setIsHighPressureWasherTurnedOn(false, nil, false) |
151 | end |
152 | end |
153 | end |
154 | end |
155 | |
156 | if self.isClient then |
157 | if spec.isTurningOff then |
158 | if g_currentMission.time > spec.turnOffTime then |
159 | spec.isTurningOff = false |
160 | g_soundManager:stopSample(spec.samples.compressor) |
161 | end |
162 | end |
163 | end |
164 | |
165 | if spec.currentPlayer ~= nil or spec.isTurningOff or spec.isPlayerInTrigger then |
166 | self:raiseActive() |
167 | end |
168 | end |
onUpdateTick
DescriptionDefinitiononUpdateTick()Code
172 | function PlaceableHighPressureWasher:onUpdateTick(dt) |
173 | local spec = self.spec_highPressureWasher |
174 | |
175 | if g_currentMission.accessHandler:canPlayerAccess(self, g_currentMission.player) then |
176 | local isPlayerInRange, _ = self:getHighPressureWasherIsPlayerInRange(spec.playerInRangeDistance, g_currentMission.player) |
177 | if isPlayerInRange then |
178 | g_currentMission.activatableObjectsSystem:addActivatable(spec.activatable) |
179 | else |
180 | g_currentMission.activatableObjectsSystem:removeActivatable(spec.activatable) |
181 | end |
182 | end |
183 | end |
onWriteStream
DescriptionCalled on server side on joinDefinition
onWriteStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
126 | function PlaceableHighPressureWasher:onWriteStream(streamId, connection) |
127 | local spec = self.spec_highPressureWasher |
128 | streamWriteBool(streamId, spec.isTurnedOn) |
129 | if spec.isTurnedOn then |
130 | NetworkUtil.writeNodeObject(streamId, spec.currentPlayer) |
131 | end |
132 | 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 |
19 | function PlaceableHighPressureWasher.prerequisitesPresent(specializations) |
20 | return true |
21 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
43 | function PlaceableHighPressureWasher.registerEventListeners(placeableType) |
44 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableHighPressureWasher) |
45 | SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableHighPressureWasher) |
46 | SpecializationUtil.registerEventListener(placeableType, "onReadStream", PlaceableHighPressureWasher) |
47 | SpecializationUtil.registerEventListener(placeableType, "onWriteStream", PlaceableHighPressureWasher) |
48 | SpecializationUtil.registerEventListener(placeableType, "onUpdate", PlaceableHighPressureWasher) |
49 | SpecializationUtil.registerEventListener(placeableType, "onUpdateTick", PlaceableHighPressureWasher) |
50 | SpecializationUtil.registerEventListener(placeableType, "onInfoTriggerEnter", PlaceableHighPressureWasher) |
51 | SpecializationUtil.registerEventListener(placeableType, "onInfoTriggerLeave", PlaceableHighPressureWasher) |
52 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
25 | function PlaceableHighPressureWasher.registerFunctions(placeableType) |
26 | SpecializationUtil.registerFunction(placeableType, "deactivateHighPressureWasher", PlaceableHighPressureWasher.deactivateHighPressureWasher) |
27 | SpecializationUtil.registerFunction(placeableType, "onHighPressureWasherLanceDeleted", PlaceableHighPressureWasher.onHighPressureWasherLanceDeleted) |
28 | SpecializationUtil.registerFunction(placeableType, "onHighPressureWasherLanceEquipped", PlaceableHighPressureWasher.onHighPressureWasherLanceEquipped) |
29 | SpecializationUtil.registerFunction(placeableType, "onHighPressureWasherPlayerDeleted", PlaceableHighPressureWasher.onHighPressureWasherPlayerDeleted) |
30 | SpecializationUtil.registerFunction(placeableType, "setIsHighPressureWasherTurnedOn", PlaceableHighPressureWasher.setIsHighPressureWasherTurnedOn) |
31 | SpecializationUtil.registerFunction(placeableType, "getHighPressureWasherLoad", PlaceableHighPressureWasher.getHighPressureWasherLoad) |
32 | SpecializationUtil.registerFunction(placeableType, "getHighPressureWasherIsPlayerInRange", PlaceableHighPressureWasher.getHighPressureWasherIsPlayerInRange) |
33 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
37 | function PlaceableHighPressureWasher.registerOverwrittenFunctions(placeableType) |
38 | SpecializationUtil.registerOverwrittenFunction(placeableType, "canBeSold", PlaceableHighPressureWasher.canBeSold) |
39 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
56 | function PlaceableHighPressureWasher.registerXMLPaths(schema, basePath) |
57 | schema:setXMLSpecializationType("highPressureWasher") |
58 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".highPressureWasher.lance#node", "Lance node") |
59 | schema:register(XMLValueType.STRING, basePath .. ".highPressureWasher.handtool#filename", "Hand tool xml filename") |
60 | schema:register(XMLValueType.FLOAT, basePath .. ".highPressureWasher.playerInRangeDistance", "Player in range distance", 3) |
61 | schema:register(XMLValueType.FLOAT, basePath .. ".highPressureWasher.actionRadius#distance", "Action radius distance", 15) |
62 | SoundManager.registerSampleXMLPaths(schema, basePath .. ".highPressureWasher.sounds", "compressor") |
63 | SoundManager.registerSampleXMLPaths(schema, basePath .. ".highPressureWasher.sounds", "switch") |
64 | schema:register(XMLValueType.STRING, basePath .. ".highPressureWasher.exhaust#filename", "Exhaust effect i3d filename") |
65 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".highPressureWasher.exhaust#index", "Exhaust effect link node") |
66 | schema:setXMLSpecializationType() |
67 | end |
setIsHighPressureWasherTurnedOn
DescriptionDefinitionsetIsHighPressureWasherTurnedOn()Code
219 | function PlaceableHighPressureWasher:setIsHighPressureWasherTurnedOn(isTurnedOn, player, noEventSend) |
220 | local spec = self.spec_highPressureWasher |
221 | if spec.isTurnedOn ~= isTurnedOn then |
222 | if noEventSend == nil or noEventSend == false then |
223 | if g_server ~= nil then |
224 | g_server:broadcastEvent(PlaceableHighPressureWasherStateEvent.new(self, isTurnedOn, player), nil, nil, self) |
225 | else |
226 | g_client:getServerConnection():sendEvent(PlaceableHighPressureWasherStateEvent.new(self, isTurnedOn, player)) |
227 | end |
228 | end |
229 | |
230 | if isTurnedOn then |
231 | spec.isTurnedOn = isTurnedOn |
232 | |
233 | if player ~= nil then |
234 | spec.currentPlayer = player |
235 | spec.currentPlayer:addDeleteListener(self, "onHighPressureWasherPlayerDeleted") |
236 | if noEventSend ~= true then |
237 | spec.currentPlayer:equipHandtool(spec.handtoolXML, true, noEventSend, self.onHighPressureWasherLanceEquipped, self) |
238 | end |
239 | end |
240 | |
241 | if spec.isClient then |
242 | g_soundManager:playSample(spec.samples.switch) |
243 | g_soundManager:playSample(spec.samples.compressor) |
244 | |
245 | if spec.isTurningOff then |
246 | spec.isTurningOff = false |
247 | end |
248 | setVisibility(spec.lanceNode, false) |
249 | end |
250 | else |
251 | self:deactivateHighPressureWasher() |
252 | end |
253 | if spec.exhaustNode ~= nil then |
254 | setVisibility(spec.exhaustNode, isTurnedOn) |
255 | end |
256 | |
257 | self:raiseActive() |
258 | end |
259 | end |