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
Roller
DescriptionSpecialization for roller used for removing fields/terrainDetailLayerFunctions
- doCheckSpeedLimit
- getDefaultSpeedLimit
- getDirtMultiplier
- getDoGroundManipulation
- getIsWorkAreaActive
- getWearMultiplier
- initSpecialization
- onDeactivate
- onDelete
- onEndWorkAreaProcessing
- onLoad
- onPostAttach
- onStartWorkAreaProcessing
- prerequisitesPresent
- processRollerArea
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
- registerRollerXMLPaths
- updateRollerAIRequirements
doCheckSpeedLimit
DescriptionDefinitiondoCheckSpeedLimit()Code
235 | function Roller:doCheckSpeedLimit(superFunc) |
236 | local spec = self.spec_roller |
237 | |
238 | return superFunc(self) or spec.isWorking |
239 | end |
getDefaultSpeedLimit
DescriptionDefinitiongetDefaultSpeedLimit()Code
343 | function Roller.getDefaultSpeedLimit() |
344 | return 15 |
345 | end |
getDirtMultiplier
DescriptionDefinitiongetDirtMultiplier()Code
250 | function Roller:getDirtMultiplier(superFunc) |
251 | local spec = self.spec_roller |
252 | local multiplier = superFunc(self) |
253 | |
254 | if spec.isWorking then |
255 | multiplier = multiplier + self:getWorkDirtMultiplier() |
256 | end |
257 | |
258 | return multiplier |
259 | end |
getDoGroundManipulation
DescriptionDefinitiongetDoGroundManipulation()Code
243 | function Roller:getDoGroundManipulation(superFunc) |
244 | local spec = self.spec_roller |
245 | return superFunc(self) and spec.isWorking |
246 | end |
getIsWorkAreaActive
DescriptionDefinitiongetIsWorkAreaActive()Code
277 | function Roller:getIsWorkAreaActive(superFunc, workArea) |
278 | if workArea.type == WorkAreaType.ROLLER then |
279 | local spec = self.spec_roller |
280 | if spec.startActivationTime > g_currentMission.time then |
281 | return false |
282 | end |
283 | |
284 | if spec.onlyActiveWhenLowered and not self:getIsLowered() then |
285 | return false |
286 | end |
287 | end |
288 | |
289 | return superFunc(self, workArea) |
290 | end |
getWearMultiplier
DescriptionReturns current wear multiplierDefinition
getWearMultiplier()Return Values
float | dirtMultiplier | current wear multiplier |
264 | function Roller:getWearMultiplier(superFunc) |
265 | local spec = self.spec_roller |
266 | local multiplier = superFunc(self) |
267 | |
268 | if spec.isWorking then |
269 | multiplier = multiplier + self:getWorkWearMultiplier() |
270 | end |
271 | |
272 | return multiplier |
273 | end |
initSpecialization
DescriptionDefinitioninitSpecialization()Code
28 | function Roller.initSpecialization() |
29 | g_configurationManager:addConfigurationType("roller", g_i18n:getText("configuration_design"), "roller", nil, nil, nil, ConfigurationUtil.SELECTOR_MULTIOPTION) |
30 | g_workAreaTypeManager:addWorkAreaType("roller", false) |
31 | |
32 | local schema = Vehicle.xmlSchema |
33 | schema:setXMLSpecializationType("Roller") |
34 | |
35 | Roller.registerRollerXMLPaths(schema, "vehicle.roller") |
36 | Roller.registerRollerXMLPaths(schema, "vehicle.roller.rollerConfigurations.rollerConfiguration(?).roller") |
37 | |
38 | ObjectChangeUtil.registerObjectChangeXMLPaths(schema, "vehicle.roller.rollerConfigurations.rollerConfiguration(?)") |
39 | |
40 | schema:setXMLSpecializationType() |
41 | end |
onDeactivate
DescriptionDefinitiononDeactivate()Code
335 | function Roller:onDeactivate() |
336 | local spec = self.spec_roller |
337 | g_soundManager:stopSample(spec.samples.work) |
338 | spec.isWorkSamplePlaying = false |
339 | end |
onDelete
DescriptionDefinitiononDelete()Code
142 | function Roller:onDelete() |
143 | local spec = self.spec_roller |
144 | g_soundManager:deleteSamples(spec.samples) |
145 | end |
onEndWorkAreaProcessing
DescriptionDefinitiononEndWorkAreaProcessing()Code
305 | function Roller:onEndWorkAreaProcessing(dt, hasProcessed) |
306 | local spec = self.spec_roller |
307 | |
308 | if self.isClient then |
309 | if spec.isWorking then |
310 | if not spec.isWorkSamplePlaying then |
311 | g_soundManager:playSample(spec.samples.work) |
312 | spec.isWorkSamplePlaying = true |
313 | end |
314 | else |
315 | if spec.isWorkSamplePlaying then |
316 | g_soundManager:stopSample(spec.samples.work) |
317 | spec.isWorkSamplePlaying = false |
318 | end |
319 | end |
320 | end |
321 | end |
onLoad
DescriptionDefinitiononLoad()Code
90 | function Roller:onLoad(savegame) |
91 | local spec = self.spec_roller |
92 | |
93 | XMLUtil.checkDeprecatedXMLElements(self.xmlFile, "vehicle.rollerSound", "vehicle.roller.sounds.work") --FS17 to FS19 |
94 | XMLUtil.checkDeprecatedXMLElements(self.xmlFile, "vehicle.onlyActiveWhenLowered#value", "vehicle.roller#onlyActiveWhenLowered") --FS17 to FS19 |
95 | |
96 | local rollerConfigurationId = Utils.getNoNil(self.configurations["roller"], 1) |
97 | local configKey = string.format("vehicle.roller.rollerConfigurations.rollerConfiguration(%d).roller", rollerConfigurationId - 1) |
98 | ObjectChangeUtil.updateObjectChanges(self.xmlFile, "vehicle.roller.rollerConfigurations.rollerConfiguration", rollerConfigurationId, self.components, self) |
99 | |
100 | if not self.xmlFile:hasProperty(configKey) then |
101 | configKey = "vehicle.roller" |
102 | end |
103 | |
104 | spec.directionNode = self.xmlFile:getValue(configKey .. ".directionNode#node", self.components[1].node, self.components, self.i3dMappings) |
105 | |
106 | if self.isClient then |
107 | spec.samples = {} |
108 | spec.isWorkSamplePlaying = false |
109 | spec.samples.work = g_soundManager:loadSampleFromXML(self.xmlFile, configKey .. ".sounds", "work", self.baseDirectory, self.components, 0, AudioGroup.VEHICLE, self.i3dMappings, self) |
110 | end |
111 | |
112 | spec.isSoilRoller = self.xmlFile:getValue(configKey .. "#isSoilRoller") |
113 | spec.isGrassRoller = self.xmlFile:getValue(configKey .. "#isGrassRoller") |
114 | if spec.isSoilRoller == nil and spec.isGrassRoller == nil then |
115 | spec.isSoilRoller = true |
116 | spec.isGrassRoller = false |
117 | else |
118 | if spec.isGrassRoller == nil then |
119 | spec.isGrassRoller = false |
120 | end |
121 | if spec.isSoilRoller == nil then |
122 | spec.isSoilRoller = false |
123 | end |
124 | end |
125 | |
126 | spec.grassFruitTypes = {FruitType.GRASS, FruitType.MEADOW} |
127 | |
128 | spec.usingAIRequirements = self.xmlFile:getValue(configKey .. "#usingAIRequirements", true) |
129 | spec.onlyActiveWhenLowered = self.xmlFile:getValue(configKey .. "#onlyActiveWhenLowered", true) |
130 | spec.startActivationTimeout = 2000 |
131 | spec.startActivationTime = 0 |
132 | spec.isWorking = false |
133 | spec.angle = 0 |
134 | |
135 | self:updateRollerAIRequirements() |
136 | |
137 | spec.dirtyFlag = self:getNextDirtyFlag() |
138 | end |
onPostAttach
DescriptionCalled after vehicle gets attachedDefinition
onPostAttach(table attacherVehicle, integer inputJointDescIndex, integer jointDescIndex)Arguments
table | attacherVehicle | attacher vehicle |
integer | inputJointDescIndex | index of input attacher joint |
integer | jointDescIndex | index of attacher joint it gets attached to |
328 | function Roller:onPostAttach(attacherVehicle, inputJointDescIndex, jointDescIndex) |
329 | local spec = self.spec_roller |
330 | spec.startActivationTime = g_currentMission.time + spec.startActivationTimeout |
331 | end |
onStartWorkAreaProcessing
DescriptionDefinitiononStartWorkAreaProcessing()Code
294 | function Roller:onStartWorkAreaProcessing(dt) |
295 | local spec = self.spec_roller |
296 | |
297 | local dx,_,dz = localDirectionToWorld(spec.directionNode, 0, 0, 1) |
298 | |
299 | spec.angle = FSDensityMapUtil.convertToDensityMapAngle(MathUtil.getYRotationFromDirection(dx, dz), g_currentMission.fieldGroundSystem:getGroundAngleMaxValue()) |
300 | spec.isWorking = false |
301 | end |
prerequisitesPresent
DescriptionDefinitionprerequisitesPresent()Code
56 | function Roller.prerequisitesPresent(specializations) |
57 | return SpecializationUtil.hasSpecialization(WorkArea, specializations) |
58 | end |
processRollerArea
DescriptionDefinitionprocessRollerArea()Code
149 | function Roller:processRollerArea(workArea, dt) |
150 | local spec = self.spec_roller |
151 | |
152 | local xs,_,zs = getWorldTranslation(workArea.start) |
153 | local xw,_,zw = getWorldTranslation(workArea.width) |
154 | local xh,_,zh = getWorldTranslation(workArea.height) |
155 | |
156 | local realArea |
157 | if spec.isGrassRoller then |
158 | realArea, _ = FSDensityMapUtil.updateGrassRollerArea(xs, zs, xw, zw, xh, zh, not spec.isSoilRoller) |
159 | end |
160 | if spec.isSoilRoller then |
161 | realArea, _ = FSDensityMapUtil.updateRollerArea(xs, zs, xw, zw, xh, zh, spec.angle) |
162 | end |
163 | |
164 | FSDensityMapUtil.eraseTireTrack(xs, zs, xw, zw, xh, zh) |
165 | |
166 | spec.isWorking = self:getLastSpeed() > 0.5 |
167 | |
168 | return realArea |
169 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
79 | function Roller.registerEventListeners(vehicleType) |
80 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", Roller) |
81 | SpecializationUtil.registerEventListener(vehicleType, "onDelete", Roller) |
82 | SpecializationUtil.registerEventListener(vehicleType, "onPostAttach", Roller) |
83 | SpecializationUtil.registerEventListener(vehicleType, "onDeactivate", Roller) |
84 | SpecializationUtil.registerEventListener(vehicleType, "onStartWorkAreaProcessing", Roller) |
85 | SpecializationUtil.registerEventListener(vehicleType, "onEndWorkAreaProcessing", Roller) |
86 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
62 | function Roller.registerFunctions(vehicleType) |
63 | SpecializationUtil.registerFunction(vehicleType, "processRollerArea", Roller.processRollerArea) |
64 | SpecializationUtil.registerFunction(vehicleType, "updateRollerAIRequirements", Roller.updateRollerAIRequirements) |
65 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
69 | function Roller.registerOverwrittenFunctions(vehicleType) |
70 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "doCheckSpeedLimit", Roller.doCheckSpeedLimit) |
71 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getDoGroundManipulation", Roller.getDoGroundManipulation) |
72 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getDirtMultiplier", Roller.getDirtMultiplier) |
73 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getWearMultiplier", Roller.getWearMultiplier) |
74 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getIsWorkAreaActive", Roller.getIsWorkAreaActive) |
75 | end |
registerRollerXMLPaths
DescriptionDefinitionregisterRollerXMLPaths()Code
45 | function Roller.registerRollerXMLPaths(schema, basePath) |
46 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".directionNode#node", "Roller direction node") |
47 | schema:register(XMLValueType.BOOL, basePath .. "#onlyActiveWhenLowered", "Only active when lowered", true) |
48 | schema:register(XMLValueType.BOOL, basePath .. "#isSoilRoller", "If roller is for soil", true) |
49 | schema:register(XMLValueType.BOOL, basePath .. "#isGrassRoller", "If roller is for grassland", false) |
50 | schema:register(XMLValueType.BOOL, basePath .. "#usingAIRequirements", "Tool using roller ai requirements", true) |
51 | SoundManager.registerSampleXMLPaths(schema, basePath .. ".sounds", "work") |
52 | end |
updateRollerAIRequirements
DescriptionDefinitionupdateRollerAIRequirements()Code
173 | function Roller:updateRollerAIRequirements() |
174 | if self.clearAITerrainDetailRequiredRange ~= nil then |
175 | local spec = self.spec_roller |
176 | |
177 | if not spec.usingAIRequirements then |
178 | return |
179 | end |
180 | |
181 | local hasSowingMachine = false |
182 | if SpecializationUtil.hasSpecialization(SowingMachine, self.specializations) then |
183 | if self:getUseSowingMachineAIRequirements() then |
184 | hasSowingMachine = true |
185 | end |
186 | end |
187 | |
188 | self:clearAIFruitRequirements() |
189 | self:clearAIFruitProhibitions() |
190 | self:clearAITerrainDetailRequiredRange() |
191 | |
192 | -- if we also have a active sowing machine attached the sowingMachine is fully handling it |
193 | if not hasSowingMachine then |
194 | if spec.isGrassRoller and not spec.isSoilRoller then |
195 | self:addAIGroundTypeRequirements(Roller.AI_REQUIRED_GROUND_TYPES_GRASS) |
196 | |
197 | for i=1, #spec.grassFruitTypes do |
198 | local fruitTypeDesc = g_fruitTypeManager:getFruitTypeByIndex(spec.grassFruitTypes[i]) |
199 | if fruitTypeDesc.terrainDataPlaneId ~= nil then |
200 | self:addAIFruitRequirement(fruitTypeDesc.index, 2, fruitTypeDesc.cutState + 1) |
201 | end |
202 | end |
203 | end |
204 | |
205 | if spec.isSoilRoller then |
206 | self:addAIGroundTypeRequirements(Roller.AI_REQUIRED_GROUND_TYPES) |
207 | |
208 | for fruitTypeIndex, fruitType in pairs(g_fruitTypeManager:getFruitTypes()) do |
209 | if fruitType.terrainDataPlaneId ~= nil then |
210 | if not spec.isGrassRoller or fruitTypeIndex ~= FruitType.GRASS then |
211 | -- rolling only allowed in first growth state |
212 | self:addAIFruitProhibitions(fruitType.index, 2, 15) |
213 | end |
214 | end |
215 | end |
216 | |
217 | -- for combined tools we allow working on all grass states |
218 | if spec.isGrassRoller then |
219 | self:addAIGroundTypeRequirements(Roller.AI_REQUIRED_GROUND_TYPES_GRASS) |
220 | |
221 | for i=1, #spec.grassFruitTypes do |
222 | local fruitTypeDesc = g_fruitTypeManager:getFruitTypeByIndex(spec.grassFruitTypes[i]) |
223 | if fruitTypeDesc.terrainDataPlaneId ~= nil then |
224 | self:addAIFruitProhibitions(fruitTypeDesc.index, 1, 1) |
225 | end |
226 | end |
227 | end |
228 | end |
229 | end |
230 | end |
231 | end |