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
PlaceableFoliageAreas
DescriptionSpecialization for placeablesFunctions
- loadFoliageArea
- onLoad
- onPostFinalizePlacement
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerXMLPaths
loadFoliageArea
DescriptionDefinitionloadFoliageArea()Code
65 | function PlaceableFoliageAreas:loadFoliageArea(xmlFile, key, area) |
66 | local fruitTypeName = xmlFile:getValue(key .. "#fruitType") |
67 | local decoFoliage = xmlFile:getValue(key .. "#decoFoliage") |
68 | |
69 | if fruitTypeName ~= nil and decoFoliage ~= nil then |
70 | Logging.xmlInfo(xmlFile, "Foliage area fruit type and decoFoliage defined defined for '%s'. Ignoring decoFoliage", fruitTypeName, key) |
71 | decoFoliage = nil |
72 | end |
73 | |
74 | local fruitType |
75 | local fruitState |
76 | if fruitTypeName ~= nil then |
77 | fruitType = g_fruitTypeManager:getFruitTypeByName(fruitTypeName) |
78 | if fruitType == nil then |
79 | Logging.xmlWarning(xmlFile, "Foliage area fruit type '%s' not defined for '%s'", fruitTypeName, key) |
80 | return false |
81 | end |
82 | |
83 | fruitState = xmlFile:getValue(key .. "#state", fruitType.maxHarvestingGrowthState - 1) |
84 | end |
85 | |
86 | if decoFoliage ~= nil then |
87 | if not g_currentMission.foliageSystem:getIsDecoLayerDefined(decoFoliage) then |
88 | Logging.xmlInfo(xmlFile, "Foliage area decoFoliage '%s' not defined on current map for '%s'", decoFoliage, key) |
89 | return false |
90 | end |
91 | end |
92 | |
93 | local start = xmlFile:getValue(key .. "#startNode", nil, self.components, self.i3dMappings) |
94 | if start == nil then |
95 | Logging.xmlWarning(xmlFile, "Foliage area start node not defined for '%s'", key) |
96 | return false |
97 | end |
98 | |
99 | local width = xmlFile:getValue(key .. "#widthNode", nil, self.components, self.i3dMappings) |
100 | if width == nil then |
101 | Logging.xmlWarning(xmlFile, "Foliage area width node not defined for '%s'", key) |
102 | return false |
103 | end |
104 | |
105 | local height = xmlFile:getValue(key .. "#heightNode", nil, self.components, self.i3dMappings) |
106 | if height == nil then |
107 | Logging.xmlWarning(xmlFile, "Foliage area height node not defined for '%s'", key) |
108 | return false |
109 | end |
110 | |
111 | area.start = start |
112 | area.width = width |
113 | area.height = height |
114 | area.fruitState = fruitState |
115 | area.fruitType = fruitType |
116 | area.decoFoliage = decoFoliage |
117 | |
118 | return true |
119 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
51 | function PlaceableFoliageAreas:onLoad(savegame) |
52 | local spec = self.spec_foliageAreas |
53 | |
54 | spec.areas = {} |
55 | self.xmlFile:iterate("placeable.foliageAreas.foliageArea", function(_, key) |
56 | local area = {} |
57 | if self:loadFoliageArea(self.xmlFile, key, area) then |
58 | table.insert(spec.areas, area) |
59 | end |
60 | end) |
61 | end |
onPostFinalizePlacement
DescriptionDefinitiononPostFinalizePlacement()Code
123 | function PlaceableFoliageAreas:onPostFinalizePlacement() |
124 | if self.isServer then |
125 | local spec = self.spec_foliageAreas |
126 | |
127 | for _, area in pairs(spec.areas) do |
128 | local x, _, z = getWorldTranslation(area.start) |
129 | local xWidth, _, zWidth = getWorldTranslation(area.width) |
130 | local xHeight, _, zHeight = getWorldTranslation(area.height) |
131 | |
132 | if area.fruitType ~= nil then |
133 | FieldUtil.setFruit(x, z, xWidth, zWidth, xHeight, zHeight, area.fruitType.index, area.fruitState) |
134 | else |
135 | g_currentMission.foliageSystem:applyDecoFoliage(area.decoFoliage, x, z, xWidth, zWidth, xHeight, zHeight) |
136 | end |
137 | end |
138 | end |
139 | 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 PlaceableFoliageAreas.prerequisitesPresent(specializations) |
19 | return true |
20 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
30 | function PlaceableFoliageAreas.registerEventListeners(placeableType) |
31 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableFoliageAreas) |
32 | SpecializationUtil.registerEventListener(placeableType, "onPostFinalizePlacement", PlaceableFoliageAreas) |
33 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
24 | function PlaceableFoliageAreas.registerFunctions(placeableType) |
25 | SpecializationUtil.registerFunction(placeableType, "loadFoliageArea", PlaceableFoliageAreas.loadFoliageArea) |
26 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
37 | function PlaceableFoliageAreas.registerXMLPaths(schema, basePath) |
38 | schema:setXMLSpecializationType("FoliageAreas") |
39 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".foliageAreas.foliageArea(?)#startNode", "Start node") |
40 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".foliageAreas.foliageArea(?)#widthNode", "Width node") |
41 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".foliageAreas.foliageArea(?)#heightNode", "Height node") |
42 | schema:register(XMLValueType.STRING, basePath .. ".foliageAreas.foliageArea(?)#fruitType", "Fruit type name") |
43 | schema:register(XMLValueType.STRING, basePath .. ".foliageAreas.foliageArea(?)#decoFoliage", "Deco foliage name") |
44 | schema:register(XMLValueType.INT, basePath .. ".foliageAreas.foliageArea(?)#state", "Fruit type state") |
45 | schema:setXMLSpecializationType() |
46 | end |