GE Lua Documentation

Press F to search!

onCouplerAttached

Definition


-- @/lua/ge/extensions/core/vehicles.lua:2689

-- TODO: Trailer respawn code is currently active, uncomment this when it's disabled
-- local function onVehicleResetted(vid)
--   if M.resetVehCollectionEnabled then
--     if not vehsSpawningFlag[vid] then
--       if vehsPreventCollectionResetFlag[vid] then
--         vehsPreventCollectionResetFlag[vid] = nil
--       else
--         vehicleCollectionReset(vid)
--       end
--     end
--   end
-- end

-- TODO: Trailer respawn code is currently active, uncomment this when it's disabled
-- local function onSetClusterPosRelRot(vehicleID, cNodeId)
--   if M.resetVehCollectionEnabled then
--     if vehsSpawningFlag[vehicleID] then
--       vehicleCollectionReset(vehicleID)
--       vehsSpawningFlag[vehicleID] = nil
--       return
--     end
--   end
-- end

local function onCouplerAttached(objId1, objId2, nodeId, obj2nodeId)
  table.insert(M.attachedCouplers, {objId1, objId2, nodeId, obj2nodeId})

  -- TODO: Trailer respawn code is currently active, uncomment this when it's disabled
  -- -- if the two vehicles coupled together are not part of the same vehicle collection, remove both collections
  -- local collection = M.vehIdToVehCollection[objId1]
  -- if collection then
  --   if collection.vehsData[objId2] then
  --     -- The two vehicles are part of the same vehicle collection
  --     if collection.resetState then
  --       -- On resets, record down coupled vehicles
  --       local coupledData = collection.resetState.coupled
  --       coupledData[objId1], coupledData[objId2] = coupledData[objId1] or {}, coupledData[objId2] or {}
  --       coupledData[objId1][objId2], coupledData[objId2][objId1] = true, true
  --       checkVehicleCollectionReset(collection)
  --     end
  --   else
  --     -- The two vehicles are part of different vehicle collections

  --     -- Determine who is the parent and who is the child
  --     local obj1CouplerTag = M.vehsCouplerTags[objId1][nodeId]
  --     local obj2CouplerTag = M.vehsCouplerTags[objId2][obj2nodeId]
  --     local couplerTag = obj1CouplerTag or obj2CouplerTag

  --     local parentVehicleId, childVehicleId, parentNode, vehNode

  --     if obj1CouplerTag then
  --       -- obj1 is the parent, obj2 is the child
  --       parentVehicleId = objId1
  --       childVehicleId = objId2
  --       parentNode = nodeId
  --       vehNode = obj2nodeId
  --     else
  --       -- obj2 is the parent, obj1 is the child
  --       parentVehicleId = objId2
  --       childVehicleId = objId1
  --       parentNode = obj2nodeId
  --       vehNode = nodeId
  --     end

  --     -- Remove the child vehicle collection and add the vehicles to the parent vehicle collection
  --     local parentCollection, childCollection = M.vehIdToVehCollection[parentVehicleId], M.vehIdToVehCollection[childVehicleId]
  --     addVehicleToCollectionViaCoupling(parentCollection, parentVehicleId, parentNode, childVehicleId, vehNode)

  --     -- Remove vehicles attached logically (rather than physically) to the parent vehicle collection with same coupler tag
  --     local parentVehData = parentCollection.vehsData[parentVehicleId]
  --     for vehId, vehData in pairs(parentVehData.children or {}) do
  --       if vehData.offsetData and vehData.offsetData.type == "coupledNodes" then
  --         local vdata = core_vehicle_manager.getVehicleData(vehId).vdata
  --         local childNode = getNodeFromName(vdata, vehData.offsetData.node)
  --         if childNode and childNode.tag == couplerTag then
  --           removeVehicleFromCollection(vehId)
  --         end
  --       end
  --     end
  --   end
  -- end
end

Callers

@/lua/vehicle/controller/couplings/fifthwheel.lua

local function onCouplerAttached(nodeId, obj2id, obj2nodeId, attachForce)
  if nodeId == fifthwheelNodeCid then
@/lua/ge/extensions/core/couplerCameraModifier.lua

