VE Lua Documentation

Press F to search!

sendDeviceTree

Definition


-- @/lua/vehicle/powertrain.lua:258

local function sendDeviceTree()
  if not playerInfo.firstPlayerSeated then
    return
  end

  local maxPower = 0
  local maxTorque = 0
  local devices = {}
  for _, d in pairs(powertrainDevices) do
    if d.parent.isFake then
      maxPower = max(maxPower, d.maxPower or 0)
      maxTorque = max(maxTorque, (d.maxTorque or 0) * (d.maxCumulativeGearRatio or 1))
    end
    local device = {
      type = d.visualType or d.type,
      modes = (d.availableModes and #d.availableModes > 1) and d.availableModes or nil,
      pos = d.visualPosition,
      children = {}
    }
    if d.children then
      local inverseMap = {}
      for _, d1 in pairs(d.children) do
        inverseMap[d1.inputIndex] = d1.name
      end
      for i, _ in pairs(d.outputPorts) do
        table.insert(device.children, inverseMap[i])
      end
    end
    device.currentMode = (v.availableModes and #v.availableModes > 1) and v.mode or nil
    devices[d.name] = device
  end

  --dump(devices)
  guihooks.trigger("PowertrainDeviceTreeChanged", {devices = devices, maxPower = maxPower, maxTorque = maxTorque})
end

Callers

@/lua/vehicle/powertrain.lua

    sendDeviceTree()
  end
  calculateTreeInertia()
  sendDeviceTree()
@/ui/modules/apps/PowerTrainDebug/app.js
      })
      bngApi.activeObjectLua('powertrain.sendDeviceTree()')
      $scope.$on('VehicleChange', function (event, data) {
        bngApi.activeObjectLua('powertrain.sendDeviceTree()')
      })
      $scope.$on('VehicleFocusChanged', function (event, data) {
        bngApi.activeObjectLua('powertrain.sendDeviceTree()')
      })