Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- AnimalHusbandry
- BeehivePlaceable
- BgaPlaceable
- BunkerSiloPlaceable
- BuyingStationPlaceable
- Doghouse
- FarmhousePlaceable
- GreenhousePlaceable
- HeatingPlantPlaceable
- HusbandryModuleWater
- Placeable
- SellingStationPlaceable
- SiloExtensionPlaceable
- SiloPlaceable
- SolarCollectorPlaceable
- WindTurbinePlaceable
- WoodSellStationPlaceable
- 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
GreenhousePlaceable
DescriptionClass for placeable greenhouseParent
PlaceableFunctions
- collectPickObjects
- delete
- finalizePlacement
- getCanInteract
- getCapacity
- getFillLevel
- getFreeCapacity
- getIsFillTypeSupported
- getSupportedFillTypes
- hourChanged
- interactionTriggerCallback
- load
- loadFromXMLFile
- new
- readStream
- readUpdateStream
- register
- saveToXMLFile
- setFillLevel
- setIsWaterTankFilling
- setOwnerFarmId
- update
- writeStream
- writeUpdateStream
collectPickObjects
DescriptionCollect pick objects. (Skip unload trigger nodes to protect against double registration)Definition
collectPickObjects(integer node)Arguments
integer | node | node id |
292 | function GreenhousePlaceable:collectPickObjects(node) |
293 | local foundNode = false |
294 | for _, unloadTrigger in ipairs(self.manureTankStation.unloadTriggers) do |
295 | if node == unloadTrigger.exactFillRootNode then |
296 | foundNode = true |
297 | break |
298 | end |
299 | end |
300 | |
301 | for _, unloadTrigger in ipairs(self.waterTankStation.unloadTriggers) do |
302 | if node == unloadTrigger.exactFillRootNode then |
303 | foundNode = true |
304 | break |
305 | end |
306 | end |
307 | |
308 | if not foundNode then |
309 | GreenhousePlaceable:superClass().collectPickObjects(self, node) |
310 | end |
311 | end |
delete
DescriptionDeleting placeable greenhouseDefinition
delete()Code
53 | function GreenhousePlaceable:delete() |
54 | if self.manureTankStation ~= nil then |
55 | g_currentMission.storageSystem:removeUnloadingStation(self.manureTankStation) |
56 | self.manureTankStation:delete() |
57 | end |
58 | if self.waterTankStation ~= nil then |
59 | g_currentMission.storageSystem:removeUnloadingStation(self.waterTankStation) |
60 | self.waterTankStation:delete() |
61 | end |
62 | |
63 | if self.interactionTriggerNode ~= nil then |
64 | removeTrigger(self.interactionTriggerNode) |
65 | end |
66 | |
67 | unregisterObjectClassName(self) |
68 | g_currentMission.environment:removeHourChangeListener(self) |
69 | |
70 | if g_client ~= nil then |
71 | for _,sample in pairs(self.samples) do |
72 | g_soundManager:deleteSample(sample) |
73 | end |
74 | end |
75 | |
76 | GreenhousePlaceable:superClass().delete(self) |
77 | end |
finalizePlacement
DescriptionCalled if placeable is placedDefinition
finalizePlacement()Code
236 | function GreenhousePlaceable:finalizePlacement() |
237 | GreenhousePlaceable:superClass().finalizePlacement(self) |
238 | |
239 | g_currentMission.environment:addHourChangeListener(self) |
240 | end |
getCanInteract
DescriptionReturns true if info should showDefinition
getCanInteract()Return Values
boolean | showInfo | show info |
330 | function GreenhousePlaceable:getCanInteract() |
331 | if g_currentMission.controlPlayer and self.playerInRange then |
332 | return true |
333 | end |
334 | if not g_currentMission.controlPlayer then |
335 | for vehicle in pairs(self.vehiclesInRange) do |
336 | if vehicle:getIsActiveForInput(true) then |
337 | return true |
338 | end |
339 | end |
340 | end |
341 | |
342 | return false |
343 | end |
getCapacity
DescriptionGet capacityDefinition
getCapacity()Code
418 | function GreenhousePlaceable:getCapacity(fillTypeIndex) |
419 | if fillTypeIndex == FillType.MANURE then |
420 | return self.manureTankCapacity |
421 | else |
422 | return self.waterTankCapacity |
423 | end |
424 | end |
getFillLevel
DescriptionGet fill levelDefinition
getFillLevel()Code
408 | function GreenhousePlaceable:getFillLevel(fillTypeIndex) |
409 | if fillTypeIndex == FillType.MANURE then |
410 | return self.manureTankFillLevel |
411 | else |
412 | return self.waterTankFillLevel |
413 | end |
414 | end |
getFreeCapacity
DescriptionGet free capacityDefinition
getFreeCapacity()Code
469 | function GreenhousePlaceable:getFreeCapacity(fillTypeIndex) |
470 | if fillTypeIndex == FillType.MANURE then |
471 | return self.manureTankCapacity - self.manureTankFillLevel |
472 | else |
473 | return self.waterTankCapacity - self.waterTankFillLevel |
474 | end |
475 | end |
getIsFillTypeSupported
DescriptionGet supported fill types for given stationDefinition
getIsFillTypeSupported()Code
402 | function GreenhousePlaceable:getIsFillTypeSupported(fillTypeIndex, station) |
403 | return (fillTypeIndex == FillType.MANURE and station == self.manureTankStation) or (fillTypeIndex == FillType.WATER and station == self.waterTankStation) |
404 | end |
getSupportedFillTypes
DescriptionGet supported fill typesDefinition
getSupportedFillTypes()Code
479 | function GreenhousePlaceable:getSupportedFillTypes() |
480 | return {FillType.MANURE, FillType.WATER} |
481 | end |
hourChanged
DescriptionCalled if hour changedDefinition
hourChanged()Code
347 | function GreenhousePlaceable:hourChanged() |
348 | if self.isServer then |
349 | self:setFillLevel(self.waterTankFillLevel - self.waterTankUsagePerHour, FillType.WATER) |
350 | self:setFillLevel(self.manureTankFillLevel - self.manureUsagePerHour, FillType.MANURE) |
351 | |
352 | if self.isFruitAlive then |
353 | local income = self.incomePerHour |
354 | if self.manureTankFillLevel > 0 then |
355 | income = income * 2 |
356 | end |
357 | |
358 | g_currentMission:addMoney(income, self:getOwnerFarmId(), MoneyType.PROPERTY_INCOME, true) |
359 | end |
360 | end |
361 | end |
interactionTriggerCallback
DescriptioninteractionTriggerCallbackDefinition
interactionTriggerCallback(integer triggerId, integer otherId, boolean onEnter, boolean onLeave, boolean onStay, integer otherId)Arguments
integer | triggerId | id of trigger |
integer | otherId | id of actor |
boolean | onEnter | on enter |
boolean | onLeave | on leave |
boolean | onStay | on stay |
integer | otherId | id of other actor |
503 | function GreenhousePlaceable:interactionTriggerCallback(triggerId, otherId, onEnter, onLeave, onStay, otherShapeId) |
504 | if onEnter or onLeave then |
505 | if g_currentMission.player ~= nil and otherId == g_currentMission.player.rootNode then |
506 | if onEnter then |
507 | self.playerInRange = true |
508 | else |
509 | self.playerInRange = false |
510 | end |
511 | else |
512 | local vehicle = g_currentMission.nodeToObject[otherShapeId] |
513 | if vehicle ~= nil then |
514 | if onEnter then |
515 | if self.vehiclesInRange[vehicle] == nil then |
516 | self.vehiclesInRange[vehicle] = true |
517 | self.numVehiclesInRange = self.numVehiclesInRange + 1 |
518 | end |
519 | else |
520 | if self.vehiclesInRange[vehicle] then |
521 | self.vehiclesInRange[vehicle] = nil |
522 | self.numVehiclesInRange = self.numVehiclesInRange - 1 |
523 | end |
524 | end |
525 | end |
526 | end |
527 | end |
528 | end |
load
DescriptionLoad greenhouseDefinition
load(string xmlFilename, float x, float y, float z, float rx, float ry, float rz, boolean initRandom)Arguments
string | xmlFilename | xml file name |
float | x | x world position |
float | y | z world position |
float | z | z world position |
float | rx | rx world rotation |
float | ry | ry world rotation |
float | rz | rz world rotation |
boolean | initRandom | initialize random |
boolean | success | success |
162 | function GreenhousePlaceable:load(xmlFilename, x,y,z, rx,ry,rz, initRandom) |
163 | if not GreenhousePlaceable:superClass().load(self, xmlFilename, x,y,z, rx,ry,rz, initRandom) then |
164 | return false |
165 | end |
166 | |
167 | local xmlFile = loadXMLFile("TempXML", xmlFilename) |
168 | |
169 | local fruitAlive = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.greenhouse.fruit#alive")) |
170 | local fruitDead = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.greenhouse.fruit#dead")) |
171 | if fruitAlive ~= nil then |
172 | self.fruitAlive = fruitAlive |
173 | end |
174 | if fruitDead ~= nil then |
175 | self.fruitDead = fruitDead |
176 | end |
177 | |
178 | self.interactionTriggerNode = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.greenhouse.interactionTrigger#node")) |
179 | if self.interactionTriggerNode ~= nil then |
180 | addTrigger(self.interactionTriggerNode, "interactionTriggerCallback", self) |
181 | end |
182 | |
183 | self.waterTankCapacity = Utils.getNoNil(getXMLFloat(xmlFile, "placeable.greenhouse.waterTank#capacity"), self.waterTankCapacity) |
184 | self.waterTankUsagePerHour = Utils.getNoNil(getXMLFloat(xmlFile, "placeable.greenhouse.waterTank#usagePerHour"), self.waterTankUsagePerHour) |
185 | self.waterTankFillLitersPerSecond = Utils.getNoNil(getXMLFloat(xmlFile, "placeable.greenhouse.waterTank#fillLitersPerSecond"), self.waterTankFillLitersPerSecond) |
186 | local unloadingNode = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.greenhouse.waterTank.unloadingStation#node")) |
187 | if unloadingNode ~= nil then |
188 | local unloadingStation = UnloadingStation:new(self.isServer, self.isClient) |
189 | if unloadingStation:load(unloadingNode, xmlFile, "placeable.greenhouse.waterTank.unloadingStation", self.customEnvironment) then |
190 | self.waterTankStation = unloadingStation |
191 | unloadingStation:addTargetStorage(self) |
192 | else |
193 | unloadingStation:delete() |
194 | end |
195 | end |
196 | |
197 | self.samples = {} |
198 | if g_client ~= nil then |
199 | self.samples.refuel = g_soundManager:loadSampleFromXML(xmlFile, "placeable.greenhouse.waterTank.sounds", "refuel", self.baseDirectory, self.nodeId, 0, AudioGroup.VEHICLE, nil, nil) |
200 | end |
201 | |
202 | self.manurePlane = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.greenhouse.manureTank.manurePlane#node")) |
203 | |
204 | local unloadingNode = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.greenhouse.manureTank.unloadingStation#node")) |
205 | if unloadingNode ~= nil then |
206 | local unloadingStation = UnloadingStation:new(self.isServer, self.isClient) |
207 | if unloadingStation:load(unloadingNode, xmlFile, "placeable.greenhouse.manureTank.unloadingStation", self.customEnvironment) then |
208 | self.manureTankStation = unloadingStation |
209 | unloadingStation:addTargetStorage(self) |
210 | else |
211 | unloadingStation:delete() |
212 | end |
213 | end |
214 | |
215 | local minY, maxY = StringUtil.getVectorFromString(getXMLString(xmlFile, "placeable.greenhouse.manureTank.manurePlane#minMaxY")) |
216 | if minY ~= nil and maxY ~= nil then |
217 | self.manurePlaneMinY = minY |
218 | self.manurePlaneMaxY = maxY |
219 | end |
220 | self.manureTankCapacity = Utils.getNoNil(getXMLFloat(xmlFile, "placeable.greenhouse.manureTank#capacity"), self.manureTankCapacity) |
221 | self.manureUsagePerHour = Utils.getNoNil(getXMLFloat(xmlFile, "placeable.greenhouse.manureTank#usagePerHour"), self.manureUsagePerHour) |
222 | |
223 | delete(xmlFile) |
224 | |
225 | self:setFillLevel(0, FillType.WATER) |
226 | self.sentWaterTankFillLevel = self.waterTankFillLevel |
227 | |
228 | self:setFillLevel(0, FillType.MANURE) |
229 | self.sentManureFillLevel = self.manureTankFillLevel |
230 | |
231 | return true |
232 | end |
loadFromXMLFile
DescriptionLoading from attributes and nodesDefinition
loadFromXMLFile(integer xmlFile, string key, boolean resetVehicles)Arguments
integer | xmlFile | id of xml object |
string | key | key |
boolean | resetVehicles | reset vehicles |
boolean | success | success |
260 | function GreenhousePlaceable:loadFromXMLFile(xmlFile, key, resetVehicles) |
261 | if not GreenhousePlaceable:superClass().loadFromXMLFile(self, xmlFile, key, resetVehicles) then |
262 | return false |
263 | end |
264 | |
265 | local waterTankFillLevel = getXMLFloat(xmlFile, key.."#waterTankFillLevel") |
266 | if waterTankFillLevel ~= nil then |
267 | self:setFillLevel(waterTankFillLevel, FillType.WATER) |
268 | end |
269 | local manureFillLevel = getXMLFloat(xmlFile, key.."#manureFillLevel") |
270 | if manureFillLevel ~= nil then |
271 | self:setFillLevel(manureFillLevel, FillType.MANURE) |
272 | end |
273 | |
274 | return true |
275 | end |
new
DescriptionCreating placeable greenhouseDefinition
new(boolean isServer, boolean isClient, table customMt)Arguments
boolean | isServer | is server |
boolean | isClient | is client |
table | customMt | custom metatable |
table | instance | Instance of object |
18 | function GreenhousePlaceable:new(isServer, isClient, customMt) |
19 | local self = Placeable:new(isServer, isClient, customMt or GreenhousePlaceable_mt) |
20 | |
21 | registerObjectClassName(self, "GreenhousePlaceable") |
22 | |
23 | self.waterTankCapacity = 1000 |
24 | self.waterTankFillLevel = 1000 |
25 | self.sentWaterTankFillLevel = self.waterTankFillLevel |
26 | self.waterTankUsagePerHour = 0 |
27 | self.waterTankFillLitersPerSecond = 200 |
28 | self.waterTrailers = {} |
29 | self.isFruitAlive = true |
30 | self.displayFruit = false |
31 | |
32 | self.manureTankFillLevel = 0 |
33 | self.manureUsagePerHour = 0 |
34 | self.manureTankCapacity = 200 |
35 | self.manurePlaneMinY = 0 |
36 | self.manurePlaneMaxY = 1 |
37 | self.sentManureFillLevel = self.manureTankFillLevel |
38 | |
39 | self.vehiclesInRange = {} |
40 | self.playerInRange = false |
41 | |
42 | self.greenhousePlaceableDirtyFlag = self:getNextDirtyFlag() |
43 | |
44 | self.playerInRange = false |
45 | self.vehiclesInRange = {} |
46 | self.numVehiclesInRange = 0 |
47 | |
48 | return self |
49 | end |
readStream
DescriptionCalled on client side on joinDefinition
readStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
83 | function GreenhousePlaceable:readStream(streamId, connection) |
84 | GreenhousePlaceable:superClass().readStream(self, streamId, connection) |
85 | if connection:getIsServer() then |
86 | local waterTankFillLevel = streamReadUInt8(streamId)/255*self.waterTankCapacity |
87 | self:setFillLevel(waterTankFillLevel, FillType.WATER) |
88 | |
89 | local manureFillLevel = streamReadUInt8(streamId)/255*self.manureTankCapacity |
90 | self:setFillLevel(manureFillLevel, FillType.MANURE) |
91 | |
92 | local unloadTriggerId = NetworkUtil.readNodeObjectId(streamId) |
93 | self.waterTankStation:readStream(streamId, connection) |
94 | g_client:finishRegisterObject(self.waterTankStation, unloadTriggerId) |
95 | |
96 | local unloadingStationId = NetworkUtil.readNodeObjectId(streamId) |
97 | self.manureTankStation:readStream(streamId, connection) |
98 | g_client:finishRegisterObject(self.manureTankStation, unloadingStationId) |
99 | end |
100 | end |
readUpdateStream
DescriptionCalled on client side on updateDefinition
readUpdateStream(integer streamId, integer timestamp, table connection)Arguments
integer | streamId | stream ID |
integer | timestamp | timestamp |
table | connection | connection |
127 | function GreenhousePlaceable:readUpdateStream(streamId, timestamp, connection) |
128 | GreenhousePlaceable:superClass().readUpdateStream(self, streamId, timestamp, connection) |
129 | if connection:getIsServer() then |
130 | local waterTankFillLevel = streamReadUInt8(streamId)/255*self.waterTankCapacity |
131 | self:setFillLevel(waterTankFillLevel, FillType.WATER) |
132 | |
133 | local manureFillLevel = streamReadUInt8(streamId)/255*self.manureTankCapacity |
134 | self:setFillLevel(manureFillLevel, FillType.MANURE) |
135 | end |
136 | end |
register
DescriptionCalled when the object is registered. Register any owned objectsDefinition
register()Code
244 | function GreenhousePlaceable:register(...) |
245 | GreenhousePlaceable:superClass().register(self, ...) |
246 | |
247 | self.manureTankStation:register(true) |
248 | g_currentMission.storageSystem:addUnloadingStation(self.manureTankStation) |
249 | |
250 | self.waterTankStation:register(true) |
251 | g_currentMission.storageSystem:addUnloadingStation(self.waterTankStation) |
252 | end |
saveToXMLFile
DescriptionGet save attributes and nodesDefinition
saveToXMLFile(string nodeIdent)Arguments
string | nodeIdent | node ident |
string | attributes | attributes |
string | nodes | nodes |
282 | function GreenhousePlaceable:saveToXMLFile(xmlFile, key, usedModNames) |
283 | GreenhousePlaceable:superClass().saveToXMLFile(self, xmlFile, key, usedModNames) |
284 | |
285 | setXMLFloat(xmlFile, key.."#waterTankFillLevel", self.waterTankFillLevel) |
286 | setXMLFloat(xmlFile, key.."#manureFillLevel", self.manureTankFillLevel) |
287 | end |
setFillLevel
DescriptionSet fill levelDefinition
setFillLevel()Code
428 | function GreenhousePlaceable:setFillLevel(fillLevel, fillTypeIndex) |
429 | if fillTypeIndex == FillType.MANURE then |
430 | self.manureTankFillLevel = MathUtil.clamp(fillLevel, 0, self.manureTankCapacity) |
431 | |
432 | if self.manurePlane ~= nil then |
433 | setVisibility(self.manurePlane, self.manureTankFillLevel > 0.0001) |
434 | local x,y,z = getTranslation(self.manurePlane) |
435 | y = self.manurePlaneMinY + self.manureTankFillLevel / self.manureTankCapacity * (self.manurePlaneMaxY - self.manurePlaneMinY) |
436 | |
437 | setTranslation(self.manurePlane, x,y,z) |
438 | end |
439 | |
440 | if self.manureTankFillLevel ~= self.sentManureFillLevel then |
441 | self:raiseDirtyFlags(self.greenhousePlaceableDirtyFlag) |
442 | self.sentManureFillLevel = self.manureTankFillLevel |
443 | end |
444 | elseif fillTypeIndex == FillType.WATER then |
445 | self.waterTankFillLevel = MathUtil.clamp(fillLevel, 0, self.waterTankCapacity) |
446 | |
447 | if self.waterTankFillLevel ~= self.sentWaterTankFillLevel then |
448 | self:raiseDirtyFlags(self.greenhousePlaceableDirtyFlag) |
449 | self.sentWaterTankFillLevel = self.waterTankFillLevel |
450 | end |
451 | |
452 | self.isFruitAlive = self.waterTankFillLevel > 0.0001 |
453 | |
454 | if self.waterTankFillLevel > 0 then |
455 | self.displayFruit = true |
456 | end |
457 | |
458 | if self.fruitAlive ~= nil then |
459 | setVisibility(self.fruitAlive, self.isFruitAlive and self.displayFruit) |
460 | end |
461 | if self.fruitDead ~= nil then |
462 | setVisibility(self.fruitDead, not self.isFruitAlive and self.displayFruit) |
463 | end |
464 | end |
465 | end |
setIsWaterTankFilling
DescriptionSet is water tank fillingDefinition
setIsWaterTankFilling(boolean isWaterTankFilling, table trailer, boolean noEventSend)Arguments
boolean | isWaterTankFilling | is water tank filling |
table | trailer | trailer |
boolean | noEventSend | no event send |
368 | function GreenhousePlaceable:setIsWaterTankFilling(isWaterTankFilling, trailer, noEventSend) |
369 | GreenhouseSetIsWaterTankFillingEvent.sendEvent(self, isWaterTankFilling, trailer, noEventSend) |
370 | if self.isWaterTankFilling ~= isWaterTankFilling then |
371 | self.isWaterTankFilling = isWaterTankFilling |
372 | self.waterTankFillTrailer = trailer |
373 | end |
374 | if g_client ~= nil then |
375 | if isWaterTankFilling then |
376 | g_soundManager:playSample(self.samples.refuel) |
377 | else |
378 | g_soundManager:stopSample(self.samples.refuel) |
379 | end |
380 | end |
381 | end |
setOwnerFarmId
DescriptionSet owner farm. Updates unloading station for manureDefinition
setOwnerFarmId()Code
385 | function GreenhousePlaceable:setOwnerFarmId(ownerFarmId, noEventSend) |
386 | GreenhousePlaceable:superClass().setOwnerFarmId(self, ownerFarmId, noEventSend) |
387 | |
388 | if self.manureTankStation ~= nil then |
389 | self.manureTankStation:setOwnerFarmId(ownerFarmId) |
390 | end |
391 | if self.waterTankStation ~= nil then |
392 | self.waterTankStation:setOwnerFarmId(ownerFarmId) |
393 | end |
394 | end |
update
DescriptionUpdateDefinition
update(float dt)Arguments
float | dt | time since last call in ms |
316 | function GreenhousePlaceable:update(dt) |
317 | GreenhousePlaceable:superClass().update(self, dt) |
318 | |
319 | if self:getCanInteract() then |
320 | g_currentMission:addExtraPrintText(g_i18n:getText("info_waterFillLevel")..": "..math.floor(self.waterTankFillLevel).." ("..math.floor(100*self.waterTankFillLevel/self.waterTankCapacity).."%)") |
321 | g_currentMission:addExtraPrintText(g_i18n:getText("info_manureFillLevel")..": "..math.floor(self.manureTankFillLevel).." ("..math.floor(100*self.manureTankFillLevel/self.manureTankCapacity).."%)") |
322 | end |
323 | |
324 | self:raiseActive() |
325 | end |
writeStream
DescriptionCalled on server side on joinDefinition
writeStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
106 | function GreenhousePlaceable:writeStream(streamId, connection) |
107 | GreenhousePlaceable:superClass().writeStream(self, streamId, connection) |
108 | if not connection:getIsServer() then |
109 | streamWriteUInt8(streamId, math.floor(self.waterTankFillLevel/self.waterTankCapacity * 255)) |
110 | streamWriteUInt8(streamId, math.floor(self.manureTankFillLevel/self.manureTankCapacity * 255)) |
111 | |
112 | NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(self.waterTankStation)) |
113 | self.waterTankStation:writeStream(streamId, connection) |
114 | g_server:registerObjectInStream(connection, self.waterTankStation) |
115 | |
116 | NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(self.manureTankStation)) |
117 | self.manureTankStation:writeStream(streamId, connection) |
118 | g_server:registerObjectInStream(connection, self.manureTankStation) |
119 | end |
120 | end |
writeUpdateStream
DescriptionCalled on server side on updateDefinition
writeUpdateStream(integer streamId, table connection, integer dirtyMask)Arguments
integer | streamId | stream ID |
table | connection | connection |
integer | dirtyMask | dirty mask |
143 | function GreenhousePlaceable:writeUpdateStream(streamId, connection, dirtyMask) |
144 | GreenhousePlaceable:superClass().writeUpdateStream(self, streamId, connection, dirtyMask) |
145 | if not connection:getIsServer() then |
146 | streamWriteUInt8(streamId, math.floor(self.waterTankFillLevel/self.waterTankCapacity * 255)) |
147 | streamWriteUInt8(streamId, math.floor(self.manureTankFillLevel/self.manureTankCapacity * 255)) |
148 | end |
149 | end |