Nasal library: Difference between revisions

1,381 bytes added ,  12 November 2023
Add findCommByFrequencyMHz()
(Add findCommByFrequencyMHz())
Line 1,455: Line 1,455:
}}
}}


===findFixesByID()===
===findCommByFrequencyMHz()===
findCommByFrequencyMHz([pos, ]freq[, type]);
[[sourceforge:p/flightgear/flightgear/ci/next/tree/src/Scripting/NasalPositioned.cxx#l1547|source]]
 
Returns a <code>comm</code> ghost object for a station matching a given frequency. If there is more than one station with that frequency, the nearest station is returned.
pos
 
: Optional position to search around. If not given, the aircraft's current position will be used. Can be one of:
:* An <code>airport</code>, <code>navaid</code>, <code>runway</code>, <code>taxiway</code>, <code>fix</code>, or <code>waypoint</code> ghost type
:* A hash with ''lat'' and ''lon'' members
:* A geo.Coord object
:* Two numbers separated by a comma, as if the function is taking three arguments. Example: <code>findCommByFrequencyMHz(lat, lon, freq, type);</code>.
; freq
: Frequency, in megahertz, of the station to search for.
; type
: This will narrow the search to station of a certain type. Defaults to "all." For the full list of accepted type arguments, see flightgear/src/Navaids/positioned.cxx (line 160)
'''Example'''
var com = findCommByFrequencyMHz(123.6);
print("ID: ", com.id); # prints info about the comm station
print("Name: ", com.name);
print("Latitude: ", com.lat);
print("Longitude: ", com.lon);
print("Type: ", com.type);
print("Frequency: ", sprintf("%.3f", com.frequency), " Mhz");
 
=== findFixesByID() ===
{{Nasal doc
{{Nasal doc
|syntax = findFixesByID([pos, ]id);
|syntax = findFixesByID([pos, ]id);
29

edits