LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

PlaceableHusbandry

Description
Specialization for placeables
Functions

addHusbandryFillLevelFromTool

Description
Definition
addHusbandryFillLevelFromTool()
Code
515function PlaceableHusbandry:addHusbandryFillLevelFromTool(farmId, deltaFillLevel, fillTypeIndex, fillPositionData, toolType, extraAttributes)
516 local spec = self.spec_husbandry
517 if spec.unloadingStation == nil then
518 return 0
519 end
520 return spec.unloadingStation:addFillLevelFromTool(farmId or self:getOwnerFarmId(), deltaFillLevel, fillTypeIndex, fillPositionData, toolType, extraAttributes)
521end

canBuy

Description
Definition
canBuy()
Code
405function PlaceableHusbandry:canBuy(superFunc)
406 if g_currentMission.husbandrySystem:getLimitReached() then
407 return false, g_i18n:getText("warning_tooManyHusbandries")
408 end
409
410 return superFunc(self)
411end

collectPickObjects

Description
Definition
collectPickObjects()
Code
371function PlaceableHusbandry:collectPickObjects(superFunc, node, target)
372 local spec = self.spec_husbandry
373
374 if spec.unloadingStation ~= nil then
375 for _, unloadTrigger in ipairs(spec.unloadingStation.unloadTriggers) do
376 if node == unloadTrigger.exactFillRootNode then
377 return
378 end
379 end
380 end
381
382 if spec.loadingStation ~= nil then
383 for _, loadTrigger in ipairs(spec.loadingStation.loadTriggers) do
384 if node == loadTrigger.triggerNode then
385 return
386 end
387 end
388 end
389
390 superFunc(self, node, target)
391end

getAnimalDescription

Description
Definition
getAnimalDescription()
Code
489function PlaceableHusbandry:getAnimalDescription(cluster)
490 return ""
491end

getAnimalInfos

Description
Definition
getAnimalInfos()
Code
483function PlaceableHusbandry:getAnimalInfos()
484 return {}
485end

getCanBePlacedAt

Description
Definition
getCanBePlacedAt()
Code
395function PlaceableHusbandry:getCanBePlacedAt(superFunc, x, y, z, farmId)
396 if g_currentMission.husbandrySystem:getLimitReached() then
397 return false, g_i18n:getText("warning_tooManyHusbandries")
398 end
399
400 return superFunc(self, x, y, z)
401end

getConditionInfos

Description
Definition
getConditionInfos()
Code
471function PlaceableHusbandry:getConditionInfos()
472 return {}
473end

getFoodInfos

Description
Definition
getFoodInfos()
Code
477function PlaceableHusbandry:getFoodInfos()
478 return {}
479end

getGlobalProductionFactor

Description
Definition
getGlobalProductionFactor()
Code
464function PlaceableHusbandry:getGlobalProductionFactor()
465 local spec = self.spec_husbandry
466 return spec.globalProductionFactor
467end

getHusbandryCapacity

Description
Definition
getHusbandryCapacity()
Code
495function PlaceableHusbandry:getHusbandryCapacity(fillTypeIndex, farmId)
496 local spec = self.spec_husbandry
497 if spec.unloadingStation == nil then
498 return 0
499 end
500 return spec.unloadingStation:getCapacity(fillTypeIndex, farmId or self:getOwnerFarmId())
501end

getHusbandryFillLevel

Description
Definition
getHusbandryFillLevel()
Code
539function PlaceableHusbandry:getHusbandryFillLevel(fillTypeIndex, farmId)
540 local spec = self.spec_husbandry
541 if spec.unloadingStation == nil then
542 return 0
543 end
544 return spec.unloadingStation:getFillLevel(fillTypeIndex, farmId or self:getOwnerFarmId())
545end

getHusbandryFreeCapacity

