LUADOC - Farming Simulator 19

BuyingStationPlaceable

Description
Class for placeable silo
Functions

collectPickObjects

Description
Collect pick objects
Definition
collectPickObjects(integer node)
Arguments
integernodenode id
Code
107function BuyingStationPlaceable:collectPickObjects(node)
108 local foundNode = false
109 if not foundNode then
110 for _, loadTrigger in ipairs(self.buyingStation.loadTriggers) do
111 if node == loadTrigger.triggerNode then
112 foundNode = true
113 break
114 end
115 end
116 end
117
118 if not foundNode then
119 BuyingStationPlaceable:superClass().collectPickObjects(self, node)
120 end
121end

delete

Description
Deleting placeable silo
Definition
delete()
Code
34function BuyingStationPlaceable:delete()
35 if self.buyingStation ~= nil then
36 self.buyingStation:delete()
37 end
38
39 unregisterObjectClassName(self)
40 BuyingStationPlaceable:superClass().delete(self)
41end

finalizePlacement

Description
Called if placeable is placed
Definition
finalizePlacement()
Code
72function BuyingStationPlaceable:finalizePlacement()
73 BuyingStationPlaceable:superClass().finalizePlacement(self)
74
75 self.buyingStation:register(true)
76end

load

Description
Load silo
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
54function BuyingStationPlaceable:load(xmlFilename, x,y,z, rx,ry,rz, initRandom)
55 if not BuyingStationPlaceable:superClass().load(self, xmlFilename, x,y,z, rx,ry,rz, initRandom) then
56 return false
57 end
58
59 local xmlFile = loadXMLFile("TempXML", xmlFilename)
60
61 self.buyingStation = BuyingStation:new(self.isServer, self.isClient)
62 self.buyingStation:load(self.nodeId, xmlFile, "placeable.buyingStation", self.customEnvironment)
63 self.buyingStation.owningPlaceable = self
64
65 delete(xmlFile)
66
67 return true
68end

new

Description
Creating placeable silo
Definition
new(boolean isServer, boolean isClient, table customMt)
Arguments
booleanisServeris server
booleanisClientis client
tablecustomMtcustom metatable
Return Values
tableinstanceInstance of object
Code
24function BuyingStationPlaceable:new(isServer, isClient, customMt)
25 local self = Placeable:new(isServer, isClient, customMt or SiloPlaceable_mt)
26
27 registerObjectClassName(self, "BuyingStationPlaceable")
28
29 return self
30end

readStream

Description
Called on client side on join
Definition
readStream(integer streamId, table connection)
Arguments
integerstreamIdstream ID
tableconnectionconnection
Code
82function BuyingStationPlaceable:readStream(streamId, connection)
83 BuyingStationPlaceable:superClass().readStream(self, streamId, connection)
84 if connection:getIsServer() then
85 local buyingStationId = NetworkUtil.readNodeObjectId(streamId)
86 self.buyingStation:readStream(streamId, connection)
87 g_client:finishRegisterObject(self.buyingStation, buyingStationId)
88 end
89end

writeStream

Description
Called on server side on join
Definition
writeStream(integer streamId, table connection)
Arguments
integerstreamIdstream ID
tableconnectionconnection
Code
95function BuyingStationPlaceable:writeStream(streamId, connection)
96 BuyingStationPlaceable:superClass().writeStream(self, streamId, connection)
97 if not connection:getIsServer() then
98 NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(self.buyingStation))
99 self.buyingStation:writeStream(streamId, connection)
100 g_server:registerObjectInStream(connection, self.buyingStation)
101 end
102end