Skip to content

05 .env file

PlayeRom edited this page Nov 17, 2025 · 1 revision

To add certain developer features without modifying the add-on's source code, you can use the .env file. To do this, copy the .env.example file and rename it to .env. Make sure that you have a line with the .env file in your .gitignore file so that Git will not consider this file for commit.

NOTE: Do not commit the .env file to git! If you do, the end user may have developer options enabled, which you should avoid.

You can use the following variables in the .env file.

MY_LOG_LEVEL

This variable is used when logging various things to the console or to the fgfs.log file using the Log class (see the nasal/Dev/Log.nas file), which is a wrapper for the logprint() function. The built-in Nasal function logprint() takes the "log-level" as its first parameter. This is where the value of the MY_LOG_LEVEL variable is using. The possible values you can assign to MY_LOG_LEVEL are: LOG_ALERT, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_BULK. If you set LOG_ALERT, the logs will always be displayed; if you set another value, such as LOG_INFO, you will also need to run FlightGear with the command line option --log-level=info to see the logs. By default, the variable MY_LOG_LEVEL is set to LOG_INFO.

DEV_MODE

Setting this option to true will enable the use of the variables described below. Additionally, it will set the global variable g_isDevMode to true, which you can use in your code to condition code that should only run in a development purposes.

RELOAD_MENU

Setting this variable to true will add a "Dev Reload" item to the add-on menu, allowing you to reload the add-on's Nasal files without having to restart the simulator. In order for the menu to be added, you must also set DEV_MODE=true and add the basic structure of the add-on menu using the /addon-menubar-items.xml file.

RELOAD_MULTIKEY_CMD

Here you can define a multi-key command, i.e. a sequence of keys that must be entered to reload the Nasal files of the add-on. This is a replacement for RELOAD_MENU when the add-on does not need its own menu.

Commands must be at least 3 characters long. It is recommended to start them with the characters "Ya".

  • "Y" is used in FlightGear and starts the sequence for the "Development functions",
  • "a" from "add-ons" (not used in FlightGear),
  • "r" from "reload"
  • and then add your own character.

This key sequence can only contain alphanumeric characters and cannot start with a number. This multi-key command will have no hint that you are following the correct key combination. This option requires DEV_MODE to be set to true.

TEST_MULTIKEY_CMD

Here you can define a multi-key command, i.e. a sequence of keys that must be entered to run Nasal unit tests (files with the nut extension). All nut files must be located in the /tests directory directory (without any subdirectories).

Commands must be at least 3 characters long. It is recommended to start them with the characters "Ya".

  • "Y" is used in FlightGear and starts the sequence for the "Development functions",
  • "a" from "add-ons" (not used in FlightGear),
  • "t" from "test"
  • and then add your own character.

This key sequence can only contain alphanumeric characters and cannot start with a number. This multi-key command will have no hint that you are following the correct key combination. This option requires DEV_MODE to be set to true.

Complete disabling of .env

If you're not interested in this at all and don't want the add-on to load the Nasal classes associated with the .env file, you can disable this mechanism entirely. For this, in the /addon-main.nas file, in the main function, before calling Application.create(), add the entry Config.dev.useEnvFile = false;.

Clone this wiki locally