Description
Definition
getHusbandryFreeCapacity()
Code
505function PlaceableHusbandry:getHusbandryFreeCapacity(fillTypeIndex, farmId)
506 local spec = self.spec_husbandry
507 if spec.unloadingStation == nil then
508 return 0
509 end
510 return spec.unloadingStation:getFreeCapacity(fillTypeIndex, farmId or self:getOwnerFarmId())
511end

getHusbandryIsFillTypeSupported

Description
Definition
getHusbandryIsFillTypeSupported()
Code
549function PlaceableHusbandry:getHusbandryIsFillTypeSupported(fillTypeIndex)
550 local spec = self.spec_husbandry
551 if spec.unloadingStation == nil then
552 return false
553 end
554 return spec.unloadingStation:getIsFillTypeSupported(fillTypeIndex)
555end

getNeedHourChanged

Description
Definition
getNeedHourChanged()
Code
441function PlaceableHusbandry:getNeedHourChanged(superFunc)
442 return true
443end

loadFromXMLFile

Description
Definition
loadFromXMLFile()
Code
343function PlaceableHusbandry:loadFromXMLFile(xmlFile, key)
344 local spec = self.spec_husbandry
345 if spec.storage ~= nil then
346 spec.storage:loadFromXMLFile(xmlFile, key..".storage")
347 end
348 spec.globalProductionFactor = xmlFile:getValue(key.."#globalProductionFactor", spec.globalProductionFactor)
349end

onAddedStorageToLoadingStation

Description
Definition
onAddedStorageToLoadingStation()
Code
559function PlaceableHusbandry:onAddedStorageToLoadingStation(storage, loadingStation)
560 local spec = self.spec_husbandry
561 if spec.loadingStation ~= nil and spec.loadingStation == loadingStation then
562 storage:addFillLevelChangedListeners(spec.fillLevelChangedCallback)
563 end
564end

onAddedStorageToUnloadingStation

Description
Definition
onAddedStorageToUnloadingStation()
Code
577function PlaceableHusbandry:onAddedStorageToUnloadingStation(storage, unloadingStation)
578 local spec = self.spec_husbandry
579 if spec.unloadingStation ~= nil and spec.unloadingStation == unloadingStation then
580 storage:addFillLevelChangedListeners(spec.fillLevelChangedCallback)
581 end
582end

onDelete

Description
Definition
onDelete()
Code
164function PlaceableHusbandry:onDelete()
165 local spec = self.spec_husbandry
166
167 local storageSystem = g_currentMission.storageSystem
168
169 if spec.unloadingStation ~= nil then
170 storageSystem:removeStorageFromUnloadingStations(spec.storage, {spec.unloadingStation})
171 storageSystem:removeUnloadingStation(spec.unloadingStation, self)
172 spec.unloadingStation:delete()
173 spec.unloadingStation = nil
174 end
175 if spec.loadingStation ~= nil then
176 if spec.loadingStation:getIsFillTypeSupported(FillType.LIQUIDMANURE) then
177 g_currentMission:removeLiquidManureLoadingStation(spec.loadingStation)
178 end
179
180 storageSystem:removeStorageFromLoadingStations(spec.storage, {spec.loadingStation})
181 storageSystem:removeLoadingStation(spec.loadingStation, self)
182 spec.loadingStation:delete()
183 spec.loadingStation = nil
184 end
185 if spec.storage ~= nil then
186 storageSystem:removeStorage(spec.storage)
187 spec.storage:delete()
188 spec.storage = nil
189 end
190
191 g_messageCenter:unsubscribe(MessageType.STORAGE_ADDED_TO_LOADING_STATION, self)
192 g_messageCenter:unsubscribe(MessageType.STORAGE_REMVOED_FROM_LOADING_STATION, self)
193 g_messageCenter:unsubscribe(MessageType.STORAGE_ADDED_TO_UNLOADING_STATION, self)
194 g_messageCenter:unsubscribe(MessageType.STORAGE_REMVOED_FROM_UNLOADING_STATION, self)
195
196 g_currentMission.husbandrySystem:removePlaceable(self)
197end

onFinalizePlacement

