LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

TensionBeltObject

Description
Specialization for vehicles which can be mounted by tension belts
Functions

getMeshNodes

Description
Definition
getMeshNodes()
Code
81function TensionBeltObject:getMeshNodes()
82 return self.spec_tensionBeltObject.meshNodes
83end

getSupportsTensionBelts

Description
Definition
getSupportsTensionBelts()
Code
75function TensionBeltObject:getSupportsTensionBelts()
76 return self.spec_tensionBeltObject.supportsTensionBelts
77end

getTensionBeltNodeId

Description
Definition
getTensionBeltNodeId()
Code
87function TensionBeltObject:getTensionBeltNodeId()
88 return self.components[1].node
89end

initSpecialization

Description
Definition
initSpecialization()
Code
21function TensionBeltObject.initSpecialization()
22 local schema = Vehicle.xmlSchema
23 schema:setXMLSpecializationType("TensionBeltObject")
24
25 schema:register(XMLValueType.BOOL, "vehicle.tensionBeltObject#supportsTensionBelts", "Supports tension belts", true)
26 schema:register(XMLValueType.NODE_INDEX, "vehicle.tensionBeltObject.meshNodes.meshNode(?)#node", "Mesh node for tension belt calculation")
27
28 schema:setXMLSpecializationType()
29end

onLoad

Description
Called on loading
Definition
onLoad(table savegame)
Arguments
tablesavegamesavegame
Code
48function TensionBeltObject:onLoad(savegame)
49 local spec = self.spec_tensionBeltObject
50
51 spec.supportsTensionBelts = self.xmlFile:getValue("vehicle.tensionBeltObject#supportsTensionBelts", true)
52
53 spec.meshNodes = {}
54 local i = 0
55 while true do
56 local baseKey = string.format("vehicle.tensionBeltObject.meshNodes.meshNode(%d)", i)
57 if not self.xmlFile:hasProperty(baseKey) then
58 break
59 end
60
61 local node = self.xmlFile:getValue(baseKey.."#node", nil, self.components, self.i3dMappings)
62 if node ~= nil then
63 if not getShapeIsCPUMesh(node) then
64 Logging.xmlWarning(self.xmlFile, "Mesh node %s (%s) does not have the CPU-Mesh flag set required for tension belts", self.xmlFile:getString(baseKey.."#node"), I3DUtil.getNodePath(node))
65 end
66 table.insert(spec.meshNodes, node)
67 end
68
69 i = i + 1
70 end
71end

prerequisitesPresent

Description
Definition
prerequisitesPresent()
Code
15function TensionBeltObject.prerequisitesPresent(specializations)
16 return true
17end

registerEventListeners

Description
Definition
registerEventListeners()
Code
41function TensionBeltObject.registerEventListeners(vehicleType)
42 SpecializationUtil.registerEventListener(vehicleType, "onLoad", TensionBeltObject)
43end

registerFunctions

Description
Definition
registerFunctions()
Code
33function TensionBeltObject.registerFunctions(vehicleType)
34 SpecializationUtil.registerFunction(vehicleType, "getSupportsTensionBelts", TensionBeltObject.getSupportsTensionBelts)
35 SpecializationUtil.registerFunction(vehicleType, "getMeshNodes", TensionBeltObject.getMeshNodes)
36 SpecializationUtil.registerFunction(vehicleType, "getTensionBeltNodeId", TensionBeltObject.getTensionBeltNodeId)
37end