LUADOC - Farming Simulator 19

HeatingPlantPlaceable

Description
Class for placeable heating plants
Parent
Placeable
Functions

collectPickObjects

Description
Collect pick objects
Definition
collectPickObjects(integer node)
Arguments
integernodenode id
Code
162function HeatingPlantPlaceable:collectPickObjects(node)
163 if self.tipTrigger == nil or self.tipTrigger.shovelTarget == nil or self.tipTrigger.shovelTarget.nodeId ~= node then
164 HeatingPlantPlaceable:superClass().collectPickObjects(self, node)
165 end
166end

delete

Description
Deleting heating plant
Definition
delete()
Code
33function HeatingPlantPlaceable:delete()
34 if self.tipTrigger ~= nil then
35 self.tipTrigger:removeUpdateEventListener(self)
36 self.tipTrigger:delete()
37 end
38
39 if self.exhaustEffect ~= nil then
40 g_i3DManager:releaseSharedI3DFile(self.exhaustEffect.filename, self.baseDirectory, true);
41 end
42
43 g_animationManager:deleteAnimations(self.animationNodes)
44
45 unregisterObjectClassName(self);
46 HeatingPlantPlaceable:superClass().delete(self);
47end

load

Description
Load heating plant
Definition
load(string xmlFilename, float x, float y, float z, float rx, float ry, float rz, boolean initRandom)
Arguments
stringxmlFilenamexml file name
floatxx world position
floatyz world position
floatzz world position
floatrxrx world rotation
floatryry world rotation
floatrzrz world rotation
booleaninitRandominitialize random
Return Values
booleansuccesssuccess
Code
60function HeatingPlantPlaceable:load(xmlFilename, x,y,z, rx,ry,rz, initRandom)
61 if not HeatingPlantPlaceable:superClass().load(self, xmlFilename, x,y,z, rx,ry,rz, initRandom) then
62 return false;
63 end;
64
65 local xmlFile = loadXMLFile("TempXML", xmlFilename);
66
67 self.tipTrigger = TipTrigger:new(self.isServer, self.isClient)
68 if self.tipTrigger:load(I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.heatingPlant#tipTrigger"))) then
69 self.tipTrigger:register(true)
70 self.tipTrigger:addUpdateEventListener(self)
71 else
72 self.tipTrigger:delete()
73 self.tipTrigger = nil
74 end
75
76 if self.isClient then
77 self.animationNodes = g_animationManager:loadAnimations(xmlFile, "placeable.animationNodes", self.nodeId, self, nil)
78
79 local filename = getXMLString(xmlFile, "placeable.exhaust#filename");
80 local node = I3DUtil.indexToObject(self.nodeId, getXMLString(xmlFile, "placeable.exhaust#index"));
81 if filename ~= nil then
82 local i3dNode = g_i3DManager:loadSharedI3DFile(filename, self.baseDirectory, false, false, false);
83 if i3dNode ~= 0 then
84 self.exhaustEffect = {}
85 self.exhaustEffect.node = getChildAt(i3dNode, 0);
86 self.exhaustEffect.filename = filename
87 link(Utils.getNoNil(node, self.nodeId), self.exhaustEffect.node);
88 setVisibility(self.exhaustEffect.node, false);
89 setShaderParameter(self.exhaustEffect.node, "param", 0, 0, 0, 0.4, false);
90 delete(i3dNode);
91 end
92 end
93 end
94
95 self.workingTimeDuration = 120*1000
96 self.workingTime = 0
97
98 delete(xmlFile);
99
100 return true;
101end

new

Description
Creating placeable high pressure washer
Definition
new(boolean isServer, boolean isClient, table customMt)
Arguments
booleanisServeris server
booleanisClientis client
tablecustomMtcustom metatable
Return Values
tableinstanceInstance of object
Code
16function HeatingPlantPlaceable:new(isServer, isClient, customMt)
17 local mt = customMt;
18 if mt == nil then
19 mt = HeatingPlantPlaceable_mt;
20 end;
21
22 local self = Placeable:new(isServer, isClient, mt);
23
24 registerObjectClassName(self, "HeatingPlantPlaceable");
25
26 self.heatingPlantDirtyFlag = self:getNextDirtyFlag();
27
28 return self;
29end

onUpdateEvent

Description
Called if someone filled in something
Definition
onUpdateEvent(table trigger, float fillDelta, integer fillType, table trailer, table tipTriggerTarget)
Arguments
tabletriggertrigger
floatfillDeltadelta filled in
integerfillTypefill type filled in
tabletrailerobject of trailer
tabletipTriggerTargettip trigger target
Code
201function HeatingPlantPlaceable:onUpdateEvent(trigger, fillDelta, fillType, trailer, tipTriggerTarget)
202 if self.exhaustEffect ~= nil then
203 setVisibility(self.exhaustEffect.node, true);
204 end
205 if self.isServer then
206 self:raiseDirtyFlags(self.heatingPlantDirtyFlag);
207 end
208 self.workingTime = self.workingTimeDuration
209
210 g_animationManager:startAnimations(self.animationNodes)
211end

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, table connection)
Arguments
integerstreamIdstream ID
tableconnectionconnection
Code
107function HeatingPlantPlaceable:readStream(streamId, connection)
108 HeatingPlantPlaceable:superClass().readStream(self, streamId, connection);
109 if connection:getIsServer() then
110 local tipTriggerId = NetworkUtil.readNodeObjectId(streamId);
111 self.tipTrigger:readStream(streamId, connection);
112 g_client:finishRegisterObject(self.tipTrigger, tipTriggerId);
113 end
114end

