Library globals

Library globals

The standard library for FlightGear Nasal code.

Sub-namespaces

Autopush

FailureMgr

addons

Initialize addons configured with --addon=foobar command line switch: - get the list of registered add-ons - load the addon-main.nas file of each add-on into namespace __addon[ADDON_ID]__ - call function main() from every such addon-main.nas with the add-on ghost as argument (an addons.Addon instance).

aircraft

This module provide basic functions and classes for use in aircraft specific Nasal context.

aurora

Aurora Borealis manager this runs once at startup to randomize Aurora appearance a little and otherwise simulates detailed Aurora evolution only when requested by the user

bits

SPDX-License-Identifier: GPL-2.0-or-later NOTE! This copyright does *not* cover user models that use these Nasal services by normal function calls - this is merely considered normal use of the code, and does *not* fall under the heading of "derived work." Copyright (C) 2008 by mfranz

canvas

checklist

Nasal functions for handling the checklists present under /sim/checklists

console

contrail

contrail calculator. Based on an approxmation to the "Appleman Chart" y = -0.077x2 + 2.7188x - 64.36

controls

debug

debug.nas -- debugging helpers ------------------------------------------------------------------------------ debug.dump(<variable>) ... dumps contents of variable to terminal; abbreviation for print(debug.string(v)) debug.local([<frame:int>]) ... dump local variables of current or given frame debug.backtrace([<comment:string>], [<dump:bool=1>], [<skip_level:int=0>]} ... writes backtrace (similar to gdb's "bt full) dump=0: only call stack dump=1 (default): with local variables skip_level: remove this many levels from call stack debug.proptrace([<property [, <frames>]]) ... trace property write/add/remove events under the <property> subtree for a number of frames. Defaults are "/" and 2 frames (of which the first one is incomplete). debug.tree([<property> [, <mode>]) ... dump property tree under property path or props.Node hash (default: root). If <mode> is unset or 0, use flat mode (similar to props.dump()), otherwise use space indentation debug.bt() ... abbreviation for debug.backtrace() debug.string(<variable>) ... returns contents of variable as string debug.attributes(<property> [, <verb>]) ... returns attribute string for a given property. <verb>ose is by default 1, and suppressed the node's refcounter if 0. debug.isnan() returns 1 if argument is an invalid number (NaN), 0 if it's a valid number, and nil in all other cases debug.benchmark(<label:string>, <func> [, <repeat:int> [, <output:vector>]]) ... runs function <repeat> times (default: nil) and prints total execution time in seconds, prefixed with <label>, while adding results to <output>, or returning the only result if <repeat> is nil. debug.benchmark_time(<func> [, <repeat:int> [, <output:vector>]]) ... like debug.benchmark, but returns total execution time and does not print anything. debug.rank(<list:vector> [, <repeat:int>]) ... sorts the list of functions based on execution time over <repeat> samples (default: 1). debug.print_rank(<result:vector>, <names:int>) ... prints the <result> of debug.rank with <names> (which can be a vector of [name, func] or [func, name], or a hash of name:func). debug.printerror(<err-vector>) ... prints error vector as set by call() debug.warn(<message>, <level>) ... generate debug message followed by caller stack trace skipping <level> caller levels (default: 0). debug.propify(<variable>) ... turn about everything into a props.Node debug.Probe class ... base class to collect stats; details below debug.Breakpoint class ... conditional backtrace; details below debug.addProbeToFunc(label, func) ... wraps a function with a probe debug.findFunctions(ns, recursive=0) ... find all functions in a hash (namespace) debug.addProbesToNamespace(ns, label="", recursive=0) ... combines findFunctions and addProbeToFunc CAVE: this file makes extensive use of ANSI color codes. These are interpreted by UNIX shells and MS Windows with ANSI.SYS extension installed. If the color codes aren't interpreted correctly, then set property /sim/startup/terminal-ansi-colors=0

dynamic_view

SPDX-License-Identifier: GPL-2.0-or-later NOTE! This copyright does *not* cover user models that use these Nasal services by normal function calls - this is merely considered normal use of the code, and does *not* fall under the heading of "derived work." Copyright (C) 2006-2008 by mfranz

earthview

Earthview orbital rendering

emesary

--------------------------------------------------------------------------- Title : EMESARY inter-object communication File Type : Implementation File Description : Provides generic inter-object communication. For an object to receive a message it : must first register with an instance of a Transmitter, and provide a Receive method : To send a message use a Transmitter with an object. That's all there is to it. References : http://chateau-logic.com/content/emesary-nasal-implementation-flightgear : http://www.chateau-logic.com/content/class-based-inter-object-communication : http://chateau-logic.com/content/emesary-efficient-inter-object-communication-using-interfaces-and-inheritance : http://chateau-logic.com/content/c-wpf-application-plumbing-using-emesary Author : Richard Harrison (richard@zaretto.com) Creation Date : 29 January 2016 Version : 4.8 Copyright © 2016 Richard Harrison Released under GPL V2 --------------------------------------------------------------------------- Classes in this file: Transmitter Notification Recipient ---------------------------------------------------------------------------*/

emesary_mp_bridge

--------------------------------------------------------------------------- Title : EMESARY multiplayer bridge File Type : Implementation File Description : Bridges selected emesary notifications over MP : To send a message use a Transmitter with an object. That's all there is to it. References : http://chateau-logic.com/content/emesary-nasal-implementation-flightgear Author : Richard Harrison (richard@zaretto.com) Creation Date : 04 April 2016 Version : 4.8 Copyright © 2016 Richard Harrison Released under GPL V2 ---------------------------------------------------------------------------*/

emexec

--------------------------------------------------------------------------- Title : Emesary based 'real time' module executive File Type : Implementation File Description : Uses Emesary notifications to permit Nasal subsystems to be invoked in : a controlled manner. : : Sends out a FrameNotification for each frame recipient can implement : workload reduction as appropriate based on skipping frames (2=half, : 4=quarter etc.) because some code can safely be run at quarter rate : (e.g. ~10hz). : : The developer should interleave slower rate modules to spread out : workload A frame is defined by the timer rate; which is usually the : maximum rate as determined by the FPS. : : This is an alternative to the timer based or explicit function calling : way of invoking aircraft systems. It has the advantage of using less : timers and remaining modular, as each aircraft subsytem can simply : register itself with the global transmitter to receive the frame : notification. See Also : https://wiki.flightgear.org/Nasal_Optimisation#Emesary_real_time_executive : F-15 and F-14 for examples of how to use this. Author : Richard Harrison (richard@zaretto.com) Creation Date : 4 June 2018 Copyright (C) 2018 Richard Harrison Released under GPL V2 ---------------------------------------------------------------------------*/

environment

environment.nas Nasal code for implementing environment-specific functionality.

events

events.nas - Generic objects for managing events Copyright (C) 2014 Anton Gomez Alvedro This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

frame_utils

--------------------------------------------------------------------------- Title : Frame Utils File Type : Implementation File Description : Objects related to frame processing Author : Richard Harrison (richard@zaretto.com) Creation Date : 05-05-2019 Version : 1.0 Copyright (C) 2019 Richard Harrison Released under GPL V2 ---------------------------------------------------------------------------*/

fuel

Fuel handling for the YASim FDM. Note that other FDMs (e.g. JSBSim) handle fuel within the FDM itself. Properties under /consumables/fuel/tank[n]: + level-lbs - Current fuel load. Can be set by user code. + selected - boolean indicating tank selection. + capacity-gal_us - Tank capacity Properties under /engines/engine[n]: + fuel-consumed-lbs - Output from the FDM, zeroed by this script + out-of-fuel - boolean, set by this code.

geo

geo functions ------------------------------------------------------------------------------------------------- geo.Coord class ------------------------------------------------------------------------------------------------- geo.Coord.new([<coord>]) ... class that holds and maintains geographical coordinates can be initialized with another geo.Coord instance SETTER METHODS: .set(<coord>) ... sets coordinates from another geo.Coord instance .set_lat(<num>) ... functions for setting latitude/longitude/altitude .set_lon(<num>) .set_alt(<num>) ..this is in meters .set_latlon(<num>, <num> [, <num>]) (altitude (meters) is optional; default=0) .set_x(<num>) ... functions for setting cartesian x/y/z coordinates .set_y(<num>) .set_z(<num>) .set_xyz(<num>, <num>, <num>) GETTER METHODS: .lat() .lon() ... functions for getting lat/lon/alt .alt() ... returns altitude in m .latlon() ... returns vector [<lat>, <lon>, <alt>] .x() ... functions for reading cartesian coords (in m) .y() .z() .xyz() ... returns vector [<x>, <y>, <z>] QUERY METHODS: .is_defined() ... returns whether the coords are defined .dump() ... outputs coordinates .course_to(<coord>) ... returns course to another geo.Coord instance (degree) .distance_to(<coord>) ... returns distance in m along Earth curvature, ignoring altitudes useful for map distance .direct_distance_to(<coord>) ... distance in m direct, considers altitude, but cuts through Earth surface .greatcircle_distance_to(<coord>, <coord>) ... returns distance to a great circle (in m along Earth curvature) defined by two points .horizon() ... returns distance to the horizon in m along Earth curvature, ignoring altitudes MANIPULATION METHODS: .apply_course_distance(<course>, <distance>) ... moves the coord distance in meters in course direction (true) ------------------------------------------------------------------------------------------------- geo.aircraft_position() ... returns current aircraft position as geo.Coord geo.viewer_position() ... returns viewer position as geo.Coord geo.click_position() ... returns last click coords as geo.Coord or nil before first click geo.tile_path(<lat>, <lon>) ... returns tile path string (e.g. "w130n30/w123n37/942056.stg") geo.elevation(<lat>, <lon> [, <top:10000>]) ... returns elevation in meter for given lat/lon, or nil on error; <top> is the altitude at which the intersection test starts geo.normdeg(<angle>) ... returns angle normalized to 0 <= angle < 360 geo.normdeg180(<angle>) ... returns angle normalized to -180 < angle <= 360 geo.put_model(<path>, <lat>, <lon> [, <elev:nil> [, <hdg:0> [, <pitch:0> [, <roll:0>]]]]); ... put model <path> at location <lat>/<lon> with given elevation (optional, default: surface). <hdg>/<pitch>/<roll> are optional and default to zero. geo.put_model(<path>, <coord> [, <hdg:0> [, <pitch:0> [, <roll:0>]]]); ... same as above, but lat/lon/elev are taken from a Coord object

glide_slope_tunnel

Draw 3 degree glide slope tunnel for the nearest airport's most suitable runway considering wind direction and runway size. Activate with --prop:sim/rendering/glide-slope-tunnel=1 or via Help menu

globals

Constants.

gui

Pop up a "tip" dialog for a moment, then remove it. The delay in seconds can be specified as the second argument. The default is 4 seconds. The third argument can be a hash with override values. Note that the tip dialog is a shared resource. If someone else comes along and wants to pop a tip up before your delay is finished, you lose. :)