Description
Definition
onFinalizePlacement()
Code
201function PlaceableHusbandry:onFinalizePlacement()
202 local spec = self.spec_husbandry
203
204 g_messageCenter:subscribe(MessageType.STORAGE_ADDED_TO_LOADING_STATION, self.onAddedStorageToLoadingStation, self)
205 g_messageCenter:subscribe(MessageType.STORAGE_REMOVED_FROM_LOADING_STATION, self.onRemovedStorageFromLoadingStation, self)
206 g_messageCenter:subscribe(MessageType.STORAGE_ADDED_TO_UNLOADING_STATION, self.onAddedStorageToUnloadingStation, self)
207 g_messageCenter:subscribe(MessageType.STORAGE_REMOVED_FROM_UNLOADING_STATION, self.onRemovedStorageFromUnloadingStation, self)
208
209 local storage = spec.storage
210 local unloadingStation = spec.unloadingStation
211 local storageSystem = g_currentMission.storageSystem
212 local loadingStation = spec.loadingStation
213 local farmId = self:getOwnerFarmId()
214
215 if loadingStation ~= nil then
216 loadingStation:setOwnerFarmId(farmId, true)
217 loadingStation:register(true)
218 storageSystem:addLoadingStation(loadingStation, self)
219
220 if loadingStation:getIsFillTypeSupported(FillType.LIQUIDMANURE) then
221 g_currentMission:addLiquidManureLoadingStation(loadingStation)
222 end
223 end
224
225 if unloadingStation ~= nil then
226 unloadingStation:setOwnerFarmId(farmId, true)
227 unloadingStation:register(true)
228 storageSystem:addUnloadingStation(unloadingStation, self)
229 end
230
231 if storage ~= nil then
232 storage:setOwnerFarmId(farmId, true)
233 storage:register(true)
234 storageSystem:addStorage(storage)
235
236 if unloadingStation ~= nil then
237 storageSystem:addStorageToUnloadingStation(storage, unloadingStation)
238 end
239
240 if loadingStation ~= nil then
241 storageSystem:addStorageToLoadingStation(storage, loadingStation)
242 end
243 end
244
245
246 if unloadingStation ~= nil then
247 -- now check if there are some storages in range which can also be used
248 local storagesInRange = storageSystem:getStorageExtensionsInRange(unloadingStation, farmId)
249 for _, storageInRange in ipairs(storagesInRange) do
250 if unloadingStation.targetStorages[storageInRange] == nil then
251 storageSystem:addStorageToUnloadingStation(storageInRange, unloadingStation)
252 end
253 if loadingStation ~= nil and loadingStation.sourceStorages[storageInRange] == nil then
254 storageSystem:addStorageToLoadingStation(storageInRange, loadingStation)
255 end
256 end
257 end
258
259 g_currentMission.husbandrySystem:addPlaceable(self)
260end

onHourChanged

Description
Definition
onHourChanged()
Code
415function PlaceableHusbandry:onHourChanged(currentHour)
416 if self.isServer then
417 local spec = self.spec_husbandry
418 local foodFactor = self:updateFeeding()
419 local productionFactor = self:updateProduction(foodFactor)
420
421 local factor
422 local changePerHour
423 if productionFactor > spec.productionThreshold then
424 factor = (productionFactor - spec.productionThreshold) / (1 - spec.productionThreshold)
425 changePerHour = spec.productionChangePerHourIncrease
426 else
427 factor = (productionFactor / spec.productionThreshold) - 1
428 changePerHour = spec.productionChangePerHourDecrease
429 end
430
431 local delta = changePerHour*factor
432 spec.globalProductionFactor = MathUtil.clamp(spec.globalProductionFactor + delta, 0, 1)
433
434 self:updateOutput(foodFactor, productionFactor, spec.globalProductionFactor)
435 self:raiseDirtyFlags(spec.dirtyFlag)
436 end
437end

onLoad

