Script v1.7.1.0
- AI
- Animals
- AnimalFoodManager
- AnimalHusbandryNoMorePall...
- AnimalManager
- AnimalNameManager
- CrowsWildlife
- Dog
- Horse
- HusbandryModuleBase
- HusbandryModuleFood
- HusbandryModuleFoodSpilla...
- HusbandryModuleLiquidManu...
- HusbandryModuleManure
- HusbandryModuleMilk
- HusbandryModulePallets
- HusbandryModuleStraw
- LightWildlife
- RideableAnimal
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
HusbandryModuleLiquidManure
DescriptionThis class handles liquid manure in husbandryParent
HusbandryModuleBaseFunctions
delete
DescriptionDeletes instanceDefinition
delete()Code
26 | function HusbandryModuleLiquidManure:delete() |
27 | |
28 | g_currentMission:removeLiquidManureSilo(self) |
29 | |
30 | HusbandryModuleLiquidManure:superClass().delete(self) |
31 | if self.loadPlace ~= nil then |
32 | self.loadPlace:delete() |
33 | self.loadPlace = nil |
34 | end |
35 | if self.fillPlane ~= nil then |
36 | self.fillPlane:delete() |
37 | self.fillPlane = nil |
38 | end |
39 | end |
getFilltypeInfos
DescriptionDefinitiongetFilltypeInfos()Code
146 | function HusbandryModuleLiquidManure:getFilltypeInfos() |
147 | local result = {} |
148 | |
149 | for fillTypeIndex, _ in pairs(self.loadPlace.fillTypes) do |
150 | local fillType = g_fillTypeManager:getFillTypeByIndex(fillTypeIndex) |
151 | local capacity = self:getCapacity() |
152 | local fillLevel = self:getFillLevel(fillTypeIndex) |
153 | |
154 | table.insert(result, {fillType=fillType, fillLevel=fillLevel, capacity=capacity}) |
155 | end |
156 | return result |
157 | end |
load
DescriptionLoads data from xmlDefinition
load(table xmlFile, string xmlKey, table rootNode)Arguments
table | xmlFile | handle |
string | xmlKey | from which to read the configuration |
table | rootNode | of the husbandry |
boolean | true | if loading was successful else false |
47 | function HusbandryModuleLiquidManure:load(xmlFile, configKey, rootNode, owner, baseDirectory) |
48 | if not HusbandryModuleLiquidManure:superClass().load(self, xmlFile, configKey, rootNode, owner, baseDirectory) then |
49 | return false |
50 | end |
51 | |
52 | if not hasXMLProperty(xmlFile, configKey) then |
53 | return false |
54 | end |
55 | |
56 | local liquidManureNodeId = I3DUtil.indexToObject(rootNode, getXMLString(xmlFile, configKey .. "#node")) |
57 | if liquidManureNodeId ~= nil then |
58 | local loadPlace = LoadTrigger:new(self.owner.isServer, self.owner.isClient) |
59 | |
60 | if loadPlace:load(liquidManureNodeId, xmlFile, configKey) then |
61 | loadPlace:setSource(self) |
62 | loadPlace:register(true) |
63 | |
64 | self.stationName = self.owner:getName() |
65 | self.loadPlace = loadPlace |
66 | self.fillPlane = FillPlane:new() |
67 | self.fillPlane:load(rootNode, xmlFile, configKey..".fillPlane") |
68 | |
69 | for fillTypeIndex, state in pairs(loadPlace.fillTypes) do |
70 | self.fillLevels[fillTypeIndex] = 0.0 |
71 | self.providedFillTypes[fillTypeIndex] = state |
72 | self:setCapacity(0.0) |
73 | end |
74 | |
75 | return true |
76 | else |
77 | loadPlace:delete() |
78 | end |
79 | end |
80 | |
81 | return false |
82 | end |
new
DescriptionCreating managerDefinition
new()Return Values
table | instance | instance of object |
20 | function HusbandryModuleLiquidManure:new(customMt) |
21 | return HusbandryModuleBase:new(customMt or HusbandryModuleLiquidManure_mt) |
22 | end |
onIntervalUpdate
DescriptionUpdate water usageDefinition
onIntervalUpdate(float dayToInterval)Arguments
float | dayToInterval |
122 | function HusbandryModuleLiquidManure:onIntervalUpdate(dayToInterval) |
123 | HusbandryModuleLiquidManure:superClass().onIntervalUpdate(self, dayToInterval) |
124 | |
125 | if self.singleAnimalUsagePerDay > 0 then |
126 | local totalNumAnimals = self.owner:getNumOfAnimals() |
127 | local hasWater = self.owner:hasWater() |
128 | |
129 | if hasWater then |
130 | local newLiquidManure = totalNumAnimals * self.singleAnimalUsagePerDay * dayToInterval |
131 | |
132 | if newLiquidManure > 0 then |
133 | for fillTypeIndex, _ in pairs(self.fillLevels) do |
134 | self:changeFillLevels(newLiquidManure, fillTypeIndex) |
135 | end |
136 | if self.fillPlane ~= nil then |
137 | self.fillPlane:setState(self:getFillProgress()) |
138 | end |
139 | end |
140 | end |
141 | end |
142 | end |
readStream
DescriptionCalled on client side on joinDefinition
readStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
95 | function HusbandryModuleLiquidManure:readStream(streamId, connection) |
96 | HusbandryModuleLiquidManure:superClass().readStream(self, streamId, connection) |
97 | |
98 | if self.loadPlace ~= nil then |
99 | local loadPlaceId = NetworkUtil.readNodeObjectId(streamId) |
100 | self.loadPlace:readStream(streamId, connection) |
101 | g_client:finishRegisterObject(self.loadPlace, loadPlaceId) |
102 | end |
103 | end |
writeStream
DescriptionCalled on server side on joinDefinition
writeStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
109 | function HusbandryModuleLiquidManure:writeStream(streamId, connection) |
110 | HusbandryModuleLiquidManure:superClass().writeStream(self, streamId, connection) |
111 | |
112 | if self.loadPlace ~= nil then |
113 | NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(self.loadPlace)) |
114 | self.loadPlace:writeStream(streamId, connection) |
115 | g_server:registerObjectInStream(connection, self.loadPlace) |
116 | end |
117 | end |