input_helpers

io

Reads and returns a complete file as a string

jetways

jetways_edit

joystick

Joystick configuration library.

lag_adjust

local_weather

local_weather_auto_init

this routine checks whether the launcher has requested to auto-start AW we can't do this inside the AW namespace because that is only loaded on demand, and we want this at Nasal (re-)init, not at AW namespace loading

material

material dialog =============== Usage: material.showDialog(<path>, [<title>], [<x>], [<y>]); the path should point to a property "directory" (usually set in the aircraft's *-set.xml file) that contains any of (shininess|transparency|texture) and (diffuse|ambient|specular|emission), whereby the latter four are directories containing any of (red|green|blue|factor|offset). If <title> is omitted or nil, then the last path component is used as title. If <x> and <y> are undefined, then the dialog is centered. Example: <foo> <diffuse> <red>1.0</red> <green>0.5</green> <blue>0.5</blue> </diffuse> <transparency>0.5</transparency> <texture>bar.rgb</texture> </foo> material.showDialog("/sim/model/foo/", "FOO"); Of course, these properties are only used if a "material" animation references them via <*-prop> definition. Example: <animation> <type>material</type> <object-name>foo</object-name> <property-base>/sim/model/foo</property-base> <diffuse> <red-prop>diffuse/red</red-prop> <green-prop>diffuse/green</green-prop> <blue-prop>diffuse/blue</blue-prop> </diffuse> <transparency-prop>transparency</transparency-prop> <texture-prop>texture</texture-prop> </animation>

math

modules

SPDX-License-Identifier: GPL-2.0-or-later NOTE! This copyright does *not* cover user models that use these Nasal services by normal function calls - this is merely considered normal use of the code, and does *not* fall under the heading of "derived work."

mp_broadcast

A message based information broadcast for the multiplayer network. Copyright (C) 2008 - 2013 Anders Gidenstam (anders(at)gidenstam.org) This file is licensed under the GPL license version 2 or later.

multikey

SPDX-License-Identifier: GPL-2.0-or-later NOTE! This copyright does *not* cover user models that use these Nasal services by normal function calls - this is merely considered normal use of the code, and does *not* fall under the heading of "derived work." Copyright (C) 2008 by mfranz

multiplayer

Multiplayer =========== 1) Display chat messages from other aircraft to the screen using screen.nas 2) Display a complete history of chat via dialog. 3) Allow chat messages to be written by the user.