Description
Called on loading
Definition
onLoad(table savegame)
Arguments
tablesavegamesavegame
Code
102function PlaceableHusbandry:onLoad(savegame)
103 local spec = self.spec_husbandry
104 local xmlFile = self.xmlFile
105
106 spec.fillLevelChangedListener = {}
107 spec.targetStorages = {}
108 spec.hideFromPricesMenu = true
109-- spec.saveId = xmlFile:getValue("placeable.husbandry#saveId", "Animals_" .. self:getAnimalType())
110-- spec.hasStatistics = xmlFile:getValue("placeable.husbandry#hasStatistics", spec.hasStatistics)
111 spec.globalProductionFactor = 0.0
112
113 spec.husbandryDirtyFlag = self:getNextDirtyFlag()
114
115 if xmlFile:hasProperty("placeable.husbandry.unloadingStation") then
116 spec.unloadingStation = UnloadingStation.new(self.isServer, self.isClient)
117 if spec.unloadingStation:load(self.components, xmlFile, "placeable.husbandry.unloadingStation", self.customEnvironment, self.i3dMappings, self.components[1].node) then
118 spec.unloadingStation.owningPlaceable = self
119 spec.unloadingStation.hasStoragePerFarm = false
120 else
121 spec.unloadingStation:delete()
122 Logging.xmlError(xmlFile, "Failed to load unloading station")
123 self:setLoadingState(Placeable.LOADING_STATE_ERROR)
124 return
125 end
126 end
127
128 if xmlFile:hasProperty("placeable.husbandry.storage") then
129 spec.storage = Storage.new(self.isServer, self.isClient)
130 if not spec.storage:load(self.components, xmlFile, "placeable.husbandry.storage", self.i3dMappings) then
131 spec.storage:delete()
132 Logging.xmlError(xmlFile, "Failed to load storage")
133 self:setLoadingState(Placeable.LOADING_STATE_ERROR)
134 return
135 end
136 end
137
138 if xmlFile:hasProperty("placeable.husbandry.loadingStation") then
139 spec.loadingStation = LoadingStation.new(self.isServer, self.isClient)
140 if spec.loadingStation:load(self.components, xmlFile, "placeable.husbandry.loadingStation", self.customEnvironment, self.i3dMappings, self.components[1].node) then
141 spec.loadingStation.owningPlaceable = self
142 spec.loadingStation.hasStoragePerFarm = false
143 else
144 spec.loadingStation:delete()
145 Logging.xmlError(xmlFile, "Failed to load loading station")
146 self:setLoadingState(Placeable.LOADING_STATE_ERROR)
147 return
148 end
149 end
150
151 spec.fillLevelChangedCallback = function(fillType, delta)
152 SpecializationUtil.raiseEvent(self, "onHusbandryFillLevelChanged", fillType, delta)
153 end
154
155 spec.productionThreshold = MathUtil.clamp(math.abs(xmlFile:getValue("placeable.husbandry.production#threshold", 0.5)), 0.01, 0.99)
156 spec.productionChangePerHourIncrease = math.abs(xmlFile:getValue("placeable.husbandry.production#increasePerHour", 0.1))
157 spec.productionChangePerHourDecrease = math.abs(xmlFile:getValue("placeable.husbandry.production#decreasePerHour", 0.2))
158
159 spec.dirtyFlag = self:getNextDirtyFlag()
160end

onReadStream

Description
Definition
onReadStream()
Code
264function PlaceableHusbandry:onReadStream(streamId, connection)
265 local spec = self.spec_husbandry
266
267 if spec.unloadingStation ~= nil then
268 local unloadingStationId = NetworkUtil.readNodeObjectId(streamId)
269 spec.unloadingStation:readStream(streamId, connection)
270 g_client:finishRegisterObject(spec.unloadingStation, unloadingStationId)
271 end
272
273 if spec.loadingStation ~= nil then
274 local loadingStationId = NetworkUtil.readNodeObjectId(streamId)
275 spec.loadingStation:readStream(streamId, connection)
276 g_client:finishRegisterObject(spec.loadingStation, loadingStationId)
277 end
278
279 if spec.storage ~= nil then
280 local storageId = NetworkUtil.readNodeObjectId(streamId)
281 spec.storage:readStream(streamId, connection)
282 g_client:finishRegisterObject(spec.storage, storageId)
283 end
284
285 spec.globalProductionFactor = streamReadUInt8(streamId) / 255
286end

