VE Lua Documentation

Press F to search!

importCouplerData

Definition


-- @/lua/vehicle/beamstate.lua:489

-- called by the host that provides the electrics
local function importCouplerData(nodeId, data)
  --print(obj:getId() .. "<-importCouplerData(" .. nodeId .. "," .. dumps(data) .. ")")

  --If we are not connected anymore to the vehicle that this data came from, we need to ignore it.
  --This is very important as the coupler detach can be broadcasted _before_ queued data from the other vehicle can reach this one.
  --In some systems that do cleanup work in the detach event, this stray data can cause havoc, so here we ignore it.
  if not attachedCouplers[nodeId] then
    table.clear(recievedElectrics)
    return
  end

  if data.electrics then
    table.insert(recievedElectrics, data.electrics)
  end
  if data.inputs then
    for k, v in pairs(data.inputs) do
      input.event(k, v, 2)
    end
  end
end

Callers

@/lua/vehicle/beamstate.lua
local function importCouplerData(nodeId, data)
  --print(obj:getId() .. "<-importCouplerData(" .. nodeId .. "," .. dumps(data) .. ")")
      end
      obj:queueObjectLuaCommand(coupler.obj2id, string.format("beamstate.importCouplerData(%s, %s)", coupler.obj2nodeId, serialize(data)))
    end