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
DynamicallyLoadedParts
DescriptionSpecialization for loading and linking external i3d files/assets (e.g. wheelChocks) to a vehicleFunctions
- initSpecialization
- onDelete
- onDynamicallyPartI3DLoaded
- onLoad
- prerequisitesPresent
- registerEventListeners
- registerFunctions
initSpecialization
DescriptionDefinitioninitSpecialization()Code
21 | function DynamicallyLoadedParts.initSpecialization() |
22 | local schema = Vehicle.xmlSchema |
23 | schema:setXMLSpecializationType("DynamicallyLoadedParts") |
24 | |
25 | local basePath = "vehicle.dynamicallyLoadedParts.dynamicallyLoadedPart(?)" |
26 | schema:register(XMLValueType.STRING, basePath .. "#filename", "Filename to i3d file") |
27 | schema:register(XMLValueType.NODE_INDEX, basePath .. "#node", "Node in external i3d file", "0|0") |
28 | schema:register(XMLValueType.NODE_INDEX, basePath .. "#linkNode", "Link node", "0>") |
29 | schema:register(XMLValueType.VECTOR_TRANS, basePath .. "#position", "Position") |
30 | schema:register(XMLValueType.NODE_INDEX, basePath .. "#rotationNode", "Rotation node", "node") |
31 | schema:register(XMLValueType.VECTOR_ROT, basePath .. "#rotation", "Rotation node rotation") |
32 | schema:register(XMLValueType.STRING, basePath .. "#shaderParameterName", "Shader parameter name") |
33 | schema:register(XMLValueType.VECTOR_4, basePath .. "#shaderParameter", "Shader parameter to apply") |
34 | |
35 | schema:setXMLSpecializationType() |
36 | end |
onDelete
DescriptionDefinitiononDelete()Code
79 | function DynamicallyLoadedParts:onDelete() |
80 | local spec = self.spec_dynamicallyLoadedParts |
81 | |
82 | if spec.sharedLoadRequestIds ~= nil then |
83 | for _, sharedLoadRequestId in ipairs(spec.sharedLoadRequestIds) do |
84 | g_i3DManager:releaseSharedI3DFile(sharedLoadRequestId) |
85 | end |
86 | spec.sharedLoadRequestIds = nil |
87 | end |
88 | end |
onDynamicallyPartI3DLoaded
DescriptionDefinitiononDynamicallyPartI3DLoaded()Code
92 | function DynamicallyLoadedParts:onDynamicallyPartI3DLoaded(i3dNode, failedReason, args) |
93 | local spec = self.spec_dynamicallyLoadedParts |
94 | |
95 | local xmlFile = args.xmlFile |
96 | local partKey = args.partKey |
97 | local dynamicallyLoadedPart = args.dynamicallyLoadedPart |
98 | |
99 | if i3dNode ~= 0 then |
100 | local node = xmlFile:getValue(partKey .. "#node", "0|0", i3dNode) |
101 | if node == nil then |
102 | Logging.xmlWarning(xmlFile, "Failed to load dynamicallyLoadedPart '%s'. Unable to find node in loaded i3d", partKey) |
103 | return false |
104 | end |
105 | |
106 | local linkNode = xmlFile:getValue(partKey .. "#linkNode", "0>", self.components, self.i3dMappings) |
107 | if linkNode == nil then |
108 | Logging.xmlWarning(xmlFile, "Failed to load dynamicallyLoadedPart '%s'. Unable to find linkNode", partKey) |
109 | return false |
110 | end |
111 | |
112 | local x, y, z = xmlFile:getValue(partKey .. "#position") |
113 | if x ~= nil and y ~= nil and z ~= nil then |
114 | setTranslation(node, x,y,z) |
115 | end |
116 | |
117 | local rotationNode = xmlFile:getValue(partKey .. "#rotationNode", node, i3dNode) |
118 | local rotX, rotY, rotZ = xmlFile:getValue(partKey .. "#rotation") |
119 | if rotX ~= nil and rotY ~= nil and rotZ ~= nil then |
120 | setRotation(rotationNode, rotX, rotY, rotZ) |
121 | end |
122 | |
123 | local shaderParameterName = xmlFile:getValue(partKey .. "#shaderParameterName") |
124 | local sx, sy, sz, sw = xmlFile:getValue(partKey .. "#shaderParameter") |
125 | if shaderParameterName ~= nil and sx ~= nil and sy ~= nil and sz ~= nil and sw ~= nil then |
126 | setShaderParameter(node, shaderParameterName, sx, sy, sz, sw, false) |
127 | end |
128 | |
129 | link(linkNode, node) |
130 | delete(i3dNode) |
131 | |
132 | table.insert(spec.parts, dynamicallyLoadedPart) |
133 | end |
134 | end |
onLoad
DescriptionDefinitiononLoad()Code
53 | function DynamicallyLoadedParts:onLoad(savegame) |
54 | local spec = self.spec_dynamicallyLoadedParts |
55 | |
56 | spec.sharedLoadRequestIds = {} |
57 | spec.parts = {} |
58 | |
59 | self.xmlFile:iterate("vehicle.dynamicallyLoadedParts.dynamicallyLoadedPart", function (_, partKey) |
60 | local filename = self.xmlFile:getValue(partKey .. "#filename") |
61 | if filename ~= nil then |
62 | local dynamicallyLoadedPart = {} |
63 | dynamicallyLoadedPart.filename = Utils.getFilename(filename, self.baseDirectory) |
64 | local arguments = { |
65 | xmlFile = self.xmlFile, |
66 | partKey = partKey, |
67 | dynamicallyLoadedPart = dynamicallyLoadedPart |
68 | } |
69 | local sharedLoadRequestId = self:loadSubSharedI3DFile(dynamicallyLoadedPart.filename, false, false, self.onDynamicallyPartI3DLoaded, self, arguments) |
70 | table.insert(spec.sharedLoadRequestIds, sharedLoadRequestId) |
71 | else |
72 | Logging.xmlWarning(self.xmlFile, "Missing filename for dynamically loaded part '%s'", partKey) |
73 | end |
74 | end) |
75 | end |
prerequisitesPresent
DescriptionDefinitionprerequisitesPresent()Code
15 | function DynamicallyLoadedParts.prerequisitesPresent(specializations) |
16 | return true |
17 | end |
registerEventListeners
DescriptionDefinitionregisterEventListeners()Code
46 | function DynamicallyLoadedParts.registerEventListeners(vehicleType) |
47 | SpecializationUtil.registerEventListener(vehicleType, "onLoad", DynamicallyLoadedParts) |
48 | SpecializationUtil.registerEventListener(vehicleType, "onDelete", DynamicallyLoadedParts) |
49 | end |
registerFunctions
DescriptionDefinitionregisterFunctions()Code
40 | function DynamicallyLoadedParts.registerFunctions(vehicleType) |
41 | SpecializationUtil.registerFunction(vehicleType, "onDynamicallyPartI3DLoaded", DynamicallyLoadedParts.onDynamicallyPartI3DLoaded) |
42 | end |