readUpdateStream

Description
Called on client side on update
Definition
readUpdateStream(integer streamId, integer timestamp, table connection)
Arguments
integerstreamIdstream ID
integertimestamptimestamp
tableconnectionconnection
Code
134function HeatingPlantPlaceable:readUpdateStream(streamId, timestamp, connection)
135 HeatingPlantPlaceable:superClass().readUpdateStream(self, streamId, timestamp, connection);
136 if connection:getIsServer() then
137 local workingTimeBiggerZero = streamReadBool(streamId)
138 if workingTimeBiggerZero then
139 self.workingTime = self.workingTimeDuration
140 if self.exhaustEffect ~= nil then
141 setVisibility(self.exhaustEffect.node, true);
142 end
143 end
144 end;
145end

update

Description
Update
Definition
update(float dt)
Arguments
floatdttime since last call in ms
Code
171function HeatingPlantPlaceable:update(dt)
172 HeatingPlantPlaceable:superClass().update(self, dt);
173
174 if self.isClient then
175 if self.workingTime > 0 then
176 self.workingTime = self.workingTime - dt
177 if self.workingTime <= 0 then
178 if self.exhaustEffect ~= nil then
179 setVisibility(self.exhaustEffect.node, false);
180 end
181 g_animationManager:stopAnimations(self.animationNodes)
182 end
183 end
184 end
185end

updateTick

Description
Update tick
Definition
updateTick(float dt)
Arguments
floatdttime since last call in ms
Code
190function HeatingPlantPlaceable:updateTick(dt)
191 HeatingPlantPlaceable:superClass().updateTick(self, dt);
192end

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, table connection)
Arguments
integerstreamIdstream ID
tableconnectionconnection
Code
120function HeatingPlantPlaceable:writeStream(streamId, connection)
121 HeatingPlantPlaceable:superClass().writeStream(self, streamId, connection);
122 if not connection:getIsServer() then
123 NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(self.tipTrigger));
124 self.tipTrigger:writeStream(streamId, connection);
125 g_server:registerObjectInStream(connection, self.tipTrigger);
126 end
127end

writeUpdateStream

Description
Called on server side on update
Definition
writeUpdateStream(integer streamId, table connection, integer dirtyMask)
Arguments
integerstreamIdstream ID
tableconnectionconnection
integerdirtyMaskdirty mask
Code
152function HeatingPlantPlaceable:writeUpdateStream(streamId, connection, dirtyMask)
153 HeatingPlantPlaceable:superClass().writeUpdateStream(self, streamId, connection, dirtyMask);
154 if not connection:getIsServer() then
155 streamWriteBool(streamId, self.workingTime > 0)
156 end;
157end