LUADOC - Farming Simulator 22

Script v1_7_1_0

Engine v1_7_1_0

Foundation Reference

MountableObject

Parent
PhysicsObject
Functions

additionalMountingMassRaycastCallback

Description
Callback used when raycast hits an object.
Definition
additionalMountingMassRaycastCallback(integer hitObjectId, float x, float y, float z, float distance, float nx, float ny, float nz, integer subShapeIndex, integer shapeId, boolean isLast)
Arguments
integerhitObjectIdscenegraph object id
floatxworld x hit position
floatyworld y hit position
floatzworld z hit position
floatdistancedistance at which the cast hit the object
floatnxnormal x direction
floatnynormal y direction
floatnznormal z direction
integersubShapeIndexsub shape index
integershapeIdid of shape
booleanisLastis last hit
Return Values
boolreturnfalse to stop raycast
Code
275function MountableObject:additionalMountingMassRaycastCallback(hitObjectId, x, y, z, distance, nx, ny, nz, subShapeIndex, shapeId, isLast)
276 local object = g_currentMission.nodeToObject[hitObjectId]
277 if object ~= self and object ~= nil and object:isa(MountableObject) then
278 self.additionalMountingMass = self.additionalMountingMass + object:getMass()
279 self.additionalMountingMass = self.additionalMountingMass + object:getAdditionalMountingMass()
280
281 return false
282 end
283end

getAdditionalMountingMass

Description
Returns recursively the mass of objects laying on top of the mountable object
Definition
getAdditionalMountingMass()
Code
248function MountableObject:getAdditionalMountingMass()
249 local distance = self:getAdditionalMountingDistance()
250 if distance > 0 then
251 local x, y, z = getWorldTranslation(self.nodeId)
252 self.additionalMountingMass = 0
253 raycastAll(x, y, z, 0, 1, 0, "additionalMountingMassRaycastCallback", distance + 0.1, self, CollisionFlag.VEHICLE, false, false)
254
255 return self.additionalMountingMass
256 end
257
258 return 0
259end

setWorldPositionQuaternion

Description
Set world pose
Definition
setWorldPositionQuaternion(float x, float y, float z, float xRot, float yRot, float zRot, float w_rot)
Arguments
floatxx position
floatyz position
floatzz position
floatxRotx rotation
floatyRoty rotation
floatzRotz rotation
floatw_rotw rotation
Code
315function MountableObject:setWorldPositionQuaternion(x, y, z, quatX, quatY, quatZ, quatW, changeInterp)
316 if not self.isServer then
317 if self.dynamicMountType ~= MountableObject.MOUNT_TYPE_KINEMATIC and self.dynamicMountType ~= MountableObject.MOUNT_TYPE_DEFAULT then
318 MountableObject:superClass().setWorldPositionQuaternion(self, x, y, z, quatX, quatY, quatZ, quatW, changeInterp)
319 end
320 else
321 MountableObject:superClass().setWorldPositionQuaternion(self, x, y, z, quatX, quatY, quatZ, quatW, changeInterp)
322 end
323end