notifications

--------------------------------------------------------------------------- Title : EMESARY flightgear standardised notifications File Type : Implementation File Description : Messages that are applicable across all models and do not specifically relate to a single system : - mostly needed when using the mutiplayer bridge Author : Richard Harrison (richard@zaretto.com) Creation Date : 06 April 2016 Version : 4.8 Copyright � 2016 Richard Harrison Released under GPL V2 ---------------------------------------------------------------------------*/

orbital_target

simulation of a faraway orbital target (needs handover to spacecraft-specific code for close range) SPDX-License-Identifier: GPL-2.0-or-later NOTE! This copyright does *not* cover user models that use these Nasal services by normal function calls - this is merely considered normal use of the code, and does *not* fall under the heading of "derived work." Thorsten Renk 2016-2019

performance_monitor

prop_key_handler

Property Key Handler ------------------------------------------------------------------ This is an extension mainly targeted at developers. It implements some useful tools for dealing with internal properties if enabled (Menu->Debug->Configure Development Extensions). To use this feature, press the '/'-key, then type a property path (using the <TAB> key to complete property path elements if possible), or a search string ... Commands: <property>=<value><CR> -> set property to value <property><CR> -> print property and value to screen and terminal <property>* -> print property and all children to terminal <property>! -> add property to display list (reset list with /!) <property>: -> open property browser in this property's directory <string>? -> print all properties whose path or value contains this string <string># -> add listener for property and all child properties (cancel all listeners with /#) Keys: <CR> ... carriage return or enter, to confirm some operations <TAB> ... complete property path element (if possible), or cycle through available elements <Shift-TAB> ... like <TAB> but cycles backwards <CurUp>/<CurDown> ... switch back/forth in the history <Escape> ... cancel the operation <Shift-Backspace> ... remove last whole path element Colors: white ... syntactically correct path to not yet existing property green ... path to existing property red ... broken path syntax (e.g. "/foo*bar" ... '*' not allowed) yellow ... while typing in value for a valid property path magenta ... while typing search string (except when first character is '/') For example, to open the property browser in /position/, type '/p<TAB>:'.

