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
PlaceableHusbandryFeedingRobot
DescriptionSpecialization for placeablesFunctions
- collectPickObjects
- loadFromXMLFile
- onDelete
- onFeedingRobotLoaded
- onFinalizePlacement
- onLoad
- onPostLoad
- onReadStream
- onWriteStream
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
- registerSavegameXMLPaths
- registerXMLPaths
- saveToXMLFile
- setOwnerFarmId
- updateFeeding
- updateInfo
collectPickObjects
DescriptionDefinitioncollectPickObjects()Code
264 | function PlaceableHusbandryFeedingRobot:collectPickObjects(superFunc, node) |
265 | local spec = self.spec_husbandryFeedingRobot |
266 | if spec.feedingRobot ~= nil then |
267 | if spec.feedingRobot:getIsNodeUsed(node) then |
268 | return |
269 | end |
270 | end |
271 | |
272 | superFunc(self, node) |
273 | end |
loadFromXMLFile
DescriptionDefinitionloadFromXMLFile()Code
222 | function PlaceableHusbandryFeedingRobot:loadFromXMLFile(xmlFile, key) |
223 | local spec = self.spec_husbandryFeedingRobot |
224 | if spec.feedingRobot ~= nil then |
225 | spec.feedingRobot:loadFromXMLFile(xmlFile, key) |
226 | end |
227 | end |
onDelete
DescriptionDefinitiononDelete()Code
182 | function PlaceableHusbandryFeedingRobot:onDelete() |
183 | local spec = self.spec_husbandryFeedingRobot |
184 | if spec.feedingRobot ~= nil then |
185 | spec.feedingRobot:delete() |
186 | end |
187 | end |
onFeedingRobotLoaded
DescriptionDefinitiononFeedingRobotLoaded()Code
176 | function PlaceableHusbandryFeedingRobot:onFeedingRobotLoaded(robot, args) |
177 | self:finishLoadingTask(args.loadingTask) |
178 | end |
onFinalizePlacement
DescriptionDefinitiononFinalizePlacement()Code
191 | function PlaceableHusbandryFeedingRobot:onFinalizePlacement() |
192 | local spec = self.spec_husbandryFeedingRobot |
193 | if spec.feedingRobot ~= nil then |
194 | spec.feedingRobot:finalizePlacement() |
195 | end |
196 | end |
onLoad
DescriptionDefinitiononLoad()Code
83 | function PlaceableHusbandryFeedingRobot:onLoad(savegame) |
84 | local spec = self.spec_husbandryFeedingRobot |
85 | |
86 | if not self.xmlFile:hasProperty("placeable.husbandry.feedingRobot") then |
87 | return |
88 | end |
89 | |
90 | local filename = self.xmlFile:getValue("placeable.husbandry.feedingRobot#filename") |
91 | if filename == nil then |
92 | Logging.xmlError(self.xmlFile, "Feedingrobot filename missing") |
93 | self:setLoadingState(Placeable.LOADING_STATE_ERROR) |
94 | return |
95 | end |
96 | |
97 | filename = Utils.getFilename(filename, self.baseDirectory) |
98 | |
99 | local className = self.xmlFile:getValue("placeable.husbandry.feedingRobot#class", "") |
100 | local class = ClassUtil.getClassObject(className) |
101 | if class == nil then |
102 | Logging.xmlError(self.xmlFile, "Feedingrobot class '%s' not defined", className) |
103 | self:setLoadingState(Placeable.LOADING_STATE_ERROR) |
104 | return |
105 | end |
106 | |
107 | local linkNode = self.xmlFile:getValue("placeable.husbandry.feedingRobot#linkNode", nil, self.components, self.i3dMappings) |
108 | if linkNode == nil then |
109 | Logging.xmlError(self.xmlFile, "Feedingrobot linkNode not defined") |
110 | self:setLoadingState(Placeable.LOADING_STATE_ERROR) |
111 | return |
112 | end |
113 | |
114 | local loadingTask = self:createLoadingTask(self) |
115 | spec.feedingRobot = class.new(self.isServer, self.isClient, self, self.baseDirectory) |
116 | spec.feedingRobot:load(linkNode, filename, self.onFeedingRobotLoaded, self, {loadingTask=loadingTask}) |
117 | spec.feedingRobot:register(true) |
118 | |
119 | self.xmlFile:iterate("placeable.husbandry.feedingRobot.splines.spline", function(_, splineKey) |
120 | local spline = self.xmlFile:getValue(splineKey .. "#node", nil, self.components, self.i3dMappings) |
121 | if spline == nil then |
122 | Logging.xmlWarning(self.xmlFile, "Feedingrobot spline not defined for '%s'", splineKey) |
123 | return false |
124 | end |
125 | if not getHasClassId(getGeometry(spline), ClassIds.SPLINE) then |
126 | Logging.xmlWarning(self.xmlFile, "Given node is not a spline for '%s'", splineKey) |
127 | return false |
128 | end |
129 | local direction = self.xmlFile:getValue(splineKey .. "#direction", 1) |
130 | local isFeeding = self.xmlFile:getValue(splineKey .. "#isFeeding", false) |
131 | |
132 | spec.feedingRobot:addSpline(spline, direction, isFeeding) |
133 | end) |
134 | |
135 | spec.dependedAnimatedObjects = {} |
136 | self.xmlFile:iterate("placeable.husbandry.feedingRobot.animatedObjects.animatedObject", function(index, animationObjectKey) |
137 | local animatedObjectIndex = self.xmlFile:getInt(animationObjectKey.."#index") |
138 | local direction = self.xmlFile:getInt(animationObjectKey.."#direction", 1) |
139 | |
140 | table.insert(spec.dependedAnimatedObjects, {animatedObjectIndex=animatedObjectIndex, direction=direction}) |
141 | end) |
142 | end |
onPostLoad
DescriptionDefinitiononPostLoad()Code
146 | function PlaceableHusbandryFeedingRobot:onPostLoad(savegame) |
147 | local spec = self.spec_husbandryFeedingRobot |
148 | if spec.dependedAnimatedObjects ~= nil and self.spec_animatedObjects ~= nil then |
149 | local animatedObjects = self.spec_animatedObjects.animatedObjects |
150 | |
151 | for _, data in ipairs(spec.dependedAnimatedObjects) do |
152 | local animatedObject = animatedObjects[data.animatedObjectIndex] |
153 | if animatedObject ~= nil then |
154 | animatedObject.getCanBeTriggered = Utils.overwrittenFunction(animatedObject.getCanBeTriggered, function(_, superFunc) |
155 | if not superFunc(animatedObject) then |
156 | return false |
157 | end |
158 | |
159 | return not spec.feedingRobot:getIsDriving() |
160 | end) |
161 | |
162 | spec.feedingRobot:addStateChangedListener(function(state) |
163 | if spec.feedingRobot:getIsDriving() then |
164 | if animatedObject.animation.direction ~= data.direction then |
165 | animatedObject:setDirection(data.direction) |
166 | end |
167 | end |
168 | end) |
169 | end |
170 | end |
171 | end |
172 | end |
onReadStream
DescriptionDefinitiononReadStream()Code
200 | function PlaceableHusbandryFeedingRobot:onReadStream(streamId, connection) |
201 | local spec = self.spec_husbandryFeedingRobot |
202 | if spec.feedingRobot ~= nil then |
203 | local feedingRobotId = NetworkUtil.readNodeObjectId(streamId) |
204 | spec.feedingRobot:readStream(streamId, connection) |
205 | g_client:finishRegisterObject(spec.feedingRobot, feedingRobotId) |
206 | end |
207 | end |
onWriteStream
DescriptionDefinitiononWriteStream()Code
211 | function PlaceableHusbandryFeedingRobot:onWriteStream(streamId, connection) |
212 | local spec = self.spec_husbandryFeedingRobot |
213 | if spec.feedingRobot ~= nil then |
214 | NetworkUtil.writeNodeObjectId(streamId, NetworkUtil.getObjectId(spec.feedingRobot)) |
215 | spec.feedingRobot:writeStream(streamId, connection) |
216 | g_server:registerObjectInStream(connection, spec.feedingRobot) |
217 | end |
218 | 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 |
27 | function PlaceableHusbandryFeedingRobot.prerequisitesPresent(specializations) |
28 | return SpecializationUtil.hasSpecialization(PlaceableHusbandryFood, specializations) |
29 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
48 | function PlaceableHusbandryFeedingRobot.registerEventListeners(placeableType) |
49 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableHusbandryFeedingRobot) |
50 | SpecializationUtil.registerEventListener(placeableType, "onPostLoad", PlaceableHusbandryFeedingRobot) |
51 | SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableHusbandryFeedingRobot) |
52 | SpecializationUtil.registerEventListener(placeableType, "onFinalizePlacement", PlaceableHusbandryFeedingRobot) |
53 | SpecializationUtil.registerEventListener(placeableType, "onReadStream", PlaceableHusbandryFeedingRobot) |
54 | SpecializationUtil.registerEventListener(placeableType, "onWriteStream", PlaceableHusbandryFeedingRobot) |
55 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
33 | function PlaceableHusbandryFeedingRobot.registerFunctions(placeableType) |
34 | SpecializationUtil.registerFunction(placeableType, "onFeedingRobotLoaded", PlaceableHusbandryFeedingRobot.onFeedingRobotLoaded) |
35 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
39 | function PlaceableHusbandryFeedingRobot.registerOverwrittenFunctions(placeableType) |
40 | SpecializationUtil.registerOverwrittenFunction(placeableType, "setOwnerFarmId", PlaceableHusbandryFeedingRobot.setOwnerFarmId) |
41 | SpecializationUtil.registerOverwrittenFunction(placeableType, "updateFeeding", PlaceableHusbandryFeedingRobot.updateFeeding) |
42 | SpecializationUtil.registerOverwrittenFunction(placeableType, "collectPickObjects", PlaceableHusbandryFeedingRobot.collectPickObjects) |
43 | SpecializationUtil.registerOverwrittenFunction(placeableType, "updateInfo", PlaceableHusbandryFeedingRobot.updateInfo) |
44 | end |
registerSavegameXMLPaths
DescriptionDefinitionregisterSavegameXMLPaths()Code
75 | function PlaceableHusbandryFeedingRobot.registerSavegameXMLPaths(schema, basePath) |
76 | schema:setXMLSpecializationType("Husbandry") |
77 | FeedingRobot.registerSavegameXMLPaths(schema, basePath) |
78 | schema:setXMLSpecializationType() |
79 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
59 | function PlaceableHusbandryFeedingRobot.registerXMLPaths(schema, basePath) |
60 | schema:setXMLSpecializationType("Husbandry") |
61 | basePath = basePath .. ".husbandry.feedingRobot" |
62 | schema:register(XMLValueType.NODE_INDEX, basePath .. "#linkNode", "Feedingrobot link node") |
63 | schema:register(XMLValueType.STRING, basePath .. "#class", "Feedingrobot class name") |
64 | schema:register(XMLValueType.STRING, basePath .. "#filename", "Feedingrobot config file") |
65 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".splines.spline(?)#node", "Feedingrobot spline") |
66 | schema:register(XMLValueType.INT, basePath .. ".splines.spline(?)#direction", "Feedingrobot spline direction") |
67 | schema:register(XMLValueType.BOOL, basePath .. ".splines.spline(?)#isFeeding", "Feedingrobot spline feeding part") |
68 | schema:register(XMLValueType.INT, basePath .. ".animatedObjects.animatedObject(?)#index", "Dependend animated object index") |
69 | schema:register(XMLValueType.INT, basePath .. ".animatedObjects.animatedObject(?)#direction", "Dependend animated object direction") |
70 | schema:setXMLSpecializationType() |
71 | end |
saveToXMLFile
DescriptionDefinitionsaveToXMLFile()Code
231 | function PlaceableHusbandryFeedingRobot:saveToXMLFile(xmlFile, key, usedModNames) |
232 | local spec = self.spec_husbandryFeedingRobot |
233 | if spec.feedingRobot ~= nil then |
234 | spec.feedingRobot:saveToXMLFile(xmlFile, key, usedModNames) |
235 | end |
236 | end |
setOwnerFarmId
DescriptionDefinitionsetOwnerFarmId()Code
240 | function PlaceableHusbandryFeedingRobot:setOwnerFarmId(superFunc, farmId) |
241 | superFunc(self, farmId) |
242 | |
243 | local spec = self.spec_husbandryFeedingRobot |
244 | if spec.feedingRobot ~= nil then |
245 | spec.feedingRobot:setOwnerFarmId(farmId, true) |
246 | end |
247 | end |
updateFeeding
DescriptionDefinitionupdateFeeding()Code
251 | function PlaceableHusbandryFeedingRobot:updateFeeding(superFunc) |
252 | local spec = self.spec_husbandryFeedingRobot |
253 | if self.isServer then |
254 | if spec.feedingRobot ~= nil then |
255 | spec.feedingRobot:createFoodMixture() |
256 | end |
257 | end |
258 | |
259 | return superFunc(self) |
260 | end |
updateInfo
DescriptionDefinitionupdateInfo()Code
277 | function PlaceableHusbandryFeedingRobot:updateInfo(superFunc, infoTable) |
278 | superFunc(self, infoTable) |
279 | |
280 | local spec = self.spec_husbandryFeedingRobot |
281 | |
282 | if spec.feedingRobot ~= nil then |
283 | spec.feedingRobot:updateInfo(infoTable) |
284 | end |
285 | end |