Vehicles/VehicleScripts/VattenmaskConnectionPart.lua

Articulated steering allows to implement a steering mechanism that works with two different objects connected with a joint.

  25  VattenmaskConnectionPart                        = VattenmaskConnectionPart or {};

VattenmaskConnectionPart:load(dataTable)

Load the configuration data of the joint and the steering values.

  29  function VattenmaskConnectionPart:load(dataTable)
  30  
  31      self.alignConnectionPart                    = VattenmaskConnectionPart.alignConnectionPart;
  32      if dataTable.vattenmaskConnectionPart == nil then
  33          printf("Warning: Using vehicle script 'VattenmaskConnectionPart', but the data table 'vattenmaskConnectionPart' is missing (got a %s value, table expected)", type(dataTable.vattenmaskConnectionPart));
  34          return;
  35      end;
  36  
  37      self.connectionPart         = dataTable.vattenmaskConnectionPart;
  38  
  39  end;

VattenmaskConnectionPart:alignConnectionPart(connectionPartId, posXIndex, posYIndex, posZIndex, rotXIndex, rotYIndex, rotZIndex)

Aligns the connection part, if existing. It will align each position and rotation value, on the given transforms.

  43  function VattenmaskConnectionPart:alignConnectionPart(connectionPartId, posXIndex, posYIndex, posZIndex, rotXIndex, rotYIndex, rotZIndex)
  44  
  45      local connectionPart                        = getChild(self.id, connectionPartId)
  46      if self.connectionPart.attachPositionComponents ~= nil then
  47          local posX1, posY1, posZ1   = getWorldPosition(getChild(self.id, posXIndex));
  48          local posX2, posY2, posZ2   = getWorldPosition(getChild(self.id, posYIndex));
  49          local posX3, posY3, posZ3   = getWorldPosition(getChild(self.id, posZIndex));
  50          setWorldPosition(connectionPart, posX1, posY2, posZ3);
  51      end;
  52  
  53      if self.connectionPart.attachRotationComponents ~= nil then
  54          local rotX1, rotY1, rotZ1   = getWorldRotation(getChild(self.id, rotXIndex));
  55          local rotX2, rotY2, rotZ2   = getWorldRotation(getChild(self.id, rotYIndex));
  56          local rotX3, rotY3, rotZ3   = getWorldRotation(getChild(self.id, rotZIndex));
  57          setWorldRotation(connectionPart, rotX1, rotY2, rotZ3);
  58      end;
  59  end;

VattenmaskConnectionPart:update()

Updates the position of the vattenmask connection part.

  63  function VattenmaskConnectionPart:update()
  64  -- update connectionPart position and rotation
  65      if self.connectionPart ~= nil and self.connectionPart.connectionPartIndex ~= nil then
  66          local posX, posY, posZ      = self.connectionPart.attachPositionComponents.posX, self.connectionPart.attachPositionComponents.posY, self.connectionPart.attachPositionComponents.posZ
  67          local rotX, rotY, rotZ      = self.connectionPart.attachRotationComponents.rotX, self.connectionPart.attachRotationComponents.rotY, self.connectionPart.attachRotationComponents.rotZ
  68          
  69          self:alignConnectionPart(self.connectionPart.connectionPartIndex, posX, posY, posZ, rotX, rotY, rotZ);
  70      end;
  71  end;

All contents of this page may be used for modding use for Winter Resort Simulator - Season 2 only. Any use exceeding this regulation is not permitted.

Copyright (C) HR Innoways, 2021. All Rights Reserved.