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
PlaceableHusbandryLiquidManure
DescriptionSpecialization for placeablesFunctions
- getConditionInfos
- onFinalizePlacement
- onHusbandryAnimalsUpdate
- onLoad
- prerequisitesPresent
- registerEventListeners
- registerOverwrittenFunctions
- registerXMLPaths
- updateInfo
- updateOutput
- updateProduction
getConditionInfos
DescriptionDefinitiongetConditionInfos()Code
122 | function PlaceableHusbandryLiquidManure:getConditionInfos(superFunc) |
123 | local infos = superFunc(self) |
124 | local spec = self.spec_husbandryLiquidManure |
125 | |
126 | local info = {} |
127 | local fillType = g_fillTypeManager:getFillTypeByIndex(spec.fillType) |
128 | info.title = fillType.title |
129 | info.value = self:getHusbandryFillLevel(spec.fillType) |
130 | local capacity = self:getHusbandryCapacity(spec.fillType) |
131 | local ratio = 0 |
132 | if capacity > 0 then |
133 | ratio = info.value / capacity |
134 | end |
135 | info.ratio = MathUtil.clamp(ratio, 0, 1) |
136 | info.invertedBar = true |
137 | |
138 | table.insert(infos, info) |
139 | |
140 | return infos |
141 | end |
onFinalizePlacement
DescriptionDefinitiononFinalizePlacement()Code
61 | function PlaceableHusbandryLiquidManure:onFinalizePlacement() |
62 | local spec = self.spec_husbandryLiquidManure |
63 | if not self:getHusbandryIsFillTypeSupported(spec.fillType) then |
64 | Logging.warning("Missing filltype 'liquidManure' in husbandry storage!") |
65 | end |
66 | end |
onHusbandryAnimalsUpdate
DescriptionDefinitiononHusbandryAnimalsUpdate()Code
101 | function PlaceableHusbandryLiquidManure:onHusbandryAnimalsUpdate(clusters) |
102 | local spec = self.spec_husbandryLiquidManure |
103 | |
104 | spec.litersPerHour = 0 |
105 | for _, cluster in ipairs(clusters) do |
106 | local subType = g_currentMission.animalSystem:getSubTypeByIndex(cluster.subTypeIndex) |
107 | if subType ~= nil then |
108 | local liquidManure = subType.output.liquidManure |
109 | if liquidManure ~= nil then |
110 | local age = cluster:getAge() |
111 | local litersPerAnimal = liquidManure:get(age) |
112 | local litersPerDay = litersPerAnimal * cluster:getNumAnimals() |
113 | |
114 | spec.litersPerHour = spec.litersPerHour + (litersPerDay / 24) |
115 | end |
116 | end |
117 | end |
118 | end |
onLoad
DescriptionDefinitiononLoad()Code
51 | function PlaceableHusbandryLiquidManure:onLoad(savegame) |
52 | local spec = self.spec_husbandryLiquidManure |
53 | |
54 | spec.litersPerHour = 0 |
55 | spec.fillType = FillType.LIQUIDMANURE |
56 | spec.info = {title=g_i18n:getText("fillType_liquidManure"), text=""} |
57 | 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 |
18 | function PlaceableHusbandryLiquidManure.prerequisitesPresent(specializations) |
19 | return true |
20 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
33 | function PlaceableHusbandryLiquidManure.registerEventListeners(placeableType) |
34 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableHusbandryLiquidManure) |
35 | SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", PlaceableHusbandryLiquidManure) |
36 | SpecializationUtil.registerEventListener(placeableType, "onHusbandryAnimalsUpdate", PlaceableHusbandryLiquidManure) |
37 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
24 | function PlaceableHusbandryLiquidManure.registerOverwrittenFunctions(placeableType) |
25 | SpecializationUtil.registerOverwrittenFunction(placeableType, "updateOutput", PlaceableHusbandryLiquidManure.updateOutput) |
26 | SpecializationUtil.registerOverwrittenFunction(placeableType, "updateProduction", PlaceableHusbandryLiquidManure.updateProduction) |
27 | SpecializationUtil.registerOverwrittenFunction(placeableType, "updateInfo", PlaceableHusbandryLiquidManure.updateInfo) |
28 | SpecializationUtil.registerOverwrittenFunction(placeableType, "getConditionInfos", PlaceableHusbandryLiquidManure.getConditionInfos) |
29 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
41 | function PlaceableHusbandryLiquidManure.registerXMLPaths(schema, basePath) |
42 | schema:setXMLSpecializationType("Husbandry") |
43 | basePath = basePath .. ".husbandry.liquidManure" |
44 | schema:register(XMLValueType.FLOAT, basePath .. ".manure#factor", "Factor to transform straw to manure", 1) |
45 | schema:register(XMLValueType.BOOL, basePath .. ".manure#active", "Enable manure production", true) |
46 | schema:setXMLSpecializationType() |
47 | end |
updateInfo
DescriptionDefinitionupdateInfo()Code
145 | function PlaceableHusbandryLiquidManure:updateInfo(superFunc, infoTable) |
146 | superFunc(self, infoTable) |
147 | local spec = self.spec_husbandryLiquidManure |
148 | |
149 | local fillLevel = self:getHusbandryFillLevel(spec.fillType) |
150 | spec.info.text = string.format("%d l", fillLevel) |
151 | table.insert(infoTable, spec.info) |
152 | end |
updateOutput
DescriptionDefinitionupdateOutput()Code
70 | function PlaceableHusbandryLiquidManure:updateOutput(superFunc, foodFactor, productionFactor, globalProductionFactor) |
71 | if self.isServer then |
72 | local spec = self.spec_husbandryLiquidManure |
73 | |
74 | if spec.litersPerHour > 0 then |
75 | local liters = foodFactor * spec.litersPerHour * g_currentMission.environment.timeAdjustment |
76 | self:addHusbandryFillLevelFromTool(self:getOwnerFarmId(), liters, spec.fillType, nil, nil, nil) |
77 | end |
78 | end |
79 | |
80 | superFunc(self, foodFactor, productionFactor, globalProductionFactor) |
81 | end |
updateProduction
DescriptionDefinitionupdateProduction()Code
85 | function PlaceableHusbandryLiquidManure:updateProduction(superFunc, foodFactor) |
86 | local factor = superFunc(self, foodFactor) |
87 | |
88 | if self.isServer then |
89 | local spec = self.spec_husbandryLiquidManure |
90 | local freeCapacity = self:getHusbandryFreeCapacity(spec.fillType) |
91 | if freeCapacity <= 0 then |
92 | factor = factor * 0.75 |
93 | end |
94 | end |
95 | |
96 | return factor |
97 | end |