LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

PlaceableProductionPoint

Description
Specialization for placeables
Functions

canBuy

Description
Definition
canBuy()
Code
220function PlaceableProductionPoint:canBuy(superFunc)
221 if not g_currentMission.productionChainManager:getHasFreeSlots() then
222 return false, g_i18n:getText("warning_maxNumOfProdPointsReached")
223 end
224
225 return superFunc(self)
226end

collectPickObjects

Description
Definition
collectPickObjects()
Code
197function PlaceableProductionPoint:collectPickObjects(superFunc, node)
198 local spec = self.spec_productionPoint
199 if spec.productionPoint.loadingStation ~= nil then
200 for i=1, #spec.productionPoint.loadingStation.loadTriggers do
201 local loadTrigger = spec.productionPoint.loadingStation.loadTriggers[i]
202 if node == loadTrigger.triggerNode then
203 return
204 end
205 end
206 end
207
208 for i=1, #spec.productionPoint.unloadingStation.unloadTriggers do
209 local unloadTrigger = spec.productionPoint.unloadingStation.unloadTriggers[i]
210 if node == unloadTrigger.exactFillRootNode then
211 return
212 end
213 end
214
215 superFunc(self, node)
216end

initSpecialization

Description
Definition
initSpecialization()
Code
73function PlaceableProductionPoint.initSpecialization()
74 g_storeManager:addSpecType("prodPointInputFillTypes", "shopListAttributeIconInput", ProductionPoint.loadSpecValueInputFillTypes, ProductionPoint.getSpecValueInputFillTypes, "placeable")
75 g_storeManager:addSpecType("prodPointOutputFillTypes", "shopListAttributeIconOutput", ProductionPoint.loadSpecValueOutputFillTypes, ProductionPoint.getSpecValueOutputFillTypes, "placeable")
76end

loadFromXMLFile

Description
Definition
loadFromXMLFile()
Code
168function PlaceableProductionPoint:loadFromXMLFile(xmlFile, key)
169 local spec = self.spec_productionPoint
170 if spec.productionPoint ~= nil then
171 spec.productionPoint:loadFromXMLFile(xmlFile, key)
172 end
173end

onDelete

Description
Definition
onDelete()
Code
96function PlaceableProductionPoint:onDelete()
97 local spec = self.spec_productionPoint
98
99 if spec.productionPoint ~= nil then
100 spec.productionPoint:delete()
101 spec.productionPoint = nil
102 end
103end

onFinalizePlacement

Description
Definition
onFinalizePlacement()
Code
107function PlaceableProductionPoint:onFinalizePlacement()
108 local spec = self.spec_productionPoint
109
110 if spec.productionPoint ~= nil then
111 spec.productionPoint:register(true)
112
113 spec.productionPoint:setOwnerFarmId(self:getOwnerFarmId())
114
115 --if not g_currentMission.productionChainManager:addProductionPoint(self.productionPoint) then
116 -- log("PPP: Error: Unable to add production point to manager")
117 -- return false
118 --end
119
120 spec.productionPoint:findStorageExtensions()
121
122 spec.productionPoint:updateFxState()
123 end
124end

onLoad

Description
Called on loading
Definition
onLoad(table savegame)
Arguments
tablesavegamesavegame
Code
81function PlaceableProductionPoint:onLoad(savegame)
82 local spec = self.spec_productionPoint
83
84 local productionPoint = ProductionPoint.new(self.isServer, self.isClient, self.baseDirectory)
85 productionPoint.owningPlaceable = self
86 if productionPoint:load(self.components, self.xmlFile, "placeable.productionPoint", self.customEnvironment, self.i3dMappings) then
87 spec.productionPoint = productionPoint
88 else
89 productionPoint:delete()
90 self:setLoadingState(Placeable.LOADING_STATE_ERROR)
91 end
92end

onReadStream

Description
Definition
onReadStream()
Code
146function PlaceableProductionPoint:onReadStream(streamId, connection)
147 local spec = self.spec_productionPoint
148 if spec.productionPoint ~= nil then
149 local productionPointId = NetworkUtil.readNodeObjectId(streamId)
150 spec.productionPoint:readStream(streamId, connection)
151 g_client:finishRegisterObject(spec.productionPoint, productionPointId)
152 end
153end

onWriteStream

Description
Definition
onWriteStream()
Code
157function PlaceableProductionPoint:onWriteStream(streamId, connection)
158 local spec = self.spec_productionPoint
159 if spec.productionPoint ~= nil then
160 NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(spec.productionPoint))
161 spec.productionPoint:writeStream(streamId, connection)
162 g_server:registerObjectInStream(connection, spec.productionPoint)
163 end
164end

