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
TipOccluder
DescriptionSpecialization allowing vehicles to prevent tipping filltypes in specified areas (e.g. below wheels)Functions
- finalizeWheel
- getRequiresTipOcclusionArea
- getTipOcclusionAreas
- getWheelsWithTipOcclisionAreaGroupId
- initSpecialization
- onLoad
- onPostLoad
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
finalizeWheel
DescriptionDefinitionfinalizeWheel()Code
118 | function TipOccluder:finalizeWheel(superFunc, wheel, parentWheel) |
119 | superFunc(self, wheel, parentWheel) |
120 | |
121 | local spec = self.spec_tipOccluder |
122 | if wheel.tipOcclusionAreaGroupId ~= nil then |
123 | local vehicleRootNode = self.components[1].node |
124 | local doCreate = true |
125 | local area |
126 | for groupId, occluderArea in pairs(spec.createdTipOcclusionAreaGroupIds) do |
127 | if groupId == wheel.tipOcclusionAreaGroupId then |
128 | doCreate = false |
129 | area = occluderArea |
130 | break |
131 | end |
132 | end |
133 | |
134 | -- the first wheel with the group id creates the area, the other just recalculate the area |
135 | if doCreate then |
136 | local start = createTransformGroup(string.format("tipOcclusionAreaGroupId%d", wheel.tipOcclusionAreaGroupId)) |
137 | local width = createTransformGroup(string.format("tipOcclusionAreaGroupId%d", wheel.tipOcclusionAreaGroupId)) |
138 | local height = createTransformGroup(string.format("tipOcclusionAreaGroupId%d", wheel.tipOcclusionAreaGroupId)) |
139 | link(vehicleRootNode, start) |
140 | link(vehicleRootNode, width) |
141 | link(vehicleRootNode, height) |
142 | |
143 | area = {start=start, width=width, height=height} |
144 | table.insert(spec.tipOcclusionAreas, area) |
145 | spec.createdTipOcclusionAreaGroupIds[wheel.tipOcclusionAreaGroupId] = area |
146 | end |
147 | |
148 | if area ~= nil then |
149 | local xMax = -math.huge |
150 | local xMin = math.huge |
151 | local zMax = -math.huge |
152 | local zMin = math.huge |
153 | |
154 | -- get other wheels with the same area group id |
155 | local usedWheels = self:getWheelsWithTipOcclisionAreaGroupId(self:getWheels(), wheel.tipOcclusionAreaGroupId) |
156 | |
157 | -- also include myself into the calculation |
158 | table.insert(usedWheels, wheel) |
159 | |
160 | local rootNodeToUse = usedWheels[#usedWheels].node |
161 | |
162 | link(rootNodeToUse, area.start) |
163 | link(rootNodeToUse, area.width) |
164 | link(rootNodeToUse, area.height) |
165 | |
166 | for _,usedWheel in pairs(usedWheels) do |
167 | local x,_,z = localToLocal(usedWheel.driveNode, rootNodeToUse, usedWheel.wheelShapeWidth - 0.5 * usedWheel.width, 0, -usedWheel.radius) |
168 | xMax = math.max(x, xMax) |
169 | zMin = math.min(z, zMin) |
170 | x,_,z = localToLocal(usedWheel.driveNode, rootNodeToUse, -usedWheel.wheelShapeWidth + 0.5 * usedWheel.width, 0, usedWheel.radius) |
171 | xMin = math.min(x, xMin) |
172 | zMax = math.max(z, zMax) |
173 | end |
174 | |
175 | |
176 | setTranslation(area.start, xMax,0,zMin) |
177 | setTranslation(area.width, xMin,0,zMin) |
178 | setTranslation(area.height, xMax,0,zMax) |
179 | end |
180 | end |
181 | end |
getRequiresTipOcclusionArea
DescriptionDefinitiongetRequiresTipOcclusionArea()Code
112 | function TipOccluder:getRequiresTipOcclusionArea() |
113 | return false |
114 | end |
getTipOcclusionAreas
DescriptionDefinitiongetTipOcclusionAreas()Code
84 | function TipOccluder:getTipOcclusionAreas() |
85 | return self.spec_tipOccluder.tipOcclusionAreas |
86 | end |
getWheelsWithTipOcclisionAreaGroupId
DescriptionDefinitiongetWheelsWithTipOcclisionAreaGroupId()Code
90 | function TipOccluder:getWheelsWithTipOcclisionAreaGroupId(wheels, groupId) |
91 | local returnWheels = {} |
92 | for _,wheel in pairs(wheels) do |
93 | if wheel.tipOcclusionAreaGroupId == groupId then |
94 | table.insert(returnWheels, wheel) |
95 | end |
96 | end |
97 | return returnWheels |
98 | end |
initSpecialization
DescriptionDefinitioninitSpecialization()Code
22 | function TipOccluder.initSpecialization() |
23 | local schema = Vehicle.xmlSchema |
24 | schema:setXMLSpecializationType("TipOccluder") |
25 | |
26 | schema:register(XMLValueType.NODE_INDEX, "vehicle.tipOccluder.occlusionArea(?)#start", "Start node") |
27 | schema:register(XMLValueType.NODE_INDEX, "vehicle.tipOccluder.occlusionArea(?)#width", "Width node") |
28 | schema:register(XMLValueType.NODE_INDEX, "vehicle.tipOccluder.occlusionArea(?)#height", "Height node") |
29 | |
30 | schema:setXMLSpecializationType() |
31 | end |
onLoad
DescriptionDefinitiononLoad()Code
56 | function TipOccluder:onLoad(savegame) |
57 | local spec = self.spec_tipOccluder |
58 | |
59 | XMLUtil.checkDeprecatedXMLElements(self.xmlFile, "vehicle.tipOcclusionAreas.tipOcclusionArea", "vehicle.tipOccluder.occlusionArea") --FS17 to FS19 |
60 | |
61 | -- load tip occlusion areas |
62 | spec.tipOcclusionAreas = {} |
63 | local i = 0 |
64 | while true do |
65 | local key = string.format("vehicle.tipOccluder.occlusionArea(%d)", i) |
66 | if not self.xmlFile:hasProperty(key) then |
67 | break |
68 | end |
69 | local entry = {} |
70 | entry.start = self.xmlFile:getValue(key .. "#start", nil, self.components, self.i3dMappings) |
71 | entry.width = self.xmlFile:getValue(key .. "#width", nil, self.components, self.i3dMappings) |
72 | entry.height = self.xmlFile:getValue(key .. "#height", nil, self.components, self.i3dMappings) |
73 | if entry.start ~= nil and entry.width ~= nil and entry.height ~= nil then |
74 | table.insert(spec.tipOcclusionAreas, entry) |
75 | end |
76 | i = i + 1 |
77 | end |
78 | |
79 | spec.createdTipOcclusionAreaGroupIds = {} |
80 | end |
onPostLoad
DescriptionDefinitiononPostLoad()Code
102 | function TipOccluder:onPostLoad() |
103 | if self:getRequiresTipOcclusionArea() then |
104 | if #self.spec_tipOccluder.tipOcclusionAreas == 0 then |
105 | Logging.xmlDevWarning(self.xmlFile, "No TipOcclusionArea defined") |
106 | end |
107 | end |
108 | end |
prerequisitesPresent
DescriptionDefinitionprerequisitesPresent()Code
16 | function TipOccluder.prerequisitesPresent(specializations) |
17 | return true |
18 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
49 | function TipOccluder.registerEventListeners(vehicleType) |
50 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", TipOccluder) |
51 | SpecializationUtil.registerEventListener(vehicleType, "onPostLoad", TipOccluder) |
52 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
35 | function TipOccluder.registerFunctions(vehicleType) |
36 | SpecializationUtil.registerFunction(vehicleType, "getTipOcclusionAreas", TipOccluder.getTipOcclusionAreas) |
37 | SpecializationUtil.registerFunction(vehicleType, "getWheelsWithTipOcclisionAreaGroupId", TipOccluder.getWheelsWithTipOcclisionAreaGroupId) |
38 | SpecializationUtil.registerFunction(vehicleType, "getRequiresTipOcclusionArea", TipOccluder.getRequiresTipOcclusionArea) |
39 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
43 | function TipOccluder.registerOverwrittenFunctions(vehicleType) |
44 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "finalizeWheel", TipOccluder.finalizeWheel) |
45 | end |