Action denied

Vehicles/VehicleScripts/VehicleAnchor.lua

VehicleAnchor creates a rope winch AnchorPoint that is mounted to a vehicle. Any vehicle with a RopeWinch script attached can then be attached to this anchor point.

  26  
  27  VehicleAnchor                       = VehicleAnchor or {};

VehicleAnchor:load(dataTable)

Loads all anchor points that are mounted to this vehicle (all of them have to be stored in dataTable.anchorPoints), and creates an object of type AnchorPoint for each of them.

  31  function VehicleAnchor:load(dataTable)
  32      self.anchorPoints               = {};
  33  
  34      if dataTable.anchorPoints ~= nil then
  35          for k, v in pairs(dataTable.anchorPoints) do
  36              local anchorId          = getChild(self.id, v.index or ""); -- rope target
  37              local colId             = getChild(self.id, v.buttonIndex or ""); -- control element for attaching / disattaching
  38  
  39              table.insert(self.anchorPoints, AnchorPoint:new(anchorId, colId));
  40          end;
  41      end;
  42  end;

VehicleAnchor:saveToTable(tbl)

We need to save the name of this anchor point (to keep savegame continuity).

  46  function VehicleAnchor:saveToTable(tbl)
  47      if tbl == nil then return end;
  48  
  49      tbl.anchorPoints                = {};
  50      for k, v in pairs(self.anchorPoints) do
  51          tbl.anchorPoints[k]         = v.anchorPointName;
  52      end;
  53  end;

VehicleAnchor:loadFromTable(tbl)

Restores the anchor point names.

  57  function VehicleAnchor:loadFromTable(tbl)
  58      if tbl == nil then return end;
  59      if tbl.anchorPoints == nil then return end;
  60  
  61      for k, v in pairs(self.anchorPoints) do
  62          local value                 = tbl.anchorPoints[k];
  63          if value ~= nil then
  64              v.anchorPointName       = value;
  65              RopeWinch.registerAnchorPoint(v.anchorPointName, v);
  66          end;
  67      end;
  68  end;

VehicleAnchor:destroy()

  70  function VehicleAnchor:destroy()
  71      for k, v in pairs(self.anchorPoints) do
  72          v:destroy();
  73      end;
  74  end;

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

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