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
PlaceableDynamicallyLoadedParts
DescriptionSpecialization for placeablesFunctions
- onDelete
- onDynamicallyPartI3DLoaded
- onLoad
- prerequisitesPresent
- registerEventListeners
- registerFunctions
- registerXMLPaths
onDelete
DescriptionDefinitiononDelete()Code
145 | function PlaceableDynamicallyLoadedParts:onDelete() |
146 | local spec = self.spec_dynamicallyLoadedParts |
147 | |
148 | if spec.sharedLoadRequestIds ~= nil then |
149 | for _, sharedLoadRequestId in ipairs(spec.sharedLoadRequestIds) do |
150 | g_i3DManager:releaseSharedI3DFile(sharedLoadRequestId) |
151 | end |
152 | spec.sharedLoadRequestIds = nil |
153 | end |
154 | |
155 | if spec.parts ~= nil then |
156 | for _, part in pairs(spec.parts) do |
157 | delete(part.node) |
158 | end |
159 | end |
160 | end |
onDynamicallyPartI3DLoaded
DescriptionDefinitiononDynamicallyPartI3DLoaded()Code
87 | function PlaceableDynamicallyLoadedParts:onDynamicallyPartI3DLoaded(i3dNode, failedReason, args) |
88 | local spec = self.spec_dynamicallyLoadedParts |
89 | |
90 | local loadingTask = args.loadingTask |
91 | local filename = args.filename |
92 | local xmlFile = args.xmlFile |
93 | local partKey = args.key |
94 | |
95 | if i3dNode ~= 0 then |
96 | local node = xmlFile:getValue(partKey .. "#node", "0", i3dNode) |
97 | if node == nil then |
98 | Logging.xmlWarning(xmlFile, "Failed to load dynamicallyLoadedPart '%s'. Unable to find node in loaded i3d", partKey) |
99 | return false |
100 | end |
101 | |
102 | local linkNode = xmlFile:getValue(partKey .. "#linkNode", "0>", self.components, self.i3dMappings) |
103 | if linkNode == nil then |
104 | Logging.xmlWarning(xmlFile, "Failed to load dynamicallyLoadedPart '%s'. Unable to find linkNode", partKey) |
105 | return false |
106 | end |
107 | |
108 | local x, y, z = xmlFile:getValue(partKey .. "#position") |
109 | if x ~= nil and y ~= nil and z ~= nil then |
110 | setTranslation(node, x,y,z) |
111 | end |
112 | |
113 | local rotationNode = xmlFile:getValue(partKey .. "#rotationNode", node, i3dNode) |
114 | local rotX, rotY, rotZ = xmlFile:getValue(partKey .. "#rotation") |
115 | if rotX ~= nil and rotY ~= nil and rotZ ~= nil then |
116 | setRotation(rotationNode, rotX, rotY, rotZ) |
117 | end |
118 | |
119 | local shaderParameterName = xmlFile:getValue(partKey .. "#shaderParameterName") |
120 | local sx, sy, sz, sw = xmlFile:getValue(partKey .. "#shaderParameter") |
121 | if shaderParameterName ~= nil and sx ~= nil and sy ~= nil and sz ~= nil and sw ~= nil then |
122 | setShaderParameter(node, shaderParameterName, sx, sy, sz, sw, false) |
123 | end |
124 | |
125 | local objects = {} |
126 | ObjectChangeUtil.loadObjectChangeFromXML(xmlFile, partKey, objects, i3dNode, nil) |
127 | ObjectChangeUtil.setObjectChanges(objects, true, nil) |
128 | |
129 | link(linkNode, node) |
130 | delete(i3dNode) |
131 | |
132 | |
133 | local dynamicallyLoadedPart = {} |
134 | dynamicallyLoadedPart.filename = filename |
135 | dynamicallyLoadedPart.node = node |
136 | |
137 | table.insert(spec.parts, dynamicallyLoadedPart) |
138 | end |
139 | |
140 | self:finishLoadingTask(loadingTask) |
141 | end |
onLoad
DescriptionCalled on loadingDefinition
onLoad(table savegame)Arguments
table | savegame | savegame |
59 | function PlaceableDynamicallyLoadedParts:onLoad(savegame) |
60 | local spec = self.spec_dynamicallyLoadedParts |
61 | |
62 | spec.sharedLoadRequestIds = {} |
63 | spec.parts = {} |
64 | |
65 | self.xmlFile:iterate("placeable.dynamicallyLoadedParts.dynamicallyLoadedPart", function (_, partKey) |
66 | local filename = self.xmlFile:getValue(partKey .. "#filename") |
67 | if filename ~= nil then |
68 | filename = Utils.getFilename(filename, self.baseDirectory) |
69 | |
70 | local args = { |
71 | xmlFile = self.xmlFile, |
72 | key = partKey, |
73 | loadingTask = self:createLoadingTask(spec), |
74 | filename = filename |
75 | } |
76 | |
77 | local sharedLoadRequestId = g_i3DManager:loadSharedI3DFileAsync(filename, false, false, self.onDynamicallyPartI3DLoaded, self, args) |
78 | table.insert(spec.sharedLoadRequestIds, sharedLoadRequestId) |
79 | else |
80 | Logging.xmlWarning(self.xmlFile, "Missing filename for dynamically loaded part '%s'", partKey) |
81 | end |
82 | end) |
83 | 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 PlaceableDynamicallyLoadedParts.prerequisitesPresent(specializations) |
19 | return true |
20 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
30 | function PlaceableDynamicallyLoadedParts.registerEventListeners(placeableType) |
31 | SpecializationUtil.registerEventListener(placeableType, "onLoad", PlaceableDynamicallyLoadedParts) |
32 | SpecializationUtil.registerEventListener(placeableType, "onDelete", PlaceableDynamicallyLoadedParts) |
33 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
24 | function PlaceableDynamicallyLoadedParts.registerFunctions(placeableType) |
25 | SpecializationUtil.registerFunction(placeableType, "onDynamicallyPartI3DLoaded", PlaceableDynamicallyLoadedParts.onDynamicallyPartI3DLoaded) |
26 | end |
registerXMLPaths
DescriptionDefinitionregisterXMLPaths()Code
37 | function PlaceableDynamicallyLoadedParts.registerXMLPaths(schema, basePath) |
38 | schema:setXMLSpecializationType("DynamicallyLoadedParts") |
39 | |
40 | basePath = basePath .. ".dynamicallyLoadedParts.dynamicallyLoadedPart(?)" |
41 | |
42 | schema:register(XMLValueType.STRING, basePath .. "#filename", "Filename to i3d file") |
43 | schema:register(XMLValueType.NODE_INDEX, basePath .. "#node", "Node in external i3d file", "0") |
44 | schema:register(XMLValueType.NODE_INDEX, basePath .. "#linkNode", "Link node", "0>") |
45 | schema:register(XMLValueType.VECTOR_TRANS, basePath .. "#position", "Position") |
46 | schema:register(XMLValueType.NODE_INDEX, basePath .. "#rotationNode", "Rotation node", "node") |
47 | schema:register(XMLValueType.VECTOR_ROT, basePath .. "#rotation", "Rotation node rotation") |
48 | schema:register(XMLValueType.STRING, basePath .. "#shaderParameterName", "Shader parameter name") |
49 | schema:register(XMLValueType.VECTOR_4, basePath .. "#shaderParameter", "Shader parameter to apply") |
50 | |
51 | ObjectChangeUtil.registerObjectChangeSingleXMLPaths(schema, basePath) |
52 | |
53 | schema:setXMLSpecializationType() |
54 | end |