Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- AIConveyorBelt
- AIImplement
- AIVehicle
- AnimatedVehicle
- ArticulatedAxis
- Attachable
- AttacherJointControl
- AttacherJoints
- BaleGrab
- BaleLoader
- Baler
- BaleWrapper
- BaseMaterial
- BunkerSiloCompacter
- BunkerSiloInteractor
- BuyableBale
- CCTDrivable
- Combine
- ConnectionHoses
- ConveyorBelt
- Cover
- CrabSteering
- Crawlers
- Cultivator
- Cutter
- Cylindered
- CylinderedFoldable
- Dashboard
- Dischargeable
- Drivable
- DynamicallyLoadedParts
- DynamicMountAttacher
- Enterable
- FertilizingCultivator
- FertilizingSowingMachine
- FillTriggerVehicle
- FillUnit
- FillVolume
- Foldable
- FoliageBending
- ForageWagon
- FrontloaderAttacher
- FruitPreparer
- GroundAdjustedNodes
- GroundReference
- Honk
- HookLiftContainer
- HookLiftTrailer
- IKChains
- JigglingParts
- Leveler
- Lights
- LivestockTrailer
- Locomotive
- LogGrab
- ManureBarrel
- MixerWagon
- Motorized
- Mountable
- Mower
- Pickup
- Pipe
- Plow
- PowerConsumer
- PowerTakeOffs
- RandomlyMovingParts
- ReceivingHopper
- ReverseDriving
- Rideable
- RidgeMarker
- Roller
- Ropes
- SemiTrailerFront
- Shovel
- SlopeCompensation
- SmartAttach
- SowingMachine
- SpeedRotatingParts
- SplineVehicle
- Sprayer
- StrawBlower
- StumpCutter
- Suspensions
- Tedder
- TensionBeltObject
- TensionBelts
- TipOccluder
- Trailer
- TreePlanter
- TreeSaw
- TurnOnVehicle
- Washable
- WaterTrailer
- Wearable
- Weeder
- Wheels
- Windrower
- Wipers
- WoodCrusher
- WoodHarvester
- WorkArea
- WorkMode
- WorkParticles
- 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
FertilizingCultivator
DescriptionSpecialization for cultivators which also have a fertilizing functionFunctions
- onLoad
- prerequisitesPresent
- processCultivatorArea
- registerEventListeners
- registerOverwrittenFunctions
- setSprayerAITerrainDetailProhibitedRange
onLoad
DescriptionDefinitiononLoad()Code
36 | function FertilizingCultivator:onLoad(savegame) |
37 | local spec = self.spec_fertilizingCultivator |
38 | spec.needsSetIsTurnedOn = Utils.getNoNil(getXMLBool(self.xmlFile, "vehicle.fertilizingCultivator#needsSetIsTurnedOn"), false) |
39 | self.spec_sprayer.useSpeedLimit = false |
40 | 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 |
17 | function FertilizingCultivator.prerequisitesPresent(specializations) |
18 | return SpecializationUtil.hasSpecialization(Cultivator, specializations) and SpecializationUtil.hasSpecialization(Sprayer, specializations) |
19 | end |
processCultivatorArea
DescriptionDefinitionprocessCultivatorArea()Code
44 | function FertilizingCultivator:processCultivatorArea(superFunc, workArea, dt) |
45 | local spec = self.spec_fertilizingCultivator |
46 | local specCultivator = self.spec_cultivator |
47 | local specSpray = self.spec_sprayer |
48 | |
49 | local xs,_,zs = getWorldTranslation(workArea.start) |
50 | local xw,_,zw = getWorldTranslation(workArea.width) |
51 | local xh,_,zh = getWorldTranslation(workArea.height) |
52 | |
53 | local cultivatorParams = specCultivator.workAreaParameters |
54 | local sprayerParams = specSpray.workAreaParameters |
55 | |
56 | -- we need to use fertilizer as spraying type because fertilizer is the final blocking value |
57 | local sprayTypeIndex = SprayType.FERTILIZER |
58 | |
59 | if sprayerParams.sprayFillLevel <= 0 or (spec.needsSetIsTurnedOn and not self:getIsTurnedOn()) then |
60 | sprayTypeIndex = nil |
61 | end |
62 | |
63 | local cultivatorChangedArea, cultivatorTotalArea = FSDensityMapUtil.updateCultivatorArea(xs, zs, xw, zw, xh, zh, not cultivatorParams.limitToField, not cultivatorParams.limitGrassDestructionToField, cultivatorParams.angle, sprayTypeIndex) |
64 | cultivatorParams.lastChangedArea = cultivatorParams.lastChangedArea + cultivatorChangedArea |
65 | cultivatorParams.lastTotalArea = cultivatorParams.lastTotalArea + cultivatorTotalArea |
66 | cultivatorParams.lastStatsArea = cultivatorParams.lastStatsArea + cultivatorChangedArea |
67 | |
68 | if specCultivator.isSubsoiler then |
69 | FSDensityMapUtil.updateSubsoilerArea(xs, zs, xw, zw, xh, zh) |
70 | end |
71 | |
72 | FSDensityMapUtil.eraseTireTrack(xs, zs, xw, zw, xh, zh) |
73 | |
74 | if sprayTypeIndex ~= nil then |
75 | local sprayChangedArea, sprayTotalArea = FSDensityMapUtil.updateSprayArea(xs, zs, xw, zw, xh, zh, sprayTypeIndex) |
76 | |
77 | sprayerParams.lastChangedArea = sprayerParams.lastChangedArea + sprayChangedArea |
78 | sprayerParams.lastTotalArea = sprayerParams.lastTotalArea + sprayTotalArea |
79 | sprayerParams.lastStatsArea = 0 |
80 | sprayerParams.isActive = true |
81 | end |
82 | |
83 | specCultivator.isWorking = true |
84 | |
85 | return cultivatorChangedArea, cultivatorTotalArea |
86 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
30 | function FertilizingCultivator.registerEventListeners(vehicleType) |
31 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", FertilizingCultivator) |
32 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
23 | function FertilizingCultivator.registerOverwrittenFunctions(vehicleType) |
24 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "processCultivatorArea", FertilizingCultivator.processCultivatorArea) |
25 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "setSprayerAITerrainDetailProhibitedRange", FertilizingCultivator.setSprayerAITerrainDetailProhibitedRange) |
26 | end |
setSprayerAITerrainDetailProhibitedRange
DescriptionDefinitionsetSprayerAITerrainDetailProhibitedRange()Code
90 | function FertilizingCultivator:setSprayerAITerrainDetailProhibitedRange(superFunc, fillType) |
91 | if self.addAITerrainDetailProhibitedRange ~= nil then |
92 | self:clearAITerrainDetailProhibitedRange() |
93 | |
94 | local sprayTypeDesc = g_sprayTypeManager:getSprayTypeByFillTypeIndex(fillType) |
95 | if sprayTypeDesc ~= nil then |
96 | -- we check here for fertilizing bit instead of ground type bit, because we directly cultivate the ground type |
97 | self:addAITerrainDetailProhibitedRange(1, 2, g_currentMission.sprayFirstChannel, g_currentMission.sprayNumChannels) |
98 | self:addAITerrainDetailProhibitedRange(g_currentMission.sprayLevelMaxValue, g_currentMission.sprayLevelMaxValue, g_currentMission.sprayLevelFirstChannel, g_currentMission.sprayLevelNumChannels) |
99 | end |
100 | end |
101 | end |