props

Node class definition. The class methods simply wrap the low level extension functions which work on a "ghost" handle to a SGPropertyNode object stored in the _g field. Not all of the features of SGPropertyNode are supported. There is no support for ties, obviously, as that wouldn't make much sense from a Nasal context. The various get/set methods work only on the local node, there is no equivalent of the "relative path" variants available in C++; just use node.getNode(path).whatever() instead.

redout

Damped G value - starts at 1.

route_manager

SPDX-License-Identifier: GPL-2.0-or-later NOTE! This copyright does *not* cover user models that use these Nasal services by normal function calls - this is merely considered normal use of the code, and does *not* fall under the heading of "derived work." Copyright (C) 2012-202 by James Turner

scenery

Support tools for multiplayer enabled scenery objects. Copyright (C) 2011 - 2013 Anders Gidenstam (anders(at)gidenstam.org) This file is licensed under the GPL license version 2 or later.

screen

on-screen displays ==============================================================================

seaport

std

SPDX-License-Identifier: GPL-2.0-or-later NOTE! This copyright does *not* cover user models that use these Nasal services by normal function calls - this is merely considered normal use of the code, and does *not* fall under the heading of "derived work."

string

tanker

--------------------------------------------------------------------------------------------------

towing

track_target

This is a small script that adjusts autopilot target values to track (fly in formation with) an AI or Multiplayer aircraft.

tutorial

video

print("A");

view

view.nas Nasal code for implementing view-specific functionality.

volcano

volcano management routines Thorsten Renk 2017

weather_scenario

find a weather scenario by it's <name> element returns /environment/weather-scenarios/scenario[name=$name]

wildfire

A cellular automaton forest fire model with the ability to spread over the multiplayer network. Copyright (C) 2007 - 2012 Anders Gidenstam (anders(at)gidenstam.org) This file is licensed under the GPL license version 2 or later.

windsock

Windsock turbulence animation