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
PlaceableManureHeap
DescriptionSpecialization for placeablesFunctions
- collectPickObjects
- getCanBePlacedAt
- getSpecValueCapacity
- initSpecialization
- loadFromXMLFile
- loadSpecValueCapacity
- onDelete
- onFinalizePlacement
- onLoad
- onReadStream
- onWriteStream
- prerequisitesPresent
- registerEventListeners
- registerOverwrittenFunctions
- registerSavegameXMLPaths
- registerXMLPaths
- saveToXMLFile
- setOwnerFarmId
- updateInfo
collectPickObjects
DescriptionDefinitioncollectPickObjects()Code
221 | function PlaceableManureHeap:collectPickObjects(superFunc, node) |
222 | local spec = self.spec_manureHeap |
223 | |
224 | if spec.loadingStation ~= nil then |
225 | for _, loadTrigger in ipairs(spec.loadingStation.loadTriggers) do |
226 | if node == loadTrigger.triggerNode then |
227 | return |
228 | end |
229 | end |
230 | end |
231 | |
232 | if spec.manureHeap ~= nil then |
233 | if node == spec.manureHeap.activationTriggerNode then |
234 | return |
235 | end |
236 | end |
237 | |
238 | superFunc(self, node) |
239 | end |
getCanBePlacedAt
DescriptionDefinitiongetCanBePlacedAt()Code
243 | function PlaceableManureHeap:getCanBePlacedAt(superFunc, x, y, z, farmId) |
244 | local spec = self.spec_manureHeap |
245 | if spec.manureHeap == nil then |
246 | return false |
247 | end |
248 | |
249 | if spec.isExtension then |
250 | local storageSystem = g_currentMission.storageSystem |
251 | |
252 | -- we also need to check farmId |
253 | local lastFoundUnloadingStations = storageSystem:getExtendableUnloadingStationsInRange(spec.manureHeap, farmId, x, y, z) |
254 | if #lastFoundUnloadingStations == 0 then |
255 | return false, g_i18n:getText("warning_manureHeapNotNearBarn") |
256 | end |
257 | end |
258 | |
259 | return superFunc(self, x, y, z, farmId) |
260 | end |
getSpecValueCapacity
DescriptionDefinitiongetSpecValueCapacity()Code
286 | function PlaceableManureHeap.getSpecValueCapacity(storeItem, realItem) |
287 | if storeItem.specs.manureHeapCapacity == nil then |
288 | return nil |
289 | end |
290 | |
291 | return g_i18n:formatVolume(storeItem.specs.manureHeapCapacity) |
292 | end |
initSpecialization
DescriptionDefinitioninitSpecialization()Code
61 | function PlaceableManureHeap.initSpecialization() |
62 | g_storeManager:addSpecType("manureHeapCapacity", "shopListAttributeIconCapacity", PlaceableManureHeap.loadSpecValueCapacity, PlaceableManureHeap.getSpecValueCapacity, "placeable") |
63 | end |
loadFromXMLFile
DescriptionDefinitionloadFromXMLFile()Code
190 | function PlaceableManureHeap:loadFromXMLFile(xmlFile, key) |
191 | local spec = self.spec_manureHeap |
192 | if spec.manureHeap ~= nil then |
193 | spec.manureHeap:loadFromXMLFile(xmlFile, key) |
194 | end |
195 | end |
loadSpecValueCapacity
DescriptionDefinitionloadSpecValueCapacity()Code
280 | function PlaceableManureHeap.loadSpecValueCapacity(xmlFile, customEnvironment, baseDir) |
281 | return xmlFile:getValue("placeable.manureHeap#capacity") |
282 | end |
onDelete
DescriptionDefinitiononDelete()Code
94 | function PlaceableManureHeap:onDelete() |
95 | local spec = self.spec_manureHeap |
96 | local storageSystem = g_currentMission.storageSystem |
97 | |
98 | if spec.manureHeap ~= nil then |
99 | if storageSystem:hasStorage(spec.manureHeap) then |
100 | -- just remove storage from all registered unloading and loading stations |
101 | storageSystem:removeStorageFromUnloadingStations(spec.manureHeap, spec.manureHeap.unloadingStations) |
102 | storageSystem:removeStorageFromLoadingStations(spec.manureHeap, spec.manureHeap.loadingStations) |
103 | |
104 | storageSystem:removeStorage(spec.manureHeap) |
105 | end |
106 | spec.manureHeap:delete() |
107 | spec.manureHeap = nil |
108 | end |
109 | |
110 | if spec.loadingStation ~= nil then |
111 | if spec.loadingStation:getIsFillTypeSupported(FillType.MANURE) then |
112 | g_currentMission:removeManureLoadingStation(spec.loadingStation) |
113 | end |
114 | |
115 | storageSystem:removeLoadingStation(spec.loadingStation, self) |
116 | spec.loadingStation:delete() |
117 | spec.loadingStation = nil |
118 | end |
119 | end |
onFinalizePlacement
DescriptionDefinitiononFinalizePlacement()Code
123 | function PlaceableManureHeap:onFinalizePlacement() |
124 | local spec = self.spec_manureHeap |
125 | local storageSystem = g_currentMission.storageSystem |
126 | local ownerFarmId = self:getOwnerFarmId() |
127 | |
128 | if spec.loadingStation ~= nil and spec.manureHeap ~= nil then |
129 | spec.loadingStation:register(true) |
130 | storageSystem:addLoadingStation(spec.loadingStation, self) |
131 | |
132 | spec.manureHeap:finalize() |
133 | spec.manureHeap:register(true) |
134 | spec.manureHeap:setOwnerFarmId(ownerFarmId, true) |
135 | storageSystem:addStorage(spec.manureHeap) |
136 | storageSystem:addStorageToLoadingStation(spec.manureHeap, spec.loadingStation) |
137 | |
138 | if spec.loadingStation:getIsFillTypeSupported(FillType.MANURE) then |
139 | g_currentMission:addManureLoadingStation(spec.loadingStation) |
140 | end |
141 | |
142 | local storagesInRange = storageSystem:getStorageExtensionsInRange(spec.loadingStation, ownerFarmId) |
143 | for _, storage in ipairs(storagesInRange) do |
144 | if spec.loadingStation.sourceStorages[storage] == nil then |
145 | storageSystem:addStorageToLoadingStation(storage, spec.loadingStation) |
146 | end |
147 | end |
148 | |
149 | local lastFoundUnloadingStations = storageSystem:getExtendableUnloadingStationsInRange(spec.manureHeap, ownerFarmId) |
150 | local lastFoundLoadingStations = storageSystem:getExtendableLoadingStationsInRange(spec.manureHeap, ownerFarmId) |
151 | storageSystem:addStorageToUnloadingStations(spec.manureHeap, lastFoundUnloadingStations) |
152 | storageSystem:addStorageToLoadingStations(spec.manureHeap, lastFoundLoadingStations) |
153 | end |
154 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
68 | function PlaceableManureHeap:onLoad(savegame) |
69 | local spec = self.spec_manureHeap |
70 | local xmlFile = self.xmlFile |
71 | |
72 | spec.loadingStation = LoadingStation.new(self.isServer, self.isClient) |
73 | if not spec.loadingStation:load(spec.components, xmlFile, "placeable.manureHeap.loadingStation", self.customEnvironment, self.i3dMappings, self.components[1].node) then |
74 | spec.loadingStation:delete() |
75 | spec.loadingStation = nil |
76 | return false |
77 | end |
78 | spec.loadingStation.owningPlaceable = self |
79 | spec.loadingStation.hasStoragePerFarm = false |
80 | |
81 | spec.manureHeap = ManureHeap.new(spec.isServer, self.isClient) |
82 | if not spec.manureHeap:load(spec.components, xmlFile, "placeable.manureHeap", self.customEnvironment, self.i3dMappings, self.components[1].node) then |
83 | spec.manureHeap:delete() |
84 | spec.manureHeap = nil |
85 | end |
86 | |
87 | spec.isExtension = xmlFile:getValue("placeable.manureHeap#isExtension", true) |
88 | |
89 | spec.infoFillLevel = {title=g_i18n:getText("fillType_manure"), text=""} |
90 | end |
onReadStream
DescriptionDefinitiononReadStream()Code
158 | function PlaceableManureHeap:onReadStream(streamId, connection) |
159 | local spec = self.spec_manureHeap |
160 | |
161 | if spec.loadingStation ~= nil and spec.manureHeap ~= nil then |
162 | local loadingStationId = NetworkUtil.readNodeObjectId(streamId) |
163 | spec.loadingStation:readStream(streamId, connection) |
164 | g_client:finishRegisterObject(spec.loadingStation, loadingStationId) |
165 | |
166 | local manureHeapId = NetworkUtil.readNodeObjectId(streamId) |
167 | spec.manureHeap:readStream(streamId, connection) |
168 | g_client:finishRegisterObject(spec.manureHeap, manureHeapId) |
169 | end |
170 | end |
onWriteStream
DescriptionDefinitiononWriteStream()Code
174 | function PlaceableManureHeap:onWriteStream(streamId, connection) |
175 | local spec = self.spec_manureHeap |
176 | |
177 | if spec.loadingStation ~= nil and spec.manureHeap ~= nil then |
178 | NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(spec.loadingStation)) |
179 | spec.loadingStation:writeStream(streamId, connection) |
180 | g_server:registerObjectInStream(connection, spec.loadingStation) |
181 | |
182 | NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(spec.manureHeap)) |
183 | spec.manureHeap:writeStream(streamId, connection) |
184 | g_server:registerObjectInStream(connection, spec.manureHeap) |
185 | end |
186 | 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 PlaceableManureHeap.prerequisitesPresent(specializations) |
19 | return true |
20 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
33 | function PlaceableManureHeap.registerEventListeners(placeableType) |
34 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableManureHeap) |
35 | SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableManureHeap) |
36 | SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", PlaceableManureHeap) |
37 | SpecializationUtil.registerEventListener(placeableType, "onReadStream", PlaceableManureHeap) |
38 | SpecializationUtil.registerEventListener(placeableType, "onWriteStream", PlaceableManureHeap) |
39 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
24 | function PlaceableManureHeap.registerOverwrittenFunctions(placeableType) |
25 | SpecializationUtil.registerOverwrittenFunction(placeableType, "setOwnerFarmId", PlaceableManureHeap.setOwnerFarmId) |
26 | SpecializationUtil.registerOverwrittenFunction(placeableType, "collectPickObjects", PlaceableManureHeap.collectPickObjects) |
27 | SpecializationUtil.registerOverwrittenFunction(placeableType, "getCanBePlacedAt", PlaceableManureHeap.getCanBePlacedAt) |
28 | SpecializationUtil.registerOverwrittenFunction(placeableType, "updateInfo", PlaceableManureHeap.updateInfo) |
29 | end |
registerSavegameXMLPaths
DescriptionDefinitionregisterSavegameXMLPaths()Code
53 | function PlaceableManureHeap.registerSavegameXMLPaths(schema, basePath) |
54 | schema:setXMLSpecializationType("ManureHeap") |
55 | ManureHeap.registerSavegameXMLPaths(schema, basePath) |
56 | schema:setXMLSpecializationType(XMLManager.XML_SPECIALIZATION_NONE) |
57 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
43 | function PlaceableManureHeap.registerXMLPaths(schema, basePath) |
44 | schema:setXMLSpecializationType("ManureHeap") |
45 | ManureHeap.registerXMLPaths(schema, basePath .. ".manureHeap") |
46 | schema:register(XMLValueType.BOOL, basePath .. ".manureHeap#isExtension", "Is extension and can only be placed next to storages", true) |
47 | LoadingStation.registerXMLPaths(schema, basePath .. ".manureHeap.loadingStation") |
48 | schema:setXMLSpecializationType(XMLManager.XML_SPECIALIZATION_NONE) |
49 | end |
saveToXMLFile
DescriptionDefinitionsaveToXMLFile()Code
199 | function PlaceableManureHeap:saveToXMLFile(xmlFile, key, usedModNames) |
200 | local spec = self.spec_manureHeap |
201 | if spec.manureHeap ~= nil then |
202 | spec.manureHeap:saveToXMLFile(xmlFile, key, usedModNames) |
203 | end |
204 | end |
setOwnerFarmId
DescriptionDefinitionsetOwnerFarmId()Code
208 | function PlaceableManureHeap:setOwnerFarmId(superFunc, farmId, noEventSend) |
209 | superFunc(self, farmId, noEventSend) |
210 | |
211 | if self.isServer then |
212 | local spec = self.spec_manureHeap |
213 | if spec.manureHeap ~= nil then |
214 | spec.manureHeap:setOwnerFarmId(farmId, true) |
215 | end |
216 | end |
217 | end |
updateInfo
DescriptionDefinitionupdateInfo()Code
264 | function PlaceableManureHeap:updateInfo(superFunc, infoTable) |
265 | superFunc(self, infoTable) |
266 | |
267 | local spec = self.spec_manureHeap |
268 | if spec.manureHeap == nil then |
269 | return |
270 | end |
271 | |
272 | local fillLevel = spec.manureHeap:getFillLevel(spec.manureHeap.fillTypeIndex) |
273 | |
274 | spec.infoFillLevel.text = string.format("%d l", fillLevel) |
275 | table.insert(infoTable, spec.infoFillLevel) |
276 | end |