LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

PlaceableBuyingStation

Description
Specialization for placeables
Functions

collectPickObjects

Description
Definition
collectPickObjects()
Code
117function PlaceableBuyingStation:collectPickObjects(superFunc, node)
118 local spec = self.spec_buyingStation
119 if spec.buyingStation ~= nil then
120 for _, loadTrigger in ipairs(spec.buyingStation.loadTriggers) do
121 if node == loadTrigger.triggerNode then
122 return
123 end
124 end
125 end
126
127 superFunc(self, node)
128end

getBuyingStation

Description
Definition
getBuyingStation()
Code
132function PlaceableBuyingStation:getBuyingStation()
133 return self.spec_buyingStation.buyingStation
134end

onDelete

Description
Definition
onDelete()
Code
72function PlaceableBuyingStation:onDelete()
73 local spec = self.spec_buyingStation
74
75 if spec.buyingStation ~= nil then
76 g_currentMission.storageSystem:removeLoadingStation(spec.buyingStation, spec.buyingStation.owningPlaceable)
77 spec.buyingStation:delete()
78 end
79end

onFinalizePlacement

Description
Definition
onFinalizePlacement()
Code
83function PlaceableBuyingStation:onFinalizePlacement()
84 local spec = self.spec_buyingStation
85
86 if spec.buyingStation ~= nil then
87 spec.buyingStation:register(true)
88 end
89end

onLoad

Description
Called on loading
Definition
onLoad(table savegame)
Arguments
tablesavegamesavegame
Code
55function PlaceableBuyingStation:onLoad(savegame)
56 local spec = self.spec_buyingStation
57
58 local buyingStation = BuyingStation.new(self.isServer, self.isClient)
59 if buyingStation:load(self.components, self.xmlFile, "placeable.buyingStation", self.customEnvironment, self.i3dMappings) then
60 spec.buyingStation = buyingStation
61 spec.buyingStation.owningPlaceable = self
62
63 g_currentMission.storageSystem:addLoadingStation(spec.buyingStation, spec.buyingStation.owningPlaceable)
64 else
65 Logging.xmlError(self.xmlFile, "Could not load buying station")
66 buyingStation:delete()
67 end
68end

onReadStream

Description
Definition
onReadStream()
Code
93function PlaceableBuyingStation:onReadStream(streamId, connection)
94 local spec = self.spec_buyingStation
95 if spec.buyingStation ~= nil then
96 local buyingStationId = NetworkUtil.readNodeObjectId(streamId)
97 spec.buyingStation:readStream(streamId, connection)
98 g_client:finishRegisterObject(spec.buyingStation, buyingStationId)
99 end
100end

onWriteStream

Description
Called on server side on join
Definition
onWriteStream(integer streamId, table connection)
Arguments
integerstreamIdstream ID
tableconnectionconnection
Code
106function PlaceableBuyingStation:onWriteStream(streamId, connection)
107 local spec = self.spec_buyingStation
108 if spec.buyingStation ~= nil then
109 NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(spec.buyingStation))
110 spec.buyingStation:writeStream(streamId, connection)
111 g_server:registerObjectInStream(connection, spec.buyingStation)
112 end
113end

prerequisitesPresent

Description
Checks if all prerequisite specializations are loaded
Definition
prerequisitesPresent(table specializations)
Arguments
tablespecializationsspecializations
Return Values
booleanhasPrerequisitetrue if all prerequisite specializations are loaded
Code
18function PlaceableBuyingStation.prerequisitesPresent(specializations)
19 return true
20end

registerEventListeners

Description
Definition
registerEventListeners()
Code
36function PlaceableBuyingStation.registerEventListeners(placeableType)
37 SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableBuyingStation)
38 SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableBuyingStation)
39 SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", PlaceableBuyingStation)
40 SpecializationUtil.registerEventListener(placeableType, "onReadStream", PlaceableBuyingStation)
41 SpecializationUtil.registerEventListener(placeableType, "onWriteStream", PlaceableBuyingStation)
42end

registerFunctions

Description
Definition
registerFunctions()
Code
24function PlaceableBuyingStation.registerFunctions(placeableType)
25 SpecializationUtil.registerFunction(placeableType, "getBuyingStation", PlaceableBuyingStation.getBuyingStation)
26end

registerOverwrittenFunctions

Description
Definition
registerOverwrittenFunctions()
Code
30function PlaceableBuyingStation.registerOverwrittenFunctions(placeableType)
31 SpecializationUtil.registerOverwrittenFunction(placeableType, "collectPickObjects", PlaceableBuyingStation.collectPickObjects)
32end

registerXMLPaths

Description
Definition
registerXMLPaths()
Code
46function PlaceableBuyingStation.registerXMLPaths(schema, basePath)
47 schema:setXMLSpecializationType("BuyingStation")
48 BuyingStation.registerXMLPaths(schema, basePath .. ".buyingStation")
49 schema:setXMLSpecializationType()
50end