Script v1.4.4.0
- Handtools
- Events
- Objects
- Placeables
- AnimatedObjectPlaceable
- BeehivePlaceable
- GreenhousePlaceable
- HayLoftPlaceable
- HeatingPlantPlaceable
- HighPressureWasherPlaceab...
- Placeable
- SolarCollectorPlaceable
- WindTurbinePlaceable
- Triggers
- Utils
- Vehicles
- Specializations
Engine v7.0.0.2
- General
- Entity
- Node
- Scenegraph
- Lighting
- Camera
- Shape
- Particle System
- Physics
- Spline
- Animation
- Overlays
- Sound
- Input
- XML
- Network
- Callbacks
- Text Rendering
- Terrain Detail
- Tire Track
- Editor
- Rendering
- String
- Math
- I3D
- Fillplanes
Foundation Reference
HeatingPlantPlaceable
DescriptionClass for placeable heating plantsParent
PlaceableFunctions
- new
- delete
- load
- readStream
- writeStream
- readUpdateStream
- writeUpdateStream
- collectPickObjects
- update
- updateTick
- onUpdateEvent
new
DescriptionCreating placeable high pressure washerDefinition
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 HeatingPlantPlaceable:new(isServer, isClient, customMt) |
19 | local mt = customMt; |
20 | if mt == nil then |
21 | mt = HeatingPlantPlaceable_mt; |
22 | end; |
23 | |
24 | local self = Placeable:new(isServer, isClient, mt); |
25 | |
26 | registerObjectClassName(self, "HeatingPlantPlaceable"); |
27 | |
28 | self.heatingPlantDirtyFlag = self:getNextDirtyFlag(); |
29 | |
30 | return self; |
31 | end; |
delete
DescriptionDeleting heating plantDefinition
delete()Code
35 | function HeatingPlantPlaceable:delete() |
36 | if self.tipTrigger ~= nil then |
37 | self.tipTrigger:removeUpdateEventListener(self) |
38 | if self.tipTrigger.isRegistered then |
39 | self.tipTrigger:unregister() |
40 | end |
41 | self.tipTrigger:delete() |
42 | end |
43 | |
44 | if self.exhaustEffect ~= nil then |
45 | Utils.releaseSharedI3DFile(self.exhaustEffect.filename, self.baseDirectory, true); |
46 | end |
47 | |
48 | unregisterObjectClassName(self); |
49 | HeatingPlantPlaceable:superClass().delete(self); |
50 | end; |
load
DescriptionLoad heating plantDefinition
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 |
63 | function HeatingPlantPlaceable:load(xmlFilename, x,y,z, rx,ry,rz, initRandom) |
64 | if not HeatingPlantPlaceable:superClass().load(self, xmlFilename, x,y,z, rx,ry,rz, initRandom) then |
65 | return false; |
66 | end; |
67 | |
68 | local xmlFile = loadXMLFile("TempXML", xmlFilename); |
69 | |
70 | self.tipTrigger = TipTrigger:new(self.isServer, self.isClient) |
71 | if self.tipTrigger:load(Utils.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.heatingPlant#tipTrigger"))) then |
72 | self.tipTrigger:register(true) |
73 | self.tipTrigger:addUpdateEventListener(self) |
74 | else |
75 | self.tipTrigger:delete() |
76 | self.tipTrigger = nil |
77 | end |
78 | |
79 | if self.isClient then |
80 | self.heatingPlantRotationNodes = Utils.loadRotationNodes(xmlFile, {}, "placeable.turnedOnRotationNodes.turnedOnRotationNode", "heatingPlant", self.nodeId); |
81 | |
82 | local filename = getXMLString(xmlFile, "placeable.exhaust#filename"); |
83 | local node = Utils.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.exhaust#index")); |
84 | if filename ~= nil then |
85 | local i3dNode = Utils.loadSharedI3DFile(filename, self.baseDirectory, false, false, false); |
86 | if i3dNode ~= 0 then |
87 | self.exhaustEffect = {} |
88 | self.exhaustEffect.node = getChildAt(i3dNode, 0); |
89 | self.exhaustEffect.filename = filename |
90 | link(Utils.getNoNil(node, self.nodeId), self.exhaustEffect.node); |
91 | setVisibility(self.exhaustEffect.node, false); |
92 | setShaderParameter(self.exhaustEffect.node, "param", 0, 0, 0, 0.4, false); |
93 | delete(i3dNode); |
94 | end |
95 | end |
96 | end |
97 | |
98 | self.workingTimeDuration = 120*1000 |
99 | self.workingTime = 0 |
100 | |
101 | delete(xmlFile); |
102 | |
103 | return true; |
104 | end; |
readStream
DescriptionCalled on client side on joinDefinition
readStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
110 | function HeatingPlantPlaceable:readStream(streamId, connection) |
111 | HeatingPlantPlaceable:superClass().readStream(self, streamId, connection); |
112 | if connection:getIsServer() then |
113 | local tipTriggerId = readNetworkNodeObjectId(streamId); |
114 | self.tipTrigger:readStream(streamId, connection); |
115 | g_client:finishRegisterObject(self.tipTrigger, tipTriggerId); |
116 | end |
117 | end |
writeStream
DescriptionCalled on server side on joinDefinition
writeStream(integer streamId, table connection)Arguments
integer | streamId | stream ID |
table | connection | connection |
123 | function HeatingPlantPlaceable:writeStream(streamId, connection) |
124 | HeatingPlantPlaceable:superClass().writeStream(self, streamId, connection); |
125 | if not connection:getIsServer() then |
126 | writeNetworkNodeObjectId(streamId, self.tipTrigger.id); |
127 | self.tipTrigger:writeStream(streamId, connection); |
128 | g_server:registerObjectInStream(connection, self.tipTrigger); |
129 | end |
130 | 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 |
137 | function HeatingPlantPlaceable:readUpdateStream(streamId, timestamp, connection) |
138 | HeatingPlantPlaceable:superClass().readUpdateStream(self, streamId, timestamp, connection); |
139 | if connection:getIsServer() then |
140 | local workingTimeBiggerZero = streamReadBool(streamId) |
141 | if workingTimeBiggerZero then |
142 | self.workingTime = self.workingTimeDuration |
143 | if self.exhaustEffect ~= nil then |
144 | setVisibility(self.exhaustEffect.node, true); |
145 | end |
146 | end |
147 | end; |
148 | 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 |
155 | function HeatingPlantPlaceable:writeUpdateStream(streamId, connection, dirtyMask) |
156 | HeatingPlantPlaceable:superClass().writeUpdateStream(self, streamId, connection, dirtyMask); |
157 | if not connection:getIsServer() then |
158 | streamWriteBool(streamId, self.workingTime > 0) |
159 | end; |
160 | end; |
collectPickObjects
DescriptionCollect pick objectsDefinition
collectPickObjects(integer node)Arguments
integer | node | node id |
165 | function HeatingPlantPlaceable:collectPickObjects(node) |
166 | if self.tipTrigger == nil or self.tipTrigger.shovelTarget == nil or self.tipTrigger.shovelTarget.nodeId ~= node then |
167 | HeatingPlantPlaceable:superClass().collectPickObjects(self, node) |
168 | end |
169 | end; |
update
DescriptionUpdateDefinition
update(float dt)Arguments
float | dt | time since last call in ms |
174 | function HeatingPlantPlaceable:update(dt) |
175 | HeatingPlantPlaceable:superClass().update(self, dt); |
176 | |
177 | if self.isClient then |
178 | if self.workingTime > 0 then |
179 | self.workingTime = self.workingTime - dt |
180 | if self.workingTime <= 0 then |
181 | if self.exhaustEffect ~= nil then |
182 | setVisibility(self.exhaustEffect.node, false); |
183 | end |
184 | end |
185 | end |
186 | |
187 | Utils.updateRotationNodes(self, self.heatingPlantRotationNodes, dt, self.workingTime > 0); |
188 | end |
189 | end |
updateTick
DescriptionUpdate tickDefinition
updateTick(float dt)Arguments
float | dt | time since last call in ms |
194 | function HeatingPlantPlaceable:updateTick(dt) |
195 | HeatingPlantPlaceable:superClass().updateTick(self, dt); |
196 | end |
onUpdateEvent
DescriptionCalled if someone filled in somethingDefinition
onUpdateEvent(table trigger, float fillDelta, integer fillType, table trailer, table tipTriggerTarget)Arguments
table | trigger | trigger |
float | fillDelta | delta filled in |
integer | fillType | fill type filled in |
table | trailer | object of trailer |
table | tipTriggerTarget | tip trigger target |
205 | function HeatingPlantPlaceable:onUpdateEvent(trigger, fillDelta, fillType, trailer, tipTriggerTarget) |
206 | if self.exhaustEffect ~= nil then |
207 | setVisibility(self.exhaustEffect.node, true); |
208 | end |
209 | if self.isServer then |
210 | self:raiseDirtyFlags(self.heatingPlantDirtyFlag); |
211 | end |
212 | self.workingTime = self.workingTimeDuration |
213 | end |