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
TreeSaplingPallet
DescriptionSpecialization for tree pallets only to store the loaded tree typeFunctions
- getTreeType
- initSpecialization
- onDelete
- onFillUnitFillLevelChanged
- onLoad
- onTreeSaplingLoaded
- prerequisitesPresent
- registerEventListeners
- registerFunctions
getTreeType
DescriptionReturns current tree typeDefinition
getTreeType()Return Values
string | name | tree type name |
124 | function TreeSaplingPallet:getTreeType() |
125 | return self.spec_treeSaplingPallet.treeTypeName |
126 | end |
initSpecialization
DescriptionCalled on specialization initializingDefinition
initSpecialization()Code
21 | function TreeSaplingPallet.initSpecialization() |
22 | g_configurationManager:addConfigurationType("treeSaplingType", g_i18n:getText("configuration_treeType"), "treeSaplingPallet", nil, nil, nil, ConfigurationUtil.SELECTOR_MULTIOPTION) |
23 | |
24 | local schema = Vehicle.xmlSchema |
25 | schema:setXMLSpecializationType("TreeSaplingPallet") |
26 | |
27 | schema:register(XMLValueType.STRING, "vehicle.treeSaplingPallet#treeType", "Tree Type Name", "spruce1") |
28 | schema:register(XMLValueType.STRING, "vehicle.treeSaplingPallet.treeSaplingTypeConfigurations.treeSaplingTypeConfiguration(?)#treeType", "Tree Type Name", "spruce1") |
29 | |
30 | schema:register(XMLValueType.NODE_INDEX, "vehicle.treeSaplingPallet.saplingNodes.saplingNode(?)#node", "Sapling link node") |
31 | schema:register(XMLValueType.NODE_INDEX, "vehicle.treeSaplingPallet.treeSaplingTypeConfigurations.treeSaplingTypeConfiguration(?).saplingNodes.saplingNode(?)#node", "Sapling link node") |
32 | |
33 | ObjectChangeUtil.registerObjectChangeXMLPaths(schema, "vehicle.treeSaplingPallet.treeSaplingTypeConfigurations.treeSaplingTypeConfiguration(?)") |
34 | |
35 | schema:setXMLSpecializationType() |
36 | end |
onDelete
DescriptionCalled on deletingDefinition
onDelete()Code
95 | function TreeSaplingPallet:onDelete() |
96 | local spec = self.spec_treeSaplingPallet |
97 | if spec.saplingNodes ~= nil then |
98 | for i=1, #spec.saplingNodes do |
99 | local entry = spec.saplingNodes[i] |
100 | if entry.sharedLoadRequestId ~= nil then |
101 | g_i3DManager:releaseSharedI3DFile(entry.sharedLoadRequestId) |
102 | end |
103 | end |
104 | spec.saplingNodes = {} |
105 | end |
106 | end |
onFillUnitFillLevelChanged
DescriptionDefinitiononFillUnitFillLevelChanged()Code
130 | function TreeSaplingPallet:onFillUnitFillLevelChanged(fillUnitIndex, fillLevelDelta, fillTypeIndex, toolType, fillPositionData, appliedDelta) |
131 | local spec = self.spec_treeSaplingPallet |
132 | for i=1, #spec.saplingNodes do |
133 | local saplingNode = spec.saplingNodes[i] |
134 | setVisibility(saplingNode.node, i <= MathUtil.round(self:getFillUnitFillLevel(fillUnitIndex))) |
135 | end |
136 | end |
onLoad
DescriptionDefinitiononLoad()Code
55 | function TreeSaplingPallet:onLoad(savegame) |
56 | local spec = self.spec_treeSaplingPallet |
57 | |
58 | local treeSaplingTypeConfigurationId = Utils.getNoNil(self.configurations["treeSaplingType"], 1) |
59 | local baseKey = string.format("vehicle.treeSaplingPallet.treeSaplingTypeConfigurations.treeSaplingTypeConfiguration(%d)", treeSaplingTypeConfigurationId - 1) |
60 | ObjectChangeUtil.updateObjectChanges(self.xmlFile, "vehicle.treeSaplingPallet.treeSaplingTypeConfigurations.treeSaplingTypeConfiguration", treeSaplingTypeConfigurationId, self.components, self) |
61 | |
62 | if not self.xmlFile:hasProperty(baseKey) then |
63 | baseKey = "vehicle.treeSaplingPallet" |
64 | end |
65 | |
66 | spec.treeTypeName = self.xmlFile:getValue(baseKey .. "#treeType", "spruce1") |
67 | spec.treeTypeDesc = g_treePlantManager:getTreeTypeDescFromName(spec.treeTypeName) |
68 | |
69 | spec.saplingNodes = {} |
70 | spec.treeTypeFilename = g_treePlantManager:getTreeTypeFilename(spec.treeTypeDesc, 1) |
71 | if spec.treeTypeFilename ~= nil then |
72 | local nodeKey = baseKey .. ".saplingNodes.saplingNode" |
73 | if not self.xmlFile:hasProperty(nodeKey) then |
74 | nodeKey = "vehicle.treeSaplingPallet.saplingNodes.saplingNode" |
75 | end |
76 | |
77 | self.xmlFile:iterate(nodeKey, function(_, key) |
78 | local entry = {} |
79 | entry.node = self.xmlFile:getValue(key .. "#node", nil, self.components, self.i3dMappings) |
80 | |
81 | if entry.node ~= nil then |
82 | setRotation(entry.node, 0, math.random(0, math.pi * 2), 0) |
83 | setScale(entry.node, 1, math.random(90, 110) / 100, 1) |
84 | |
85 | entry.sharedLoadRequestId = self:loadSubSharedI3DFile(spec.treeTypeFilename, false, false, self.onTreeSaplingLoaded, self, {entry=entry}) |
86 | |
87 | table.insert(spec.saplingNodes, entry) |
88 | end |
89 | end) |
90 | end |
91 | end |
onTreeSaplingLoaded
DescriptionCalled after the sapling has been loadedDefinition
onTreeSaplingLoaded()Return Values
integer | i3dNode | i3d node id |
table | args | arguments |
112 | function TreeSaplingPallet:onTreeSaplingLoaded(i3dNode, failedReason, args) |
113 | if i3dNode ~= 0 then |
114 | local entry = args.entry |
115 | link(entry.node, getChildAt(i3dNode, 0)) |
116 | delete(i3dNode) |
117 | end |
118 | end |
prerequisitesPresent
DescriptionDefinitionprerequisitesPresent()Code
15 | function TreeSaplingPallet.prerequisitesPresent(specializations) |
16 | return true |
17 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
47 | function TreeSaplingPallet.registerEventListeners(vehicleType) |
48 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", TreeSaplingPallet) |
49 | SpecializationUtil.registerEventListener(vehicleType, "onDelete", TreeSaplingPallet) |
50 | SpecializationUtil.registerEventListener(vehicleType, "onFillUnitFillLevelChanged", TreeSaplingPallet) |
51 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
40 | function TreeSaplingPallet.registerFunctions(vehicleType) |
41 | SpecializationUtil.registerFunction(vehicleType, "onTreeSaplingLoaded", TreeSaplingPallet.onTreeSaplingLoaded) |
42 | SpecializationUtil.registerFunction(vehicleType, "getTreeType", TreeSaplingPallet.getTreeType) |
43 | end |