Skip to content

Context objects ​

Sectors API ​

Access via sectors object in onTick context.

sectors.currentOf(callsign) ​

Get current sector of aircraft.

Returns: string | undefined

Example:

javascript
onTick(({ sectors, traffic }) => {
  traffic.all().forEach(ac => {
    const sector = sectors.currentOf(ac.cs);
    log(`${ac.cs} in sector ${sector}`);
  });
});

Fixes API ​

Access via fixes object in onTick context.

fixes.get(fixName) ​

Get waypoint by name.

Returns: {name: string, pos: Vec2} | undefined

Example:

javascript
onTick(({ fixes, traffic }) => {
  const kmart = fixes.get("KMART");
  if (kmart) {
    log(`KMART at ${kmart.pos.x.toFixed(1)}, ${kmart.pos.y.toFixed(1)}`);

    // Calculate distance from aircraft
    const ac = traffic.byCallsign("AAL123");
    if (ac) {
      const dist = distance(ac.pos, kmart.pos);
      log(`Distance to KMART: ${dist.toFixed(1)}nm`);
    }
  }
});

Procedures API ​

Access SID/STAR procedure data via the procedures object in onTick context. This lets scripts look up any procedure in the airspace to see its waypoints, altitude constraints, and speed constraints.

procedures.getSID(id) ​

Look up a SID by procedure name.

Parameters:

  • id: string - Procedure ID (e.g., 'DEEZZ5')

Returns: Procedure | null

procedures.getSTAR(id) ​

Look up a STAR by procedure name.

Parameters:

  • id: string - Procedure ID (e.g., 'PARCH4')

Returns: Procedure | null

procedures.get(id) ​

Look up a procedure by name (checks both SIDs and STARs).

Returns: Procedure | null

procedures.allSIDs() / procedures.allSTARs() ​

Get all SIDs or STARs in the current airspace.

Returns: Procedure[]

Example:

javascript
onTick(({ procedures }) => {
  // Look up a STAR to see its constraints
  const parch4 = procedures.getSTAR('PARCH4');
  if (parch4) {
    log(`${parch4.id}: ${parch4.waypoints.join(' - ')}`);
    for (const [fix, alt] of Object.entries(parch4.altitudeConstraints)) {
      log(`  ${fix}: ${alt.type} ${alt.alt1}ft`);
    }
  }

  // List all STARs available in this airspace
  const stars = procedures.allSTARs();
  log(`${stars.length} STARs available`);
});

Example scripts

The sim includes loadable example scripts demonstrating procedure management. Select "STAR management" or "Arrival sequencing with procedures" from the script dropdown.