onCouplerAttached
Definition
-- @/lua/vehicle/beamstate.lua:395
local function onCouplerAttached(nodeId, obj2id, obj2nodeId, attachSpeed, attachEnergy)
--check if we are dealing with couplers within the same vehicle
local sameId = objectId == obj2id
local sameTag = couplerCache[nodeId] and couplerCache[obj2nodeId] and (couplerCache[obj2nodeId].tag == couplerCache[nodeId].couplerTag)
if sameId and sameTag then
--if we do, we need to make sure that both the primary and the secondary coupler have the same lock/welded meta data
--without this, the secondary coupler will be detected as "attached" even though it's supposed to be ignored if locked/welded
couplerCache[obj2nodeId].couplerLock = couplerCache[obj2nodeId].couplerLock or couplerCache[nodeId].couplerLock
couplerCache[obj2nodeId].couplerWeld = couplerCache[obj2nodeId].couplerWeld or couplerCache[nodeId].couplerWeld
end
if autoCouplingActive and (couplerCache[nodeId] and autoCouplingVisibleTags and autoCouplingVisibleTags[couplerCache[nodeId].couplerTag]) then
disableAutoCoupling()
end
attachedCouplers[nodeId] = transmitCouplers[nodeId] or {}
attachedCouplers[nodeId].obj2id = obj2id
attachedCouplers[nodeId].obj2nodeId = obj2nodeId
-- figure out the electrics state
local n = v.data.nodes[nodeId]
if n and (n.importElectrics or n.importInputs) then
local data = {electrics = n.importElectrics, inputs = n.importInputs}
--print("couplerAttached -> beamstate.exportCouplerData("..tostring(obj2nodeId)..", "..serialize(data)..")")
-- obj:queueObjectLuaCommand(obj2id, "beamstate.exportCouplerData(" .. tostring(obj2nodeId) .. ", " .. serialize(data) .. ")")
-- M.updateRemoteElectrics = updateRemoteElectrics
sendExportCouplerData(obj2id, obj2nodeId, data)
end
local breakGroups = type(n.breakGroup) == "table" and n.breakGroup or {n.breakGroup}
for _, g in pairs(breakGroups) do
couplerBreakGroupCache[g] = couplerBreakGroupCacheOrig[g]
end
--print(string.format("coupler attached %s.%s->%s.%s", obj:getId(),nodeId,obj2id, obj2nodeId))
if objectId < obj2id then
obj:queueGameEngineLua(string.format("onCouplerAttached(%s,%s,%s,%s)", objectId, obj2id, nodeId, obj2nodeId))
end
end
Callers
@/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/couplings/fifthwheel.lua
local function onCouplerAttached(nodeId, obj2id, obj2nodeId, attachForce)
if nodeId == fifthwheelNodeCid then
@/lua/vehicle/beamstate.lua
if objectId < obj2id then
obj:queueGameEngineLua(string.format("onCouplerAttached(%s,%s,%s,%s)", objectId, obj2id, nodeId, obj2nodeId))
end
@/lua/ge/extensions/core/vehicles.lua
local function onCouplerAttached(objId1, objId2, nodeId, obj2nodeId)
table.insert(M.attachedCouplers, {objId1, objId2, nodeId, obj2nodeId})
@/lua/ge/extensions/flowgraph/modules/vehicleModule.lua
function C:onCouplerAttached(objId1, objId2, nodeId, obj2nodeId)
self.couplings[objId1][objId2] = true
@/lua/ge/extensions/core/trailerRespawn.lua
local function onCouplerAttached(objId1, objId2, nodeId, obj2nodeId)
if objId1 == objId2 then return end
@/lua/vehicle/controller/hydraulics/hydraulicTrailerFeet.lua
local function onCouplerAttached(nodeId, obj2id, obj2nodeId)
if obj:getId() ~= obj2id then
@/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/main.lua
function onCouplerAttached(objId1, objId2, nodeId, obj2nodeId)
if objId1 ~= objId2 and settings.getValue("couplerCameraModifier", false) then
@/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/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/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/ge/extensions/career/modules/delivery/vehicleTasks.lua
--[[
local function onCouplerAttached(objId1, objId2, nodeId, obj2nodeId)
for _, taskData in ipairs(vehicleTasks) do
@/lua/vehicle/controller/controllerTemplate.lua
-- local function onCouplerAttached(nodeId, obj2id, obj2nodeId)
-- end
@/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/vehicle/controller/advancedCouplerControl.lua
local function onCouplerAttached(nodeId, obj2id, obj2nodeId, attachForce)
local couplerIndex = couplerGroup.couplerNodeIdLookup[nodeId]
@/lua/vehicle/controller/linearActuators/linearActuatorTrailerFeet.lua
local function onCouplerAttached(nodeId, obj2id, obj2nodeId)
if obj:getId() ~= obj2id and nodeId == couplerNodeId then
@/lua/ge/extensions/core/couplerCameraModifier.lua
local function onCouplerAttached(objId1_, objId2_)
if checkForTrailer(objId1_, objId2_) == true 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/vehicle/controller/trailerFeet.lua
local function onCouplerAttached(nodeId, obj2id, obj2nodeId)
if obj:getId() ~= obj2id then