onReadUpdateStream

Description
Definition
onReadUpdateStream()
Code
316function PlaceableHusbandry:onReadUpdateStream(streamId, connection)
317 local spec = self.spec_husbandry
318
319 spec.globalProductionFactor = streamReadUInt8(streamId) / 100
320end

onRemovedStorageFromLoadingStation

Description
Definition
onRemovedStorageFromLoadingStation()
Code
568function PlaceableHusbandry:onRemovedStorageFromLoadingStation(storage, loadingStation)
569 local spec = self.spec_husbandry
570 if spec.loadingStation ~= nil and spec.loadingStation == loadingStation then
571 storage:removeFillLevelChangedListeners(spec.fillLevelChangedCallback)
572 end
573end

onRemovedStorageFromUnloadingStation

Description
Definition
onRemovedStorageFromUnloadingStation()
Code
586function PlaceableHusbandry:onRemovedStorageFromUnloadingStation(storage, unloadingStation)
587 local spec = self.spec_husbandry
588 if spec.unloadingStation ~= nil and spec.unloadingStation == unloadingStation then
589 storage:removeFillLevelChangedListeners(spec.fillLevelChangedCallback)
590 end
591end

onWriteStream

Description
Definition
onWriteStream()
Code
290function PlaceableHusbandry:onWriteStream(streamId, connection)
291 local spec = self.spec_husbandry
292
293 if spec.unloadingStation ~= nil then
294 NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(spec.unloadingStation))
295 spec.unloadingStation:writeStream(streamId, connection)
296 g_server:registerObjectInStream(connection, spec.unloadingStation)
297 end
298
299 if spec.loadingStation ~= nil then
300 NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(spec.loadingStation))
301 spec.loadingStation:writeStream(streamId, connection)
302 g_server:registerObjectInStream(connection, spec.loadingStation)
303 end
304
305 if spec.storage ~= nil then
306 NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(spec.storage))
307 spec.storage:writeStream(streamId, connection)
308 g_server:registerObjectInStream(connection, spec.storage)
309 end
310
311 streamWriteUInt8(streamId, MathUtil.round(spec.globalProductionFactor * 255))
312end

onWriteUpdateStream

Description
Definition
onWriteUpdateStream()
Code
324function PlaceableHusbandry:onWriteUpdateStream(streamId, connection)
325 local spec = self.spec_husbandry
326
327 streamWriteUInt8(streamId, MathUtil.round(spec.globalProductionFactor * 100))
328end

prerequisitesPresent

Description
Checks if all prerequisite specializations are loaded
Definition
prerequisitesPresent(table specializations)
Arguments
tablespecializationsspecializations
Return Values
booleanhasPrerequisitetrue if all prerequisite specializations are loaded
Code
18function PlaceableHusbandry.prerequisitesPresent(specializations)
19 return true
20end

registerEventListeners

Description
Definition
registerEventListeners()
Code
63function PlaceableHusbandry.registerEventListeners(placeableType)
64 SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableHusbandry)
65 SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableHusbandry)
66 SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", PlaceableHusbandry)
67 SpecializationUtil.registerEventListener(placeableType, "onReadStream", PlaceableHusbandry)
68 SpecializationUtil.registerEventListener(placeableType, "onWriteStream", PlaceableHusbandry)
69 SpecializationUtil.registerEventListener(placeableType, "onReadUpdateStream", PlaceableHusbandry)
70 SpecializationUtil.registerEventListener(placeableType, "onWriteUpdateStream", PlaceableHusbandry)
71 SpecializationUtil.registerEventListener(placeableType, "onHourChanged", PlaceableHusbandry)
72end

registerEvents

