LUADOC - Farming Simulator 19

SellingStationPlaceable

Description
Class for placeable silo
Functions

collectPickObjects

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

delete

Description
Deleting placeable silo
Definition
delete()
Code
34function SellingStationPlaceable:delete()
35 if self.sellingStation ~= nil then
36 g_currentMission.storageSystem:removeUnloadingStation(self.sellingStation)
37 self.sellingStation:delete()
38 end
39
40 unregisterObjectClassName(self)
41 SellingStationPlaceable:superClass().delete(self)
42end

finalizePlacement

Description
Called if placeable is placed
Definition
finalizePlacement()
Code
73function SellingStationPlaceable:finalizePlacement()
74 SellingStationPlaceable:superClass().finalizePlacement(self)
75 self.sellingStation:register(true)
76 g_currentMission.storageSystem:addUnloadingStation(self.sellingStation)
77end

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

loadFromXMLFile

Description
Loading from attributes and nodes
Definition
loadFromXMLFile(integer xmlFile, string key, boolean resetVehicles)
Arguments
integerxmlFileid of xml object
stringkeykey
booleanresetVehiclesreset vehicles
Return Values
booleansuccesssuccess
Code
128function SellingStationPlaceable:loadFromXMLFile(xmlFile, key, resetVehicles)
129 if not SellingStationPlaceable:superClass().loadFromXMLFile(self, xmlFile, key, resetVehicles) then
130 return false
131 end
132
133 if not self.sellingStation:loadFromXMLFile(xmlFile, key..".sellingStation") then
134 return false
135 end
136
137 return true
138end

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 SellingStationPlaceable:new(isServer, isClient, customMt)
25 local self = Placeable:new(isServer, isClient, customMt or SellStationPlaceable_mt)
26
27 registerObjectClassName(self, "SellingStationPlaceable")
28
29 return self
30end

readStream

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

saveToXMLFile

Description
Get save attributes and nodes
Definition
saveToXMLFile(string nodeIdent)
Arguments
stringnodeIdentnode ident
Return Values
stringattributesattributes
stringnodesnodes
Code
145function SellingStationPlaceable:saveToXMLFile(xmlFile, key, usedModNames)
146 SellingStationPlaceable:superClass().saveToXMLFile(self, xmlFile, key, usedModNames)
147
148 self.sellingStation:saveToXMLFile(xmlFile, key..".sellingStation", usedModNames)
149end

writeStream

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