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
Pallet
DescriptionSpecialization for handling the content on the big bagsFunctions
- getMeshNodes
- initSpecialization
- onDelete
- onFillUnitFillLevelChanged
- onLoad
- onPreLoad
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerOverwrittenFunctions
getMeshNodes
DescriptionDefinitiongetMeshNodes()Code
158 | function Pallet:getMeshNodes(superFunc) |
159 | local spec = self.spec_pallet |
160 | if spec.tensionBeltMeshesDirty then |
161 | spec.tensionBeltMeshes = {} |
162 | |
163 | if spec.node ~= nil then |
164 | table.insert(spec.tensionBeltMeshes, spec.node) |
165 | end |
166 | |
167 | for i=1, #spec.contents do |
168 | local content = spec.contents[i] |
169 | for j=1, #content.objects do |
170 | local object = content.objects[j] |
171 | if object.isActive then |
172 | table.insert(spec.tensionBeltMeshes, object.tensionBeltNode or object.node) |
173 | end |
174 | end |
175 | end |
176 | end |
177 | |
178 | if #spec.tensionBeltMeshes > 0 then |
179 | return spec.tensionBeltMeshes |
180 | end |
181 | |
182 | return superFunc(self) |
183 | end |
initSpecialization
DescriptionDefinitioninitSpecialization()Code
23 | function Pallet.initSpecialization() |
24 | local schema = Vehicle.xmlSchema |
25 | schema:setXMLSpecializationType("Pallet") |
26 | |
27 | schema:register(XMLValueType.INT, "vehicle.pallet#fillUnitIndex", "Fill unit index", 1) |
28 | schema:register(XMLValueType.NODE_INDEX, "vehicle.pallet#node", "Root visual pallet node") |
29 | |
30 | schema:register(XMLValueType.INT, "vehicle.pallet.content(?)#fillUnitIndex", "Fill unit index for this content", "pallet#fillUnitIndex") |
31 | schema:register(XMLValueType.NODE_INDEX, "vehicle.pallet.content(?).object(?)#node", "Object node") |
32 | schema:register(XMLValueType.NODE_INDEX, "vehicle.pallet.content(?).object(?)#tensionBeltNode", "Object used for tension belt calculations") |
33 | |
34 | SoundManager.registerSampleXMLPaths(schema, "vehicle.pallet.sounds", "unload") |
35 | |
36 | schema:setXMLSpecializationType() |
37 | end |
onDelete
DescriptionCalled on deleteDefinition
onDelete()Code
111 | function Pallet:onDelete() |
112 | if self.isClient then |
113 | local spec = self.spec_pallet |
114 | g_soundManager:deleteSamples(spec.samples) |
115 | end |
116 | |
117 | g_currentMission.slotSystem:removeLimitedObject(SlotSystem.LIMITED_OBJECT_PALLET, self) |
118 | end |
onFillUnitFillLevelChanged
DescriptionDefinitiononFillUnitFillLevelChanged()Code
122 | function Pallet:onFillUnitFillLevelChanged(fillUnitIndex, fillLevelDelta, fillType, toolType, fillPositionData, appliedDelta) |
123 | local spec = self.spec_pallet |
124 | for i=1, #spec.contents do |
125 | local content = spec.contents[i] |
126 | |
127 | if content.fillUnitIndex == fillUnitIndex then |
128 | local fillLevelPct = self:getFillUnitFillLevelPercentage(fillUnitIndex) |
129 | |
130 | local visibleIndex = math.floor(content.numObjects * fillLevelPct) |
131 | if visibleIndex == 0 and fillLevelPct then |
132 | visibleIndex = 1 -- show at least one object if somethign is loaded |
133 | end |
134 | |
135 | for j=1, #content.objects do |
136 | local object = content.objects[j] |
137 | local isActive = j <= visibleIndex |
138 | if object.isActive ~= isActive then |
139 | local unloading = object.isActive and not isActive |
140 | |
141 | if unloading then |
142 | if self.isClient then |
143 | g_soundManager:playSample(spec.samples.unload) |
144 | end |
145 | end |
146 | |
147 | object.isActive = isActive |
148 | setVisibility(object.node, object.isActive) |
149 | spec.tensionBeltMeshesDirty = true |
150 | end |
151 | end |
152 | end |
153 | end |
154 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
68 | function Pallet:onLoad(savegame) |
69 | local spec = self.spec_pallet |
70 | |
71 | spec.fillUnitIndex = self.xmlFile:getValue("vehicle.pallet#fillUnitIndex", 1) |
72 | spec.node = self.xmlFile:getValue("vehicle.pallet#node", nil, self.components, self.i3dMappings) |
73 | |
74 | spec.contents = {} |
75 | self.xmlFile:iterate("vehicle.pallet.content", function(_, contentKey) |
76 | local content = {} |
77 | content.objects = {} |
78 | content.fillUnitIndex = self.xmlFile:getValue(contentKey .. "#fillUnitIndex", spec.fillUnitIndex) |
79 | |
80 | self.xmlFile:iterate(contentKey .. ".object", function(index, key) |
81 | local object = {} |
82 | object.node = self.xmlFile:getValue(key .. "#node", nil, self.components, self.i3dMappings) |
83 | if object.node ~= nil then |
84 | object.tensionBeltNode = self.xmlFile:getValue(key .. "#tensionBeltNode", nil, self.components, self.i3dMappings) |
85 | object.isActive = false |
86 | setVisibility(object.node, object.isActive) |
87 | |
88 | table.insert(content.objects, object) |
89 | end |
90 | end) |
91 | |
92 | if #content.objects > 0 then |
93 | content.numObjects = #content.objects |
94 | table.insert(spec.contents, content) |
95 | end |
96 | end) |
97 | |
98 | spec.tensionBeltMeshes = {spec.node} |
99 | spec.tensionBeltMeshesDirty = false |
100 | |
101 | if self.isClient then |
102 | spec.samples = {} |
103 | spec.samples.unload = g_soundManager:loadSampleFromXML(self.xmlFile, "vehicle.pallet.sounds", "unload", self.baseDirectory, self.components, 1, AudioGroup.VEHICLE, self.i3dMappings, self) |
104 | end |
105 | |
106 | g_currentMission.slotSystem:addLimitedObject(SlotSystem.LIMITED_OBJECT_PALLET, self) |
107 | end |
onPreLoad
DescriptionDefinitiononPreLoad()Code
61 | function Pallet:onPreLoad(savegame) |
62 | self.isPallet = true |
63 | 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 Pallet.prerequisitesPresent(specializations) |
18 | return true |
19 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
52 | function Pallet.registerEventListeners(vehicleType) |
53 | SpecializationUtil.registerEventListener(vehicleType, "onPreLoad", Pallet) |
54 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", Pallet) |
55 | SpecializationUtil.registerEventListener(vehicleType, "onDelete", Pallet) |
56 | SpecializationUtil.registerEventListener(vehicleType, "onFillUnitFillLevelChanged", Pallet) |
57 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
41 | function Pallet.registerFunctions(vehicleType) |
42 | end |
registerOverwrittenFunctions
DescriptionDefinitionregisterOverwrittenFunctions()Code
46 | function Pallet.registerOverwrittenFunctions(vehicleType) |
47 | SpecializationUtil.registerOverwrittenFunction(vehicleType, "getMeshNodes", Pallet.getMeshNodes) |
48 | end |