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
ManureSensor
DescriptionSpecialization for manure sensorsFunctions
- getCurrentNitrogenLevelOffset
- getCurrentNitrogenUsageLevelOffset
- getIsUsingExactNitrogenAmount
- getManureSensorNitrogenOffset
- initSpecialization
- linkManureSensor
- onLoad
- prerequisitesPresent
getCurrentNitrogenLevelOffset
DescriptionDefinitiongetCurrentNitrogenLevelOffset()Code
147 | function ManureSensor:getCurrentNitrogenLevelOffset(superFunc, lastChangeLevels) |
148 | if not self.spec_manureSensor.sensorRequired then |
149 | return superFunc(self) |
150 | end |
151 | |
152 | if not self.spec_manureSensor.sensorAvailable then |
153 | return self:getManureSensorNitrogenOffset(lastChangeLevels) |
154 | end |
155 | |
156 | return 0 |
157 | end |
getCurrentNitrogenUsageLevelOffset
DescriptionDefinitiongetCurrentNitrogenUsageLevelOffset()Code
161 | function ManureSensor:getCurrentNitrogenUsageLevelOffset(superFunc, lastChangeLevels) |
162 | if not self.spec_manureSensor.sensorRequired then |
163 | return superFunc(self) |
164 | end |
165 | |
166 | if self.spec_manureSensor.sensorAvailable then |
167 | return self:getManureSensorNitrogenOffset(lastChangeLevels) |
168 | end |
169 | |
170 | return 0 |
171 | end |
getIsUsingExactNitrogenAmount
DescriptionDefinitiongetIsUsingExactNitrogenAmount()Code
175 | function ManureSensor:getIsUsingExactNitrogenAmount(superFunc) |
176 | if not self.spec_manureSensor.sensorRequired then |
177 | return superFunc(self) |
178 | end |
179 | |
180 | return self.spec_manureSensor.sensorAvailable |
181 | end |
getManureSensorNitrogenOffset
DescriptionDefinitiongetManureSensorNitrogenOffset()Code
135 | function ManureSensor:getManureSensorNitrogenOffset(lastChangeLevels) |
136 | local spec = self.spec_manureSensor |
137 | local curve = (g_time % ManureSensor.CHANGE_TIME) / ManureSensor.CHANGE_TIME + spec.currentCurveOffset |
138 | local offset = math.sin(curve * math.pi * 2) * 0.75 + math.sin(curve * math.pi * 10) * 0.15 + math.sin(curve * math.pi * 20) * 0.15 |
139 | local stepOffset = offset * (lastChangeLevels * ManureSensor.MAX_NITROGEN_OFFSET_PCT) |
140 | local direction = MathUtil.sign(stepOffset) |
141 | stepOffset = MathUtil.round(math.abs(stepOffset)) |
142 | return stepOffset * direction |
143 | end |
initSpecialization
DescriptionDefinitioninitSpecialization()Code
29 | function ManureSensor.initSpecialization() |
30 | g_configurationManager:addConfigurationType("manureSensor", g_i18n:getText("configuration_manureSensor"), "manureSensor", nil, nil, nil, ConfigurationUtil.SELECTOR_MULTIOPTION) |
31 | |
32 | local schema = Vehicle.xmlSchema |
33 | schema:setXMLSpecializationType("ManureSensor") |
34 | |
35 | schema:register(XMLValueType.NODE_INDEX, "vehicle.manureSensor.manureSensorConfigurations.manureSensorConfiguration(?).linkNode#node", "Sensor Link Node") |
36 | schema:register(XMLValueType.STRING, "vehicle.manureSensor.manureSensorConfigurations.manureSensorConfiguration(?).linkNode#type", "Sensor Type (DEFAULT, LARGE, SMALL or STANDALONE)") |
37 | |
38 | schema:setXMLSpecializationType() |
39 | end |
linkManureSensor
DescriptionDefinitionlinkManureSensor()Code
101 | function ManureSensor:linkManureSensor(linkData) |
102 | for i=1, #linkData.linkNodes do |
103 | local linkNodeData = linkData.linkNodes[i] |
104 | |
105 | local linkNode = linkNodeData.linkNode |
106 | if linkNode == nil and linkNodeData.nodeName ~= nil then |
107 | if self.i3dMappings[linkNodeData.nodeName] ~= nil then |
108 | linkNode = self.i3dMappings[linkNodeData.nodeName].nodeId |
109 | end |
110 | end |
111 | |
112 | if linkNode ~= nil then |
113 | local sensorData = g_precisionFarming:getClonedManureSensorNode(linkNodeData.typeName) |
114 | if sensorData ~= nil then |
115 | link(linkNode, sensorData.node) |
116 | |
117 | if linkNodeData.translation ~= nil then |
118 | setTranslation(sensorData.node, linkNodeData.translation[1], linkNodeData.translation[2], linkNodeData.translation[3]) |
119 | end |
120 | if linkNodeData.rotation ~= nil then |
121 | setRotation(sensorData.node, linkNodeData.rotation[1], linkNodeData.rotation[2], linkNodeData.rotation[3]) |
122 | end |
123 | if linkNodeData.scale ~= nil then |
124 | setScale(sensorData.node, linkNodeData.scale[1], linkNodeData.scale[2], linkNodeData.scale[3]) |
125 | end |
126 | end |
127 | end |
128 | end |
129 | |
130 | self.spec_manureSensor.sensorAvailable = true |
131 | end |
onLoad
DescriptionDefinitiononLoad()Code
59 | function ManureSensor:onLoad(savegame) |
60 | self.spec_manureSensor = self["spec_" .. ManureSensor.SPEC_NAME] |
61 | local spec = self.spec_manureSensor |
62 | |
63 | spec.currentCurveOffset = math.random() |
64 | |
65 | spec.sensorRequired = false |
66 | local fillUnits = self:getFillUnits() |
67 | for i=1, #fillUnits do |
68 | spec.sensorRequired = spec.sensorRequired or self:getFillUnitAllowsFillType(i, FillType.LIQUIDMANURE) or self:getFillUnitAllowsFillType(i, FillType.DIGESTATE) |
69 | end |
70 | |
71 | spec.sensorAvailable = false |
72 | |
73 | local configIndex = self.configurations["manureSensor"] |
74 | if configIndex ~= nil then |
75 | local configKey = string.format("vehicle.manureSensor.manureSensorConfigurations.manureSensorConfiguration(%d)", configIndex - 1) |
76 | |
77 | local linkNode = self.xmlFile:getValue(configKey .. ".linkNode#node", nil, self.components, self.i3dMappings) |
78 | if linkNode ~= nil then |
79 | local typeName = self.xmlFile:getValue(configKey .. ".linkNode#type", "DEFAULT") |
80 | local linkData = {} |
81 | linkData.linkNodes = {} |
82 | linkData.linkNodes[1] = {linkNode = linkNode, |
83 | typeName = typeName |
84 | } |
85 | self:linkManureSensor(linkData) |
86 | end |
87 | |
88 | if configIndex > 1 then |
89 | if g_precisionFarming ~= nil then |
90 | local linkData = g_precisionFarming:getManureSensorLinkageData(self.configFileName) |
91 | if linkData ~= nil then |
92 | self:linkManureSensor(linkData) |
93 | end |
94 | end |
95 | end |
96 | end |
97 | 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 |
23 | function ManureSensor.prerequisitesPresent(specializations) |
24 | return SpecializationUtil.hasSpecialization(Sprayer, specializations) and SpecializationUtil.hasSpecialization(PrecisionFarmingStatistic, specializations) |
25 | end |