outputsChanged

Description
Definition
outputsChanged()
Code
134function PlaceableProductionPoint:outputsChanged(outputs, state)
135 SpecializationUtil.raiseEvent(self, "onOutputFillTypesChanged", outputs, state)
136end

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 PlaceableProductionPoint.prerequisitesPresent(specializations)
19 return SpecializationUtil.hasSpecialization(PlaceableInfoTrigger, specializations)
20end

productionStatusChanged

Description
Definition
productionStatusChanged()
Code
140function PlaceableProductionPoint:productionStatusChanged(production, status)
141 SpecializationUtil.raiseEvent(self, "onProductionStatusChanged", production, status)
142end

registerEventListeners

Description
Definition
registerEventListeners()
Code
47function PlaceableProductionPoint.registerEventListeners(placeableType)
48 SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableProductionPoint)
49 SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableProductionPoint)
50 SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", PlaceableProductionPoint)
51 SpecializationUtil.registerEventListener(placeableType, "onWriteStream", PlaceableProductionPoint)
52 SpecializationUtil.registerEventListener(placeableType, "onReadStream", PlaceableProductionPoint)
53end

registerEvents

Description
Definition
registerEvents()
Code
24function PlaceableProductionPoint.registerEvents(placeableType)
25 SpecializationUtil.registerEvent(placeableType, "onOutputFillTypesChanged")
26 SpecializationUtil.registerEvent(placeableType, "onProductionStatusChanged")
27end

registerFunctions

Description
Definition
registerFunctions()
Code
31function PlaceableProductionPoint.registerFunctions(placeableType)
32 SpecializationUtil.registerFunction(placeableType, "outputsChanged", PlaceableProductionPoint.outputsChanged)
33 SpecializationUtil.registerFunction(placeableType, "productionStatusChanged", PlaceableProductionPoint.productionStatusChanged)
34end

registerOverwrittenFunctions

Description
Definition
registerOverwrittenFunctions()
Code
38function PlaceableProductionPoint.registerOverwrittenFunctions(placeableType)
39 SpecializationUtil.registerOverwrittenFunction(placeableType, "setOwnerFarmId", PlaceableProductionPoint.setOwnerFarmId)
40 SpecializationUtil.registerOverwrittenFunction(placeableType, "collectPickObjects", PlaceableProductionPoint.collectPickObjects)
41 SpecializationUtil.registerOverwrittenFunction(placeableType, "canBuy", PlaceableProductionPoint.canBuy)
42 SpecializationUtil.registerOverwrittenFunction(placeableType, "updateInfo", PlaceableProductionPoint.updateInfo)
43end

registerSavegameXMLPaths

Description
Definition
registerSavegameXMLPaths()
Code
65function PlaceableProductionPoint.registerSavegameXMLPaths(schema, basePath)
66 schema:setXMLSpecializationType("ProductionPoint")
67 ProductionPoint.registerSavegameXMLPaths(schema, basePath)
68 schema:setXMLSpecializationType()
69end

registerXMLPaths

Description
Definition
registerXMLPaths()
Code
57function PlaceableProductionPoint.registerXMLPaths(schema, basePath)
58 schema:setXMLSpecializationType("ProductionPoint")
59 ProductionPoint.registerXMLPaths(schema, basePath .. ".productionPoint")
60 schema:setXMLSpecializationType()
61end

saveToXMLFile

Description
Definition
saveToXMLFile()
Code
177function PlaceableProductionPoint:saveToXMLFile(xmlFile, key, usedModNames)
178 local spec = self.spec_productionPoint
179 if spec.productionPoint ~= nil then
180 spec.productionPoint:saveToXMLFile(xmlFile, key, usedModNames)
181 end
182end

setOwnerFarmId

Description
Definition
setOwnerFarmId()
Code
186function PlaceableProductionPoint:setOwnerFarmId(superFunc, farmId, noEventSend)
187 superFunc(self, farmId, noEventSend)
188
189 local spec = self.spec_productionPoint
190 if spec.productionPoint ~= nil then
191 spec.productionPoint:setOwnerFarmId(farmId)
192 end
193end

updateInfo

Description
Definition
updateInfo()
Code
128function PlaceableProductionPoint:updateInfo(superFunc, infoTable)
129 self.spec_productionPoint.productionPoint:updateInfo(superFunc, infoTable)
130end