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
FertilizingCultivator
DescriptionSpecialization for cultivators which also have a fertilizing functionFunctions
- initSpecialization
- onLoad
- prerequisitesPresent
- processCultivatorArea
- registerEventListeners
- registerOverwrittenFunctions
- setSprayerAITerrainDetailProhibitedRange
initSpecialization
DescriptionDefinitioninitSpecialization()Code
23 | function FertilizingCultivator.initSpecialization() |
24 | local schema = Vehicle.xmlSchema |
25 | schema:setXMLSpecializationType("FertilizingCultivator") |
26 | |
27 | schema:register(XMLValueType.BOOL, "vehicle.fertilizingCultivator#needsSetIsTurnedOn", "Needs to be turned on to spray", false) |
28 | |
29 | schema:setXMLSpecializationType() |
30 | end |
onLoad
DescriptionDefinitiononLoad()Code
47 | function FertilizingCultivator:onLoad(savegame) |
48 | local spec = self.spec_fertilizingCultivator |
49 | spec.needsSetIsTurnedOn = self.xmlFile:getValue("vehicle.fertilizingCultivator#needsSetIsTurnedOn", false) |
50 | self.spec_sprayer.useSpeedLimit = false |
51 | |
52 | self:clearAITerrainDetailRequiredRange() |
53 | self:updateCultivatorAIRequirements() |
54 | 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
58 | function FertilizingCultivator:processCultivatorArea(superFunc, workArea, dt) |
59 | local spec = self.spec_fertilizingCultivator |
60 | local specCultivator = self.spec_cultivator |
61 | local specSpray = self.spec_sprayer |
62 | |
63 | local xs,_,zs = getWorldTranslation(workArea.start) |
64 | local xw,_,zw = getWorldTranslation(workArea.width) |
65 | local xh,_,zh = getWorldTranslation(workArea.height) |
66 | |
67 | local cultivatorParams = specCultivator.workAreaParameters |
68 | local sprayerParams = specSpray.workAreaParameters |
69 | |
70 | -- we need to use fertilizer as spraying type because fertilizer is the final blocking value |
71 | local sprayTypeIndex = SprayType.FERTILIZER |
72 | |
73 | if sprayerParams.sprayFillLevel <= 0 or (spec.needsSetIsTurnedOn and not self:getIsTurnedOn()) then |
74 | sprayTypeIndex = nil |
75 | end |
76 | |
77 | local cultivatorChangedArea, cultivatorTotalArea |
78 | if specCultivator.useDeepMode then |
79 | cultivatorChangedArea, cultivatorTotalArea = FSDensityMapUtil.updateCultivatorArea(xs, zs, xw, zw, xh, zh, not cultivatorParams.limitToField, cultivatorParams.limitFruitDestructionToField, cultivatorParams.angle, sprayTypeIndex) |
80 | cultivatorChangedArea = cultivatorChangedArea + FSDensityMapUtil.updateVineCultivatorArea(xs, zs, xw, zw, xh, zh) |
81 | else |
82 | cultivatorChangedArea, cultivatorTotalArea = FSDensityMapUtil.updateDiscHarrowArea(xs, zs, xw, zw, xh, zh, not cultivatorParams.limitToField, cultivatorParams.limitFruitDestructionToField, cultivatorParams.angle, sprayTypeIndex) |
83 | cultivatorChangedArea = cultivatorChangedArea + FSDensityMapUtil.updateVineCultivatorArea(xs, zs, xw, zw, xh, zh) |
84 | end |
85 | |
86 | cultivatorParams.lastChangedArea = cultivatorParams.lastChangedArea + cultivatorChangedArea |
87 | cultivatorParams.lastTotalArea = cultivatorParams.lastTotalArea + cultivatorTotalArea |
88 | cultivatorParams.lastStatsArea = cultivatorParams.lastStatsArea + cultivatorChangedArea |
89 | |
90 | if specCultivator.isSubsoiler then |
91 | FSDensityMapUtil.updateSubsoilerArea(xs, zs, xw, zw, xh, zh) |
92 | end |
93 | |
94 | FSDensityMapUtil.eraseTireTrack(xs, zs, xw, zw, xh, zh) |
95 | |
96 | if sprayTypeIndex ~= nil then |
97 | local sprayAmount = specSpray.doubledAmountIsActive and 2 or 1 |
98 | local sprayChangedArea, sprayTotalArea = FSDensityMapUtil.updateSprayArea(xs, zs, xw, zw, xh, zh, sprayTypeIndex, sprayAmount) |
99 | |
100 | sprayerParams.lastChangedArea = sprayerParams.lastChangedArea + sprayChangedArea |
101 | sprayerParams.lastTotalArea = sprayerParams.lastTotalArea + sprayTotalArea |
102 | sprayerParams.lastStatsArea = 0 |
103 | sprayerParams.isActive = true |
104 | end |
105 | |
106 | specCultivator.isWorking = true |
107 | |
108 | return cultivatorChangedArea, cultivatorTotalArea |
109 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
41 | function FertilizingCultivator.registerEventListeners(vehicleType) |
42 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", FertilizingCultivator) |
43 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
34 | function FertilizingCultivator.registerOverwrittenFunctions(vehicleType) |
35 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "processCultivatorArea", FertilizingCultivator.processCultivatorArea) |
36 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "setSprayerAITerrainDetailProhibitedRange", FertilizingCultivator.setSprayerAITerrainDetailProhibitedRange) |
37 | end |
setSprayerAITerrainDetailProhibitedRange
DescriptionDefinitionsetSprayerAITerrainDetailProhibitedRange()Code
113 | function FertilizingCultivator:setSprayerAITerrainDetailProhibitedRange(superFunc, fillType) |
114 | if self.addAITerrainDetailProhibitedRange ~= nil then |
115 | self:clearAITerrainDetailProhibitedRange() |
116 | |
117 | local sprayTypeDesc = g_sprayTypeManager:getSprayTypeByFillTypeIndex(fillType) |
118 | if sprayTypeDesc ~= nil then |
119 | local mission = g_currentMission |
120 | local sprayTypeMapId, sprayTypeFirstChannel, sprayTypeNumChannels = mission.fieldGroundSystem:getDensityMapData(FieldDensityMap.SPRAY_TYPE) |
121 | local sprayLevelMapId, sprayLevelFirstChannel, sprayLevelNumChannels = mission.fieldGroundSystem:getDensityMapData(FieldDensityMap.SPRAY_LEVEL) |
122 | local sprayLevelMaxValue = mission.fieldGroundSystem:getMaxValue(FieldDensityMap.SPRAY_LEVEL) |
123 | self:addAITerrainDetailProhibitedRange(sprayTypeDesc.sprayGroundType, sprayTypeDesc.sprayGroundType, sprayTypeFirstChannel, sprayTypeNumChannels) |
124 | -- TODO enable after field crops query support bitVectorMaps |
125 | --self:addAIFruitProhibitions(0, sprayTypeDesc.sprayGroundType, sprayTypeDesc.sprayGroundType, sprayTypeMapId, sprayTypeFirstChannel, sprayTypeNumChannels) |
126 | --self:addAIFruitProhibitions(0, sprayLevelMaxValue, sprayLevelMaxValue, sprayLevelMapId, sprayLevelFirstChannel, sprayLevelNumChannels) |
127 | end |
128 | end |
129 | end |