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
FertilizingSowingMachine
DescriptionSpecialization for sowing machines which also have a fertilizing functionFunctions
- getAreEffectsVisible
- getUseSprayerAIRequirements
- initSpecialization
- onLoad
- prerequisitesPresent
- processSowingMachineArea
- registerEventListeners
- registerOverwrittenFunctions
getAreEffectsVisible
DescriptionDefinitiongetAreEffectsVisible()Code
159 | function FertilizingSowingMachine:getAreEffectsVisible(superFunc) |
160 | return superFunc(self) and self:getFillUnitFillType(self:getSprayerFillUnitIndex()) ~= FillType.UNKNOWN |
161 | end |
getUseSprayerAIRequirements
DescriptionDefinitiongetUseSprayerAIRequirements()Code
153 | function FertilizingSowingMachine:getUseSprayerAIRequirements(superFunc) |
154 | return false |
155 | end |
initSpecialization
DescriptionDefinitioninitSpecialization()Code
23 | function FertilizingSowingMachine.initSpecialization() |
24 | local schema = Vehicle.xmlSchema |
25 | schema:setXMLSpecializationType("FertilizingSowingMachine") |
26 | |
27 | schema:register(XMLValueType.BOOL, "vehicle.fertilizingSowingMachine#needsSetIsTurnedOn", "Needs to be turned on to spray", false) |
28 | |
29 | schema:setXMLSpecializationType() |
30 | end |
onLoad
DescriptionDefinitiononLoad()Code
48 | function FertilizingSowingMachine:onLoad(savegame) |
49 | local spec = self.spec_fertilizingSowingMachine |
50 | spec.needsSetIsTurnedOn = self.xmlFile:getValue("vehicle.fertilizingSowingMachine#needsSetIsTurnedOn", false) |
51 | |
52 | self.spec_sprayer.needsToBeFilledToTurnOn = false |
53 | self.spec_sprayer.useSpeedLimit = false |
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 FertilizingSowingMachine.prerequisitesPresent(specializations) |
18 | return SpecializationUtil.hasSpecialization(SowingMachine, specializations) and SpecializationUtil.hasSpecialization(Sprayer, specializations) |
19 | end |
processSowingMachineArea
DescriptionDefinitionprocessSowingMachineArea()Code
58 | function FertilizingSowingMachine:processSowingMachineArea(superFunc, workArea, dt) |
59 | local spec = self.spec_fertilizingSowingMachine |
60 | local specSowingMachine = self.spec_sowingMachine |
61 | local specSpray = self.spec_sprayer |
62 | |
63 | local sprayerParams = specSpray.workAreaParameters |
64 | local sowingParams = specSowingMachine.workAreaParameters |
65 | local changedArea, totalArea |
66 | |
67 | self.spec_sowingMachine.isWorking = self:getLastSpeed() > 0.5 |
68 | |
69 | if not sowingParams.isActive then |
70 | return 0, 0 |
71 | end |
72 | |
73 | if not self:getIsAIActive() or not g_currentMission.missionInfo.helperBuySeeds then |
74 | if sowingParams.seedsVehicle == nil then |
75 | if self:getIsAIActive() then |
76 | local rootVehicle = self.rootVehicle |
77 | rootVehicle:stopCurrentAIJob(AIMessageErrorOutOfFill.new()) |
78 | end |
79 | |
80 | return 0, 0 |
81 | end |
82 | end |
83 | |
84 | -- stop the sowing machine if the fertilizer tank was filled and got empty |
85 | -- do not stop if the tank was all the time empty |
86 | if not g_currentMission.missionInfo.helperBuyFertilizer then |
87 | if self:getIsAIActive() then |
88 | if sprayerParams.sprayFillType == nil or sprayerParams.sprayFillType == FillType.UNKNOWN then |
89 | if sprayerParams.lastAIHasSprayed ~= nil then |
90 | local rootVehicle = self.rootVehicle |
91 | rootVehicle:stopCurrentAIJob(AIMessageErrorOutOfFill.new()) |
92 | sprayerParams.lastAIHasSprayed = nil |
93 | end |
94 | else |
95 | sprayerParams.lastAIHasSprayed = true |
96 | end |
97 | end |
98 | end |
99 | |
100 | if not sowingParams.canFruitBePlanted then |
101 | return 0, 0 |
102 | end |
103 | |
104 | -- we need to use fertilizer as spraying type because fertilizer is the final blocking value |
105 | local sprayTypeIndex = SprayType.FERTILIZER |
106 | if sprayerParams.sprayFillLevel <= 0 or (spec.needsSetIsTurnedOn and not self:getIsTurnedOn()) then |
107 | sprayTypeIndex = nil |
108 | end |
109 | |
110 | local startX,_,startZ = getWorldTranslation(workArea.start) |
111 | local widthX,_,widthZ = getWorldTranslation(workArea.width) |
112 | local heightX,_,heightZ = getWorldTranslation(workArea.height) |
113 | |
114 | if not specSowingMachine.useDirectPlanting then |
115 | changedArea, totalArea = FSDensityMapUtil.updateSowingArea(sowingParams.seedsFruitType, startX, startZ, widthX, widthZ, heightX, heightZ, sowingParams.fieldGroundType, sowingParams.angle, nil, sprayTypeIndex) |
116 | else |
117 | changedArea, totalArea = FSDensityMapUtil.updateDirectSowingArea(sowingParams.seedsFruitType, startX, startZ, widthX, widthZ, heightX, heightZ, sowingParams.fieldGroundType, sowingParams.angle, nil, sprayTypeIndex) |
118 | end |
119 | |
120 | self.spec_sowingMachine.isProcessing = self.spec_sowingMachine.isWorking |
121 | |
122 | if sprayTypeIndex ~= nil then |
123 | local sprayAmount = specSpray.doubledAmountIsActive and 2 or 1 |
124 | local sprayChangedArea, sprayTotalArea = FSDensityMapUtil.updateSprayArea(startX, startZ, widthX, widthZ, heightX, heightZ, sprayTypeIndex, sprayAmount) |
125 | |
126 | sprayerParams.lastChangedArea = sprayerParams.lastChangedArea + sprayChangedArea |
127 | sprayerParams.lastTotalArea = sprayerParams.lastTotalArea + sprayTotalArea |
128 | sprayerParams.lastStatsArea = 0 |
129 | sprayerParams.isActive = true |
130 | sprayerParams.lastSprayTime = g_time |
131 | |
132 | local stats = g_currentMission:farmStats(self:getLastTouchedFarmlandFarmId()) |
133 | local ha = MathUtil.areaToHa(sprayerParams.lastChangedArea, g_currentMission:getFruitPixelsToSqm()) |
134 | stats:updateStats("sprayedHectares", ha) |
135 | stats:updateStats("sprayedTime", dt/(1000*60)) |
136 | stats:updateStats("sprayUsage", sprayerParams.usage) |
137 | end |
138 | |
139 | sowingParams.lastChangedArea = sowingParams.lastChangedArea + changedArea |
140 | sowingParams.lastStatsArea = sowingParams.lastStatsArea + changedArea |
141 | sowingParams.lastTotalArea = sowingParams.lastTotalArea + totalArea |
142 | |
143 | -- remove tireTracks |
144 | FSDensityMapUtil.eraseTireTrack(startX, startZ, widthX, widthZ, heightX, heightZ) |
145 | |
146 | self:updateMissionSowingWarning(startX, startZ) |
147 | |
148 | return changedArea, totalArea |
149 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
42 | function FertilizingSowingMachine.registerEventListeners(vehicleType) |
43 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", FertilizingSowingMachine) |
44 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
34 | function FertilizingSowingMachine.registerOverwrittenFunctions(vehicleType) |
35 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "processSowingMachineArea", FertilizingSowingMachine.processSowingMachineArea) |
36 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getUseSprayerAIRequirements", FertilizingSowingMachine.getUseSprayerAIRequirements) |
37 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getAreEffectsVisible", FertilizingSowingMachine.getAreEffectsVisible) |
38 | end |