API ReferenceGE Extensionsui
UI Navigation / Map
Provides navigation map data, routing, POI, and real-time object tracking for the UI.
Provides navigation map data, routing, POI, and real-time object tracking for the UI.
Overview
ui_uiNavi is the main navigation extension. It supplies the minimap/bigmap with road nodes, tracked objects (vehicles/camera), spawn points, points of interest, routing, and bus stops. Updated every GUI frame.
Extension path: lua/ge/extensions/ui/uiNavi.lua
Exports (M)
| Function | Signature | Description |
|---|---|---|
onGuiUpdate | (dtReal, dtSim, dtRaw) | Pushes tracked objects and player position to UI each frame. |
onVehicleSwitched | (oid, nid) | Hook for vehicle switch (currently no-op). |
requestUIDashboardMap | () → table | Returns full map data (terrain tiles, POI, road nodes) and triggers NavigationMap. |
requestVehicleDashboardMap | (dashboard, initmap, vehId) | Sends map data to a vehicle's JS dashboard. |
findClosestRoad | (x, y, z) → node | Finds the closest road node to world coordinates. |
route_start | (wp, pos) | Starts ground-marker route to waypoint. |
route_end | () | Ends the active route. |
route_requestStatus | (oldPos, newPos) | Updates route, checks arrival (< 50m). |
planRoute | (posX, posY) | Plans a route between two points, triggers RoutePlanned. |
getBusStops | () → table | Returns bus stop positions (merged nearby stops). |
getSpawnpoints | () → table | Returns spawn sphere positions + metadata. |
getPointsOfInterest | () → table | Returns POI from PointOfInterestSet. |
requestPoi | () | Triggers MapPointsOfInterest guihook. |
getMissions | () → table | Returns current mission markers. |
setMissions | (m) | Sets mission markers and triggers MapMissions. |
requestMissions | () | Triggers MapMissions guihook. |
onExtensionLoaded | () | Hook - initialization on extension load. |
Internals
Real-Time Object Tracking (onGuiUpdate)
Each frame:
- Iterates
map.getTrackedObjects()to get vehicle positions, rotations, speeds. - If no player vehicle or in free camera, falls back to camera position.
- Sends
NavigationMapUpdatewith{controlID, objects}.
Uses a table pool (mapObjectsTblPool) to avoid per-frame allocations.
Road Nodes
getNodes()- Full node data with links, filtered byhiddenInNavi.getNodesMinified()- Renamed integer keys, 2D positions only, smaller payload for UI.
Minimap Data
requestUIDashboardMap assembles:
- Terrain tiles from level info or
TerrainBlockfallback - Points of interest
- Road nodes
Routing
route_start(wp, pos)- Setscore_groundMarkerspath and destination.route_update(oldPos, newPos)- Recalculates path, triggersRouteReachedDestinationwithin 50m.route_end()- Clears ground markers and triggersRouteEnded.
Bus Stops
getBusStops() finds BeamNGTrigger objects of type busstop, merges nearby pairs (< 70m distance) into single points.
Lua Examples
-- Request full map data for UI
extensions.ui_uiNavi.requestUIDashboardMap()
-- Start a route
local wp = map.findClosestRoad(vec3(100, 200, 0))
extensions.ui_uiNavi.route_start(wp, {100, 200, 0})
-- End the route
extensions.ui_uiNavi.route_end()Hooks Triggered
| Hook | Payload | When |
|---|---|---|
NavigationMapUpdate (guihook) | {controlID, objects} | Every GUI frame |
NavigationMap (guihook) | {terrainTiles, poi, nodes} | Map data requested |
RouteUpdate (guihook) | route data | Route recalculated |
RouteReachedDestination (guihook) | - | Player within 50m of destination |
RouteEnded (guihook) | - | Route cancelled/completed |
RoutePlanned (guihook) | route | planRoute called |
MapMissions (guihook) | missions | Mission markers sent |
MapPointsOfInterest (guihook) | POI list | POI requested |
Additional Exports
The following exports are available but not yet documented in detail:
M.findClosestRoadM.getBusStopsM.getMissionsM.getPointsOfInterestM.getSpawnpointsM.onExtensionLoadedM.onGuiUpdateM.onVehicleSwitchedM.planRouteM.requestMissionsM.requestPoiM.requestUIDashboardMapM.requestVehicleDashboardMapM.route_endM.route_requestStatusM.route_startM.setMissions