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
PlaceableClearAreas
DescriptionSpecialization for placeablesFunctions
- loadClearArea
- onLoad
- onPostFinalizePlacement
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerXMLPaths
loadClearArea
DescriptionDefinitionloadClearArea()Code
66 | function PlaceableClearAreas:loadClearArea(xmlFile, key, area) |
67 | local start = xmlFile:getValue(key .. "#startNode", nil, self.components, self.i3dMappings) |
68 | if start == nil then |
69 | Logging.xmlWarning(xmlFile, "Clear area start node not defined for '%s'", key) |
70 | return false |
71 | end |
72 | |
73 | local width = xmlFile:getValue(key .. "#widthNode", nil, self.components, self.i3dMappings) |
74 | if width == nil then |
75 | Logging.xmlWarning(xmlFile, "Clear area width node not defined for '%s'", key) |
76 | return false |
77 | end |
78 | |
79 | local height = xmlFile:getValue(key .. "#heightNode", nil, self.components, self.i3dMappings) |
80 | if height == nil then |
81 | Logging.xmlWarning(xmlFile, "Clear area height node not defined for '%s'", key) |
82 | return false |
83 | end |
84 | |
85 | area.start = start |
86 | area.width = width |
87 | area.height = height |
88 | |
89 | return true |
90 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
48 | function PlaceableClearAreas:onLoad(savegame) |
49 | local spec = self.spec_clearAreas |
50 | |
51 | spec.areas = {} |
52 | self.xmlFile:iterate("placeable.clearAreas.clearArea", function(_, key) |
53 | local area = {} |
54 | if self:loadClearArea(self.xmlFile, key, area) then |
55 | table.insert(spec.areas, area) |
56 | end |
57 | end) |
58 | |
59 | if not self.xmlFile:hasProperty("placeable.clearAreas") then |
60 | Logging.xmlWarning(self.xmlFile, "Missing clear areas") |
61 | end |
62 | end |
onPostFinalizePlacement
DescriptionDefinitiononPostFinalizePlacement()Code
94 | function PlaceableClearAreas:onPostFinalizePlacement() |
95 | if self.isServer and not self.isLoadedFromSavegame then |
96 | local spec = self.spec_clearAreas |
97 | for _, area in pairs(spec.areas) do |
98 | local x,_,z = getWorldTranslation(area.start) |
99 | local x1,_,z1 = getWorldTranslation(area.width) |
100 | local x2,_,z2 = getWorldTranslation(area.height) |
101 | -- clear foliage |
102 | FSDensityMapUtil.removeFieldArea(x, z, x1, z1, x2, z2, false) |
103 | FSDensityMapUtil.removeWeedArea(x, z, x1, z1, x2, z2) |
104 | FSDensityMapUtil.removeStoneArea(x, z, x1, z1, x2, z2) |
105 | FSDensityMapUtil.eraseTireTrack(x, z, x1, z1, x2, z2) |
106 | FSDensityMapUtil.clearDecoArea(x, z, x1, z1, x2, z2) |
107 | -- clear tipAny |
108 | DensityMapHeightUtil.clearArea(x, z, x1, z1, x2, z2) |
109 | end |
110 | end |
111 | 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 PlaceableClearAreas.prerequisitesPresent(specializations) |
19 | return true |
20 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
30 | function PlaceableClearAreas.registerEventListeners(placeableType) |
31 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableClearAreas) |
32 | SpecializationUtil.registerEventListener(placeableType, "onPostFinalizePlacement", PlaceableClearAreas) |
33 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
24 | function PlaceableClearAreas.registerFunctions(placeableType) |
25 | SpecializationUtil.registerFunction(placeableType, "loadClearArea", PlaceableClearAreas.loadClearArea) |
26 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
37 | function PlaceableClearAreas.registerXMLPaths(schema, basePath) |
38 | schema:setXMLSpecializationType("ClearAreas") |
39 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".clearAreas.clearArea(?)#startNode", "Start node") |
40 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".clearAreas.clearArea(?)#widthNode", "Width node") |
41 | schema:register(XMLValueType.NODE_INDEX, basePath .. ".clearAreas.clearArea(?)#heightNode", "Height node") |
42 | schema:setXMLSpecializationType() |
43 | end |