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
PlaceableBeehivePalletSpawner
DescriptionSpecialization for placeablesFunctions
- addFillLevel
- canBuy
- getPalletCallback
- loadFromXMLFile
- onDelete
- onFinalizePlacement
- onLoad
- onReadStream
- onReadUpdateStream
- onWriteStream
- onWriteUpdateStream
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
- registerSavegameXMLPaths
- registerXMLPaths
- saveToXMLFile
- updateInfo
- updatePallets
addFillLevel
DescriptionDefinitionaddFillLevel()Code
161 | function PlaceableBeehivePalletSpawner:addFillLevel(fillLevel) |
162 | if self.isServer then |
163 | local spec = self.spec_beehivePalletSpawner |
164 | |
165 | if fillLevel ~= nil then |
166 | spec.pendingLiters = spec.pendingLiters + fillLevel |
167 | end |
168 | end |
169 | end |
canBuy
DescriptionDefinitioncanBuy()Code
225 | function PlaceableBeehivePalletSpawner:canBuy(superFunc) |
226 | local canBuy, warning = superFunc(self) |
227 | if not canBuy then |
228 | return false, warning |
229 | end |
230 | |
231 | if g_currentMission.beehiveSystem:getFarmBeehivePalletSpawner(g_currentMission.player.farmId) ~= nil then |
232 | return false, g_i18n:getText("warning_onlyOneOfThisItemAllowedPerFarm") |
233 | end |
234 | |
235 | return true, nil |
236 | end |
getPalletCallback
DescriptionDefinitiongetPalletCallback()Code
186 | function PlaceableBeehivePalletSpawner:getPalletCallback(pallet, result, fillTypeIndex) |
187 | local spec = self.spec_beehivePalletSpawner |
188 | spec.spawnPending = false |
189 | |
190 | if pallet ~= nil then |
191 | if result == PalletSpawner.RESULT_SUCCESS then |
192 | if spec.palletLimitReached then |
193 | spec.palletLimitReached = false |
194 | self:raiseDirtyFlags(spec.dirtyFlag) |
195 | end |
196 | pallet:emptyAllFillUnits(true) |
197 | end |
198 | |
199 | local delta = pallet:addFillUnitFillLevel(self:getOwnerFarmId(), 1, spec.pendingLiters, fillTypeIndex, ToolType.UNDEFINED) |
200 | |
201 | spec.pendingLiters = math.max(spec.pendingLiters - delta, 0) |
202 | |
203 | elseif result == PalletSpawner.RESULT_NO_SPACE then |
204 | -- TODO: add cooldown or "pallet removed" callback to prevent overlap boxes in every frame |
205 | elseif result == PalletSpawner.PALLET_LIMITED_REACHED then |
206 | if not spec.palletLimitReached then |
207 | spec.palletLimitReached = true |
208 | self:raiseDirtyFlags(spec.dirtyFlag) |
209 | end |
210 | end |
211 | end |
loadFromXMLFile
DescriptionDefinitionloadFromXMLFile()Code
142 | function PlaceableBeehivePalletSpawner:loadFromXMLFile(xmlFile, key) |
143 | local spec = self.spec_beehivePalletSpawner |
144 | |
145 | spec.pendingLiters = xmlFile:getValue(key..".beehivePalletSpawner#pendingLiters") or spec.pendingLiters |
146 | end |
onDelete
DescriptionDefinitiononDelete()Code
88 | function PlaceableBeehivePalletSpawner:onDelete() |
89 | local spec = self.spec_beehivePalletSpawner |
90 | if spec.palletSpawner ~= nil then |
91 | spec.palletSpawner:delete() |
92 | end |
93 | g_currentMission.beehiveSystem:removeBeehivePalletSpawner(self) |
94 | end |
onFinalizePlacement
DescriptionDefinitiononFinalizePlacement()Code
98 | function PlaceableBeehivePalletSpawner:onFinalizePlacement() |
99 | g_currentMission.beehiveSystem:addBeehivePalletSpawner(self) |
100 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
65 | function PlaceableBeehivePalletSpawner:onLoad(savegame) |
66 | local spec = self.spec_beehivePalletSpawner |
67 | local xmlFile = self.xmlFile |
68 | |
69 | local palletSpawnerKey = "placeable.beehivePalletSpawner" |
70 | spec.palletSpawner = PalletSpawner.new(self.baseDirectory) |
71 | if not spec.palletSpawner:load(self.components, xmlFile, palletSpawnerKey, self.customEnvironment, self.i3dMappings) then |
72 | Logging.xmlError(xmlFile, "Unable to load pallet spawner %s", palletSpawnerKey) |
73 | self:setLoadingState(Placeable.LOADING_STATE_ERROR) |
74 | return |
75 | end |
76 | |
77 | spec.pendingLiters = 0 |
78 | spec.spawnPending = false |
79 | spec.palletLimitReached = false |
80 | spec.infoHudTooManyPallets = {title=g_i18n:getText("infohud_tooManyPallets")} |
81 | spec.fillType = g_fillTypeManager:getFillTypeIndexByName("HONEY") |
82 | |
83 | spec.dirtyFlag = self:getNextDirtyFlag() |
84 | end |
onReadStream
DescriptionDefinitiononReadStream()Code
104 | function PlaceableBeehivePalletSpawner:onReadStream(streamId, connection) |
105 | if connection:getIsServer() then |
106 | local spec = self.spec_beehivePalletSpawner |
107 | spec.palletLimitReached = streamReadBool(streamId) |
108 | end |
109 | end |
onReadUpdateStream
DescriptionDefinitiononReadUpdateStream()Code
123 | function PlaceableBeehivePalletSpawner:onReadUpdateStream(streamId, timestamp, connection) |
124 | if connection:getIsServer() then |
125 | local spec = self.spec_beehivePalletSpawner |
126 | spec.palletLimitReached = streamReadBool(streamId) |
127 | end |
128 | end |
onWriteStream
DescriptionDefinitiononWriteStream()Code
113 | function PlaceableBeehivePalletSpawner:onWriteStream(streamId, connection) |
114 | if not connection:getIsServer() then |
115 | local spec = self.spec_beehivePalletSpawner |
116 | streamWriteBool(streamId, spec.palletLimitReached) |
117 | end |
118 | end |
onWriteUpdateStream
DescriptionDefinitiononWriteUpdateStream()Code
132 | function PlaceableBeehivePalletSpawner:onWriteUpdateStream(streamId, connection, dirtyMask) |
133 | if not connection:getIsServer() then |
134 | local spec = self.spec_beehivePalletSpawner |
135 | streamWriteBool(streamId, spec.palletLimitReached) |
136 | end |
137 | 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 |
17 | function PlaceableBeehivePalletSpawner.prerequisitesPresent(specializations) |
18 | return true |
19 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
38 | function PlaceableBeehivePalletSpawner.registerEventListeners(placeableType) |
39 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableBeehivePalletSpawner) |
40 | SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableBeehivePalletSpawner) |
41 | SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", PlaceableBeehivePalletSpawner) |
42 | SpecializationUtil.registerEventListener(placeableType, "onReadStream", PlaceableBeehivePalletSpawner) |
43 | SpecializationUtil.registerEventListener(placeableType, "onWriteStream", PlaceableBeehivePalletSpawner) |
44 | SpecializationUtil.registerEventListener(placeableType, "onReadUpdateStream", PlaceableBeehivePalletSpawner) |
45 | SpecializationUtil.registerEventListener(placeableType, "onWriteUpdateStream", PlaceableBeehivePalletSpawner) |
46 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
23 | function PlaceableBeehivePalletSpawner.registerFunctions(placeableType) |
24 | SpecializationUtil.registerFunction(placeableType, "addFillLevel", PlaceableBeehivePalletSpawner.addFillLevel) |
25 | SpecializationUtil.registerFunction(placeableType, "updatePallets", PlaceableBeehivePalletSpawner.updatePallets) |
26 | SpecializationUtil.registerFunction(placeableType, "getPalletCallback", PlaceableBeehivePalletSpawner.getPalletCallback) |
27 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
31 | function PlaceableBeehivePalletSpawner.registerOverwrittenFunctions(placeableType) |
32 | SpecializationUtil.registerOverwrittenFunction(placeableType, "canBuy", PlaceableBeehivePalletSpawner.canBuy) |
33 | SpecializationUtil.registerOverwrittenFunction(placeableType, "updateInfo", PlaceableBeehivePalletSpawner.updateInfo) |
34 | end |
registerSavegameXMLPaths
DescriptionDefinitionregisterSavegameXMLPaths()Code
58 | function PlaceableBeehivePalletSpawner.registerSavegameXMLPaths(schema, basePath) |
59 | schema:register(XMLValueType.FLOAT, basePath .. ".beehivePalletSpawner#pendingLiters", "Pending liters to be spawned") |
60 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
50 | function PlaceableBeehivePalletSpawner.registerXMLPaths(schema, basePath) |
51 | schema:setXMLSpecializationType("BeehivePalletSpawner") |
52 | PalletSpawner.registerXMLPaths(schema, basePath .. ".beehivePalletSpawner") |
53 | schema:setXMLSpecializationType() |
54 | end |
saveToXMLFile
DescriptionDefinitionsaveToXMLFile()Code
150 | function PlaceableBeehivePalletSpawner:saveToXMLFile(xmlFile, key, usedModNames) |
151 | local spec = self.spec_beehivePalletSpawner |
152 | |
153 | if spec.pendingLiters > 0 then |
154 | xmlFile:setValue(key..".beehivePalletSpawner#pendingLiters", spec.pendingLiters) |
155 | end |
156 | end |
updateInfo
DescriptionDefinitionupdateInfo()Code
215 | function PlaceableBeehivePalletSpawner:updateInfo(superFunc, infoTable) |
216 | superFunc(self, infoTable) |
217 | local spec = self.spec_beehivePalletSpawner |
218 | if spec.palletLimitReached then |
219 | table.insert(infoTable, spec.infoHudTooManyPallets) |
220 | end |
221 | end |
updatePallets
DescriptionDefinitionupdatePallets()Code
173 | function PlaceableBeehivePalletSpawner:updatePallets() |
174 | if self.isServer then |
175 | local spec = self.spec_beehivePalletSpawner |
176 | |
177 | if not spec.spawnPending and spec.pendingLiters > 10 then |
178 | spec.spawnPending = true |
179 | spec.palletSpawner:getOrSpawnPallet(self:getOwnerFarmId(), spec.fillType, self.getPalletCallback, self) |
180 | end |
181 | end |
182 | end |