Script v1_7_1_0
- AI
- Animals
- Collections
- Contracts
- Debug
- Economy
- Elements
- EnvironmentalScore
- Errors
- Events
- GUI
- Handtools
- Hud
- I3d
- Input
- Jobs
- Maps
- Materials
- Misc
- Objects
- Parameters
- Placeables
- Placement
- Player
- Shop
- Sounds
- Specialization
- Specializations
- AIConveyorBelt
- AIDrivable
- AIFieldWorker
- AIImplement
- AIJobVehicle
- AIVehicle
- AIVehicleObstacle
- AnimatedVehicle
- ArticulatedAxis
- Attachable
- AttacherJointControl
- AttacherJoints
- AutoLoader
- BaleGrab
- BaleLoader
- Baler
- BaleWrapper
- BaseMaterial
- BigBag
- BunkerSiloCompacter
- BunkerSiloInteractor
- CCTDrivable
- Combine
- ConnectionHoses
- ConveyorBelt
- Cover
- CrabSteering
- Crawlers
- CropSensor
- Cultivator
- Cutter
- Cylindered
- CylinderedFoldable
- Dashboard
- Dischargeable
- Drivable
- DynamicallyLoadedParts
- DynamicMountAttacher
- Enterable
- ExtendedAIVehicle
- ExtendedCombine
- ExtendedMotorized
- ExtendedMower
- ExtendedSowingMachine
- ExtendedSprayer
- ExtendedWearable
- FertilizingCultivator
- FertilizingSowingMachine
- FillTriggerVehicle
- FillUnit
- FillVolume
- Foldable
- FoliageBending
- ForageWagon
- FrontloaderAttacher
- FruitPreparer
- GroundAdjustedNodes
- GroundReference
- HeadlandAnimation
- Honk
- HookLiftContainer
- HookLiftTrailer
- IKChains
- InlineWrapper
- JigglingParts
- Leveler
- LicensePlates
- Lights
- LivestockTrailer
- Locomotive
- LogGrab
- ManureBarrel
- ManureSensor
- MixerWagon
- Motorized
- Mountable
- Mower
- Mulcher
- MultipleItemPurchase
- Pallet
- Pickup
- Pipe
- PlaceableAI
- PlaceableAnimatedObjects
- PlaceableBeehive
- PlaceableBeehivePalletSpa...
- PlaceableBunkerSilo
- PlaceableBuyingStation
- PlaceableCartridgePlayer
- PlaceableChargingStation
- PlaceableClearAreas
- PlaceableColorable
- PlaceableDeletedNodes
- PlaceableDoghouse
- PlaceableDynamicallyLoade...
- PlaceableFarmhouse
- PlaceableFence
- PlaceableFoliageAreas
- PlaceableGreenhouse
- PlaceableHighPressureWash...
- PlaceableHotspots
- PlaceableHusbandry
- PlaceableHusbandryAnimals
- PlaceableHusbandryFeeding...
- PlaceableHusbandryFence
- PlaceableHusbandryFood
- PlaceableHusbandryLiquidM...
- PlaceableHusbandryMilk
- PlaceableHusbandryPallets
- PlaceableHusbandryStraw
- PlaceableHusbandryWater
- PlaceableIncomePerHour
- PlaceableIndoorAreas
- PlaceableInfoTrigger
- PlaceableLeveling
- PlaceableLights
- PlaceableManureHeap
- PlaceablePlacement
- PlaceableProductionPoint
- PlaceableSellingStation
- PlaceableSilo
- PlaceableSiloExtension
- PlaceableSolarPanels
- PlaceableTipOcclusionArea...
- PlaceableTrainSystem
- PlaceableTriggerMarkers
- PlaceableVine
- PlaceableWardrobe
- PlaceableWeatherStation
- PlaceableWeighingStation
- PlaceableWindTurbine
- PlaceableWorkshop
- Plow
- PlowPacker
- PowerConsumer
- PowerTakeOffs
- PrecisionFarmingStatistic
- PushHandTool
- RandomlyMovingParts
- ReceivingHopper
- ReverseDriving
- Rideable
- RidgeMarker
- Roller
- Ropes
- RTKStation
- SaltSpreader
- SemiTrailerFront
- Shovel
- SlopeCompensation
- SmartAttach
- SoilSampler
- SowingMachine
- SpeedRotatingParts
- SplineVehicle
- Sprayer
- StonePicker
- StrawBlower
- StumpCutter
- SupportVehicle
- Suspensions
- Tedder
- TensionBeltObject
- TensionBelts
- TestAreas
- TipOccluder
- Trailer
- TreePlanter
- TreeSaplingPallet
- TreeSaw
- TurnOnVehicle
- VariableWorkWidth
- VehicleSettings
- VineCutter
- VineDetector
- VinePrepruner
- Washable
- WaterTrailer
- Wearable
- Weeder
- WeedSpotSpray
- Wheels
- WindBending
- Windrower
- Wipers
- WoodCrusher
- WoodHarvester
- WorkArea
- WorkMode
- WorkParticles
- StateMachine
- Statistics
- Tasks
- Triggers
- Utils
- Vehicles
Engine v1_7_1_0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- general
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- NoteNode
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- VoiceChat
- XML
Foundation Reference
PlaceableBunkerSilo
DescriptionSpecialization for placeablesFunctions
- canBeSold
- getHasOverlap
- getIsBunkerSiloExtendable
- getPlacementPosition
- getPlacementRotation
- loadFromXMLFile
- onDelete
- onFinalizePlacement
- onLoad
- onReadStream
- onSell
- onWriteStream
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
- registerSavegameXMLPaths
- registerXMLPaths
- saveToXMLFile
- setWallVisibility
- startPlacementCheck
- updateBunkerSiloWalls
canBeSold
DescriptionDefinitioncanBeSold()Code
218 | function PlaceableBunkerSilo:canBeSold(superFunc) |
219 | local spec = self.spec_bunkerSilo |
220 | |
221 | if spec.bunkerSilo.fillLevel > 0 then |
222 | return true, spec.sellWarningText |
223 | end |
224 | |
225 | return true, nil |
226 | end |
getHasOverlap
DescriptionDefinitiongetHasOverlap()Code
259 | function PlaceableBunkerSilo:getHasOverlap(superFunc, x, y, z, rotY, checkFunc) |
260 | |
261 | local spec = self.spec_bunkerSilo |
262 | local overwrittenCheckFunc = checkFunc |
263 | |
264 | if spec.foundSnappingSilo ~= nil then |
265 | overwrittenCheckFunc = function(hitObjectId) |
266 | local object = g_currentMission:getNodeObject(hitObjectId) |
267 | if object == spec.foundSnappingSilo then |
268 | return false |
269 | end |
270 | |
271 | if checkFunc ~= nil then |
272 | return checkFunc(hitObjectId) |
273 | end |
274 | |
275 | return hitObjectId ~= g_currentMission.terrainRootNode |
276 | end |
277 | end |
278 | |
279 | return superFunc(self, x, y, z, rotY, overwrittenCheckFunc) |
280 | end |
getIsBunkerSiloExtendable
DescriptionDefinitiongetIsBunkerSiloExtendable()Code
167 | function PlaceableBunkerSilo:getIsBunkerSiloExtendable() |
168 | local spec = self.spec_bunkerSilo |
169 | return spec.isExtendable |
170 | end |
getPlacementPosition
DescriptionDefinitiongetPlacementPosition()Code
298 | function PlaceableBunkerSilo:getPlacementPosition(superFunc, x, y, z) |
299 | x, y, z = superFunc(self, x, y, z) |
300 | |
301 | local spec = self.spec_bunkerSilo |
302 | if spec.foundSnappingSilo ~= nil then |
303 | x, y, z = localToWorld(spec.foundSnappingSilo.rootNode, spec.siloSiloDistance * spec.foundSnappingSiloSide, 0, 0) |
304 | end |
305 | |
306 | return x, y, z |
307 | end |
getPlacementRotation
DescriptionDefinitiongetPlacementRotation()Code
284 | function PlaceableBunkerSilo:getPlacementRotation(superFunc, x, y, z) |
285 | x, y, z = superFunc(self, x, y, z) |
286 | |
287 | local spec = self.spec_bunkerSilo |
288 | if spec.foundSnappingSilo ~= nil then |
289 | local dx, _, dz = localDirectionToWorld(spec.foundSnappingSilo.rootNode, 0, 0, 1) |
290 | x, y, z = 0, MathUtil.getYRotationFromDirection(dx, dz), 0 |
291 | end |
292 | |
293 | return x, y, z |
294 | end |
loadFromXMLFile
DescriptionDefinitionloadFromXMLFile()Code
142 | function PlaceableBunkerSilo:loadFromXMLFile(xmlFile, key) |
143 | local spec = self.spec_bunkerSilo |
144 | |
145 | if not spec.bunkerSilo:loadFromXMLFile(xmlFile, key) then |
146 | return false |
147 | end |
148 | end |
onDelete
DescriptionDefinitiononDelete()Code
98 | function PlaceableBunkerSilo:onDelete() |
99 | local spec = self.spec_bunkerSilo |
100 | |
101 | self:updateBunkerSiloWalls(true) |
102 | if spec.bunkerSilo ~= nil then |
103 | spec.bunkerSilo:delete() |
104 | end |
105 | g_currentMission.placeableSystem:removeBunkerSilo(self) |
106 | end |
onFinalizePlacement
DescriptionDefinitiononFinalizePlacement()Code
110 | function PlaceableBunkerSilo:onFinalizePlacement() |
111 | local spec = self.spec_bunkerSilo |
112 | local ownerFarmId = self:getOwnerFarmId() |
113 | |
114 | self:updateBunkerSiloWalls(false) |
115 | spec.bunkerSilo:register(true) |
116 | spec.bunkerSilo:setOwnerFarmId(ownerFarmId, true) |
117 | g_currentMission.placeableSystem:addBunkerSilo(self) |
118 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
74 | function PlaceableBunkerSilo:onLoad(savegame) |
75 | local spec = self.spec_bunkerSilo |
76 | |
77 | spec.bunkerSilo = BunkerSilo.new(self.isServer, self.isClient) |
78 | if not spec.bunkerSilo:load(self.components, self.xmlFile, "placeable.bunkerSilo", self.i3dMappings) then |
79 | spec.bunkerSilo:delete() |
80 | end |
81 | |
82 | spec.isExtendable = self.xmlFile:getValue("placeable.bunkerSilo#isExtendable", false) |
83 | if spec.isExtendable then |
84 | spec.siloSiloDistance = self.xmlFile:getValue("placeable.bunkerSilo#siloToSiloDistance") |
85 | if spec.siloSiloDistance == nil then |
86 | Logging.xmlError(self.xmlFile, "Bunker Silo is marked as extendable but 'placeable.bunkerSilo#siloToSiloDistance' is not set") |
87 | self:setLoadingState(Placeable.LOADING_STATE_ERROR) |
88 | return |
89 | end |
90 | spec.snapDistance = self.xmlFile:getValue("placeable.bunkerSilo#snapDistance") or spec.siloSiloDistance * 1.1 |
91 | end |
92 | |
93 | spec.sellWarningText = g_i18n:convertText(self.xmlFile:getValue("placeable.bunkerSilo#sellWarningText", "$l10n_info_bunkerSiloNotEmpty")) |
94 | end |
onReadStream
DescriptionDefinitiononReadStream()Code
122 | function PlaceableBunkerSilo:onReadStream(streamId, connection) |
123 | local spec = self.spec_bunkerSilo |
124 | |
125 | local bunkerSiloId = NetworkUtil.readNodeObjectId(streamId) |
126 | spec.bunkerSilo:readStream(streamId, connection) |
127 | g_client:finishRegisterObject(spec.bunkerSilo, bunkerSiloId) |
128 | end |
onSell
DescriptionDefinitiononSell()Code
210 | function PlaceableBunkerSilo:onSell() |
211 | local spec = self.spec_bunkerSilo |
212 | |
213 | spec.bunkerSilo:clearSiloArea() |
214 | end |
onWriteStream
DescriptionDefinitiononWriteStream()Code
132 | function PlaceableBunkerSilo:onWriteStream(streamId, connection) |
133 | local spec = self.spec_bunkerSilo |
134 | |
135 | NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(spec.bunkerSilo)) |
136 | spec.bunkerSilo:writeStream(streamId, connection) |
137 | g_server:registerObjectInStream(connection, spec.bunkerSilo) |
138 | end |
prerequisitesPresent
DescriptionChecks if all prerequisite specializations are loadedDefinition
prerequisitesPresent(table specializations)Arguments
table | specializations | specializations |
boolean | hasPrerequisite | true if all prerequisite specializations are loaded |
18 | function PlaceableBunkerSilo.prerequisitesPresent(specializations) |
19 | return true |
20 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
24 | function PlaceableBunkerSilo.registerEventListeners(placeableType) |
25 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableBunkerSilo) |
26 | SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableBunkerSilo) |
27 | SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", PlaceableBunkerSilo) |
28 | SpecializationUtil.registerEventListener(placeableType, "onReadStream", PlaceableBunkerSilo) |
29 | SpecializationUtil.registerEventListener(placeableType, "onWriteStream", PlaceableBunkerSilo) |
30 | SpecializationUtil.registerEventListener(placeableType, "onSell", PlaceableBunkerSilo) |
31 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
35 | function PlaceableBunkerSilo.registerFunctions(placeableType) |
36 | SpecializationUtil.registerFunction(placeableType, "updateBunkerSiloWalls", PlaceableBunkerSilo.updateBunkerSiloWalls) |
37 | SpecializationUtil.registerFunction(placeableType, "setWallVisibility", PlaceableBunkerSilo.setWallVisibility) |
38 | SpecializationUtil.registerFunction(placeableType, "getIsBunkerSiloExtendable", PlaceableBunkerSilo.getIsBunkerSiloExtendable) |
39 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
43 | function PlaceableBunkerSilo.registerOverwrittenFunctions(placeableType) |
44 | SpecializationUtil.registerOverwrittenFunction(placeableType, "getPlacementPosition", PlaceableBunkerSilo.getPlacementPosition) |
45 | SpecializationUtil.registerOverwrittenFunction(placeableType, "getPlacementRotation", PlaceableBunkerSilo.getPlacementRotation) |
46 | SpecializationUtil.registerOverwrittenFunction(placeableType, "getHasOverlap", PlaceableBunkerSilo.getHasOverlap) |
47 | SpecializationUtil.registerOverwrittenFunction(placeableType, "startPlacementCheck", PlaceableBunkerSilo.startPlacementCheck) |
48 | SpecializationUtil.registerOverwrittenFunction(placeableType, "canBeSold", PlaceableBunkerSilo.canBeSold) |
49 | end |
registerSavegameXMLPaths
DescriptionDefinitionregisterSavegameXMLPaths()Code
65 | function PlaceableBunkerSilo.registerSavegameXMLPaths(schema, basePath) |
66 | schema:setXMLSpecializationType("BunkerSilo") |
67 | BunkerSilo.registerSavegameXMLPaths(schema, basePath) |
68 | schema:setXMLSpecializationType() |
69 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
53 | function PlaceableBunkerSilo.registerXMLPaths(schema, basePath) |
54 | schema:setXMLSpecializationType("BunkerSilo") |
55 | BunkerSilo.registerXMLPaths(schema, basePath .. ".bunkerSilo") |
56 | schema:register(XMLValueType.BOOL, basePath .. ".bunkerSilo#isExtendable", "Checks if silo is extendable. If set 'siloToSiloDistance' needs to be provided as well", false) |
57 | schema:register(XMLValueType.FLOAT, basePath .. ".bunkerSilo#siloToSiloDistance", "Silo to silo distance required for aligning multiple silos of the same type next to each other") |
58 | schema:register(XMLValueType.FLOAT, basePath .. ".bunkerSilo#snapDistance", "Snap distance for building an array of the same silo", "siloToSiloDistance * 1.1") |
59 | schema:register(XMLValueType.STRING, basePath .. ".bunkerSilo#sellWarningText", "Sell warning text") |
60 | schema:setXMLSpecializationType() |
61 | end |
saveToXMLFile
DescriptionDefinitionsaveToXMLFile()Code
152 | function PlaceableBunkerSilo:saveToXMLFile(xmlFile, key, usedModNames) |
153 | local spec = self.spec_bunkerSilo |
154 | |
155 | spec.bunkerSilo:saveToXMLFile(xmlFile, key, usedModNames) |
156 | end |
setWallVisibility
DescriptionDefinitionsetWallVisibility()Code
160 | function PlaceableBunkerSilo:setWallVisibility(isLeftVisible, isRightVisible) |
161 | local spec = self.spec_bunkerSilo |
162 | spec.bunkerSilo:setWallVisibility(isLeftVisible, isRightVisible) |
163 | end |
startPlacementCheck
DescriptionDefinitionstartPlacementCheck()Code
230 | function PlaceableBunkerSilo:startPlacementCheck(superFunc, x, y, z, rotY) |
231 | local spec = self.spec_bunkerSilo |
232 | superFunc(self, x, y, z, rotY) |
233 | |
234 | if not spec.isExtendable then |
235 | return |
236 | end |
237 | |
238 | spec.foundSnappingSilo = nil |
239 | spec.foundSnappingSiloSide = 0 |
240 | local nearestDistance = spec.snapDistance |
241 | for _, placeable in ipairs(g_currentMission.placeableSystem:getBunkerSilos()) do |
242 | if placeable:getOwnerFarmId() == g_currentMission.player.farmId then |
243 | if placeable.configFileName == self.configFileName then |
244 | |
245 | local lx, _, lz = worldToLocal(placeable.rootNode, x, y, z) |
246 | local distance = MathUtil.vector2Length(lx, lz) |
247 | if distance < nearestDistance then |
248 | nearestDistance = distance |
249 | spec.foundSnappingSilo = placeable |
250 | spec.foundSnappingSiloSide = MathUtil.sign(lx) |
251 | end |
252 | end |
253 | end |
254 | end |
255 | end |
updateBunkerSiloWalls
DescriptionDefinitionupdateBunkerSiloWalls()Code
174 | function PlaceableBunkerSilo:updateBunkerSiloWalls(isDeleting) |
175 | local spec = self.spec_bunkerSilo |
176 | if self.rootNode ~= nil then |
177 | local x, y, z = getWorldTranslation(self.rootNode) |
178 | local placeableSystem = g_currentMission.placeableSystem |
179 | for _, placeable in ipairs(placeableSystem:getBunkerSilos()) do |
180 | if placeable:getIsBunkerSiloExtendable() and placeable ~= self and placeable:getOwnerFarmId() == self:getOwnerFarmId() then |
181 | if placeable.configFileName == self.configFileName then |
182 | local lx, _, lz = worldToLocal(placeable.rootNode, x, y, z) |
183 | local distance = MathUtil.vector2Length(lx, lz) |
184 | if distance < spec.siloSiloDistance + 0.5 then |
185 | local isLeft = lx > 0 |
186 | |
187 | if isDeleting then |
188 | -- always set walls visible |
189 | if isLeft then |
190 | placeable:setWallVisibility(true, nil) |
191 | else |
192 | placeable:setWallVisibility(nil, true) |
193 | end |
194 | else |
195 | if isLeft then |
196 | placeable:setWallVisibility(false, nil) |
197 | else |
198 | placeable:setWallVisibility(nil, false) |
199 | end |
200 | end |
201 | end |
202 | end |
203 | end |
204 | end |
205 | end |
206 | end |