Description
Definition
registerEvents()
Code
24function PlaceableHusbandry.registerEvents(placeableType)
25 SpecializationUtil.registerEvent(placeableType, "onHusbandryFillLevelChanged")
26end

registerFunctions

Description
Definition
registerFunctions()
Code
30function PlaceableHusbandry.registerFunctions(placeableType)
31 SpecializationUtil.registerFunction(placeableType, "onAddedStorageToLoadingStation", PlaceableHusbandry.onAddedStorageToLoadingStation)
32 SpecializationUtil.registerFunction(placeableType, "onRemovedStorageFromLoadingStation", PlaceableHusbandry.onRemovedStorageFromLoadingStation)
33 SpecializationUtil.registerFunction(placeableType, "onAddedStorageToUnloadingStation", PlaceableHusbandry.onAddedStorageToUnloadingStation)
34 SpecializationUtil.registerFunction(placeableType, "onRemovedStorageFromUnloadingStation", PlaceableHusbandry.onRemovedStorageFromUnloadingStation)
35 SpecializationUtil.registerFunction(placeableType, "updateFeeding", PlaceableHusbandry.updateFeeding)
36 SpecializationUtil.registerFunction(placeableType, "updateProduction", PlaceableHusbandry.updateProduction)
37 SpecializationUtil.registerFunction(placeableType, "updateOutput", PlaceableHusbandry.updateOutput)
38 SpecializationUtil.registerFunction(placeableType, "getGlobalProductionFactor", PlaceableHusbandry.getGlobalProductionFactor)
39 SpecializationUtil.registerFunction(placeableType, "getConditionInfos", PlaceableHusbandry.getConditionInfos)
40 SpecializationUtil.registerFunction(placeableType, "getFoodInfos", PlaceableHusbandry.getFoodInfos)
41 SpecializationUtil.registerFunction(placeableType, "getAnimalInfos", PlaceableHusbandry.getAnimalInfos)
42 SpecializationUtil.registerFunction(placeableType, "getAnimalDescription", PlaceableHusbandry.getAnimalDescription)
43 SpecializationUtil.registerFunction(placeableType, "getHusbandryCapacity", PlaceableHusbandry.getHusbandryCapacity)
44 SpecializationUtil.registerFunction(placeableType, "getHusbandryFreeCapacity", PlaceableHusbandry.getHusbandryFreeCapacity)
45 SpecializationUtil.registerFunction(placeableType, "addHusbandryFillLevelFromTool", PlaceableHusbandry.addHusbandryFillLevelFromTool)
46 SpecializationUtil.registerFunction(placeableType, "removeHusbandryFillLevel", PlaceableHusbandry.removeHusbandryFillLevel)
47 SpecializationUtil.registerFunction(placeableType, "getHusbandryFillLevel", PlaceableHusbandry.getHusbandryFillLevel)
48 SpecializationUtil.registerFunction(placeableType, "getHusbandryIsFillTypeSupported", PlaceableHusbandry.getHusbandryIsFillTypeSupported)
49end

registerOverwrittenFunctions

Description
Definition
registerOverwrittenFunctions()
Code
53function PlaceableHusbandry.registerOverwrittenFunctions(placeableType)
54 SpecializationUtil.registerOverwrittenFunction(placeableType, "setOwnerFarmId", PlaceableHusbandry.setOwnerFarmId)
55 SpecializationUtil.registerOverwrittenFunction(placeableType, "collectPickObjects", PlaceableHusbandry.collectPickObjects)
56 SpecializationUtil.registerOverwrittenFunction(placeableType, "getCanBePlacedAt", PlaceableHusbandry.getCanBePlacedAt)
57 SpecializationUtil.registerOverwrittenFunction(placeableType, "canBuy", PlaceableHusbandry.canBuy)
58 SpecializationUtil.registerOverwrittenFunction(placeableType, "getNeedHourChanged", PlaceableHusbandry.getNeedHourChanged)
59end

registerSavegameXMLPaths