local function onCouplerAttached(objId1_, objId2_)
  if checkForTrailer(objId1_, objId2_) == true then
@/lua/vehicle/controller/advancedCouplerControl.lua

local function onCouplerAttached(nodeId, obj2id, obj2nodeId, attachForce)
  local couplerIndex = couplerGroup.couplerNodeIdLookup[nodeId]
@/lua/vehicle/controller/hydraulics/hydraulicTrailerFeet.lua

local function onCouplerAttached(nodeId, obj2id, obj2nodeId)
  if obj:getId() ~= obj2id then
@/lua/vehicle/powertrain/hydraulicPump.lua

local function onCouplerAttached(device, nodeId, obj2id, obj2nodeId, attachForce)
  --if we just attached to our own consumer (ie we act as supply)
@/lua/ge/main.lua

function onCouplerAttached(objId1, objId2, nodeId, obj2nodeId)
  if objId1 ~= objId2 and settings.getValue("couplerCameraModifier", false) then
@/lua/vehicle/powertrain.lua

local function onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  for i = 1, deviceCount, 1 do
    if device.onCouplerAttached then
      device:onCouplerAttached(nodeId, obj2id, obj2nodeId, attachEnergy)
    end
@/lua/vehicle/controller.lua

local function onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  for i = 1, couplerAttachedEventCount, 1 do
      if controller.onCouplerAttached ~= nil then
        print("  sortedControllers[" .. i .. "].onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy) -- " .. tostring(controller.typeName))
      end
@/lua/vehicle/powertrain/hydraulicAccumulator.lua

local function onCouplerAttached(device, nodeId, obj2id, obj2nodeId, attachForce)
  --if the attached node is our supply node (ie the one where WE connect to OUR supply) and we act as consumer
@/lua/vehicle/controller/linearActuators/linearActuatorTrailerFeet.lua

local function onCouplerAttached(nodeId, obj2id, obj2nodeId)
  if obj:getId() ~= obj2id and nodeId == couplerNodeId then
@/lua/vehicle/controller/trailerFeet.lua

local function onCouplerAttached(nodeId, obj2id, obj2nodeId)
  if obj:getId() ~= obj2id then
@/lua/vehicle/energyStorage.lua

local function onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  for i = 1, storageCount, 1 do
    if storage.onCouplerAttached then
      storage:onCouplerAttached(nodeId, obj2id, obj2nodeId, attachEnergy)
    end
@/lua/ge/extensions/career/modules/delivery/vehicleTasks.lua
--[[
local function onCouplerAttached(objId1, objId2, nodeId, obj2nodeId)
  for _, taskData in ipairs(vehicleTasks) do
@/lua/vehicle/beamstate.lua

local function onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  --check if we are dealing with couplers within the same vehicle
  if objectId < obj2id then
    obj:queueGameEngineLua(string.format("onCouplerAttached(%s,%s,%s,%s)", objectId, obj2id, nodeId, obj2nodeId))
  end
@/lua/vehicle/energyStorage/pressureTank.lua

local function onCouplerAttached(storage, nodeId, obj2id, obj2nodeId, attachForce)
  --if the attached node is our supply node (ie the one where WE connect to OUR supply) and we act as consumer
@/lua/vehicle/main.lua

function onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  -- print('couplerAttached'..','..nodeId..','..obj2nodeId..','..obj2id..','..attachSpeed)
  -- print('couplerAttached'..','..nodeId..','..obj2nodeId..','..obj2id..','..attachSpeed)
  beamstate.onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  controller.onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  beamstate.onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  controller.onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  powertrain.onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  controller.onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  powertrain.onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  energyStorage.onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  powertrain.onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  energyStorage.onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
  extensions.hook("onCouplerAttached", nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
@/lua/ge/extensions/flowgraph/modules/vehicleModule.lua

function C:onCouplerAttached(objId1, objId2, nodeId, obj2nodeId)
  self.couplings[objId1][objId2] = true
@/lua/vehicle/controller/controllerTemplate.lua

-- local function onCouplerAttached(nodeId, obj2id, obj2nodeId)
-- end
@/lua/ge/extensions/core/trailerRespawn.lua

local function onCouplerAttached(objId1, objId2, nodeId, obj2nodeId)
  if objId1 == objId2 then return end