VE Lua Documentation

Press F to search!

sendTracking

Definition


-- @/lua/vehicle/mapmgr.lua:104
local function sendTracking()
  if M.signalsData then
    local lastMailboxVersion = obj:getLastMailboxVersion("trafficSignalUpdates")
    if currentMailboxVersion ~= lastMailboxVersion then
      currentMailboxVersion = lastMailboxVersion
      updateSignals(lpack.decode(obj:getLastMailbox("trafficSignalUpdates")))
    end
  end

  local objCols = M.objectCollisionIds
  table.clear(objCols)
  obj:getObjectCollisionIds(objCols)

  if electrics.values.horn ~= 0 then states.horn = electrics.values.horn end
  if electrics.values.lightbar ~= 0 then states.lightbar = electrics.values.lightbar end
  if electrics.values.hazard_enabled ~= 0 then states.hazard_enabled = electrics.values.hazard_enabled end
  if electrics.values.ignitionLevel == 0 or electrics.values.ignitionLevel == 1 then states.ignitionLevel = electrics.values.ignitionLevel end

  buf:reset():putf('map.objectData(%s,%s,%s,', objectId, playerInfo.anyPlayerSeated, math.floor(beamstate.damage))

  -- add states to the buffer if they exist
  if next(states) then
    buf:put('{')
    for k, v in pairs(states) do
      buf:putf('[%q]=%s,', k, v)
    end
    buf:put('}')
  else
    buf:put('nil')
  end

  -- add object collisions to the buffer if they exist
  if objCols[1] then
    buf:put(',{')
    for i = 1, #objCols do buf:putf('[%s]=1,', objCols[i]) end
    buf:put('}')
  end

  buf:put(')')

  obj:queueGameEngineLua(buf)

  table.clear(states)
end

Callers

@/lua/vehicle/main.lua
  sensors.updateGFX(dtSim) -- must be before input and ai
  mapmgr.sendTracking() -- must be before ai
  wheels.updateGFX(dtSim)