Description
Definition
registerSavegameXMLPaths()
Code
91function PlaceableHusbandry.registerSavegameXMLPaths(schema, basePath)
92 schema:setXMLSpecializationType("Husbandry")
93 schema:register(XMLValueType.STRING, basePath .. ".module(?)#name", "Name of module")
94 schema:register(XMLValueType.FLOAT, basePath .. "#globalProductionFactor", "Global production factor")
95 Storage.registerSavegameXMLPaths(schema, basePath .. ".storage")
96 schema:setXMLSpecializationType()
97end

registerXMLPaths

Description
Definition
registerXMLPaths()
Code
76function PlaceableHusbandry.registerXMLPaths(schema, basePath)
77 schema:setXMLSpecializationType("Husbandry")
78 schema:register(XMLValueType.STRING, basePath .. ".husbandry#saveId", "Save id")
79 schema:register(XMLValueType.BOOL, basePath .. ".husbandry#hasStatistics", "Has statistics", false)
80 schema:register(XMLValueType.FLOAT, basePath .. ".husbandry.production#threshold", "Threshold for production increase", 0.5)
81 schema:register(XMLValueType.FLOAT, basePath .. ".husbandry.production#increasePerHour", "Production increase if production factor bigger then threshold", 0.1)
82 schema:register(XMLValueType.FLOAT, basePath .. ".husbandry.production#decreasePerHour", "Production increase if production factor less then threshold", 0.2)
83 UnloadingStation.registerXMLPaths(schema, basePath .. ".husbandry.unloadingStation")
84 Storage.registerXMLPaths(schema, basePath .. ".husbandry.storage")
85 LoadingStation.registerXMLPaths(schema, basePath .. ".husbandry.loadingStation")
86 schema:setXMLSpecializationType()
87end

removeHusbandryFillLevel

Description
removeHusbandryFillLevel
Definition
removeHusbandryFillLevel(integer farmId, float deltaFillLevel, integer fillTypeIndex)
Arguments
integerfarmId
floatdeltaFillLevel
integerfillTypeIndex
Return Values
floatremainingdelta
Code
529function PlaceableHusbandry:removeHusbandryFillLevel(farmId, deltaFillLevel, fillTypeIndex)
530 local spec = self.spec_husbandry
531 if spec.loadingStation == nil then
532 return deltaFillLevel
533 end
534 return spec.loadingStation:removeFillLevel(fillTypeIndex, deltaFillLevel, farmId or self:getOwnerFarmId())
535end

saveToXMLFile

Description
Definition
saveToXMLFile()
Code
332function PlaceableHusbandry:saveToXMLFile(xmlFile, key, usedModNames)
333 local spec = self.spec_husbandry
334
335 if spec.storage ~= nil then
336 spec.storage:saveToXMLFile(xmlFile, key..".storage", usedModNames)
337 end
338 xmlFile:setValue(key.."#globalProductionFactor", spec.globalProductionFactor)
339end

setOwnerFarmId

Description
Definition
setOwnerFarmId()
Code
353function PlaceableHusbandry:setOwnerFarmId(superFunc, farmId, noEventSend)
354 local spec = self.spec_husbandry
355
356 superFunc(self, farmId, noEventSend)
357
358 if spec.storage ~= nil then
359 spec.storage:setOwnerFarmId(farmId, true)
360 end
361 if spec.loadingStation ~= nil then
362 spec.loadingStation:setOwnerFarmId(farmId, true)
363 end
364 if spec.unloadingStation ~= nil then
365 spec.unloadingStation:setOwnerFarmId(farmId, true)
366 end
367end

updateFeeding

Description
Definition
updateFeeding()
Code
447function PlaceableHusbandry:updateFeeding()
448 return 1
449end

updateOutput

Description
Definition
updateOutput()
Code
459function PlaceableHusbandry:updateOutput(foodFactor, productionFactor, globalProductionFactor)
460end

updateProduction

Description
Definition
updateProduction()
Code
453function PlaceableHusbandry:updateProduction(foodFactor)
454 return foodFactor
455end