2022-08-13 23:19:24 +08:00
|
|
|
#
|
|
|
|
# Aerotow Everywhere - Add-on for FlightGear
|
|
|
|
#
|
|
|
|
# Written and developer by Roman Ludwicki (PlayeRom, SP-ROM)
|
|
|
|
#
|
|
|
|
# Copyright (C) 2022 Roman Ludwicki
|
|
|
|
#
|
|
|
|
# Aerotow Everywhere is an Open Source project and it is licensed
|
|
|
|
# under the GNU Public License v3 (GPLv3)
|
|
|
|
#
|
|
|
|
|
|
|
|
var unload = func(addon) {
|
|
|
|
# This function is for addon development only. It is called on addon
|
|
|
|
# reload. The addons system will replace setlistener() and maketimer() to
|
|
|
|
# track this resources automatically for you.
|
|
|
|
#
|
|
|
|
# Listeners created with setlistener() will be removed automatically for you.
|
|
|
|
# Timers created with maketimer() will have their stop() method called
|
|
|
|
# automatically for you. You should NOT use settimer anymore, see wiki at
|
|
|
|
# http://wiki.flightgear.org/Nasal_library#maketimer.28.29
|
|
|
|
#
|
|
|
|
# Other resources should be freed by adding the corresponding code here,
|
|
|
|
# e.g. myCanvas.del();
|
2022-08-16 09:27:37 +08:00
|
|
|
|
|
|
|
aerotow.uninit();
|
2022-08-13 23:19:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var main = func(addon) {
|
|
|
|
print("Aerotow Everywhere add-on initialized from path ", addon.basePath);
|
|
|
|
|
|
|
|
loadExtraNasalFiles(addon);
|
|
|
|
|
2022-08-21 04:14:24 +08:00
|
|
|
createDirectories(addon);
|
2022-08-21 03:49:31 +08:00
|
|
|
|
2022-08-19 08:36:36 +08:00
|
|
|
aerotow.init(addon);
|
2022-08-13 23:19:24 +08:00
|
|
|
}
|
|
|
|
|
2022-08-16 09:27:37 +08:00
|
|
|
#
|
|
|
|
# Load extra Nasal files in main add-on directory
|
|
|
|
#
|
2022-08-19 08:36:36 +08:00
|
|
|
# addon - Addob object
|
|
|
|
#
|
2022-08-13 23:19:24 +08:00
|
|
|
var loadExtraNasalFiles = func (addon) {
|
2022-08-19 08:36:36 +08:00
|
|
|
var modules = [
|
2022-08-21 19:10:42 +08:00
|
|
|
"nasal/timer",
|
2022-08-19 08:36:36 +08:00
|
|
|
"nasal/aircraft",
|
|
|
|
"nasal/message",
|
|
|
|
"nasal/dialogs/route",
|
|
|
|
"nasal/dialogs/thermal",
|
|
|
|
"nasal/flight-plan",
|
|
|
|
"nasal/scenario",
|
2022-09-09 09:48:20 +08:00
|
|
|
"nasal/io/waypoint",
|
2022-08-19 09:39:09 +08:00
|
|
|
"nasal/io/flight-plan-writer",
|
2022-08-21 03:49:31 +08:00
|
|
|
"nasal/aerotow",
|
2022-08-19 08:36:36 +08:00
|
|
|
"aerotow",
|
|
|
|
];
|
|
|
|
|
|
|
|
foreach (var scriptName; modules) {
|
2022-08-13 23:19:24 +08:00
|
|
|
var fileName = addon.basePath ~ "/" ~ scriptName ~ ".nas";
|
|
|
|
|
2022-08-19 08:36:36 +08:00
|
|
|
if (io.load_nasal(fileName, "aerotow")) {
|
2022-08-16 09:27:37 +08:00
|
|
|
print("Aerotown Add-on module \"", scriptName, "\" loaded OK");
|
|
|
|
}
|
2022-08-13 23:19:24 +08:00
|
|
|
}
|
|
|
|
}
|
2022-08-21 03:49:31 +08:00
|
|
|
|
|
|
|
#
|
|
|
|
# Create all needed directories.
|
|
|
|
#
|
|
|
|
var createDirectories = func (addon) {
|
|
|
|
# Create $FG_HOME/Export/Addons/org.flightgear.addons.Aerotow directory
|
|
|
|
addon.createStorageDir();
|
|
|
|
|
|
|
|
# Create /AI/FlightPlans/ directory in $FG_HOME/Export/Addons/org.flightgear.addons.Aerotow/
|
|
|
|
# User has to add the path as --data=$FG_HOME/Export/Addons/org.flightgear.addons.Aerotow
|
|
|
|
# Then the FG will be able to read flight plan file
|
|
|
|
var path = os.path.new(addon.storagePath ~ "/AI/FlightPlans/dummy-file.txt");
|
|
|
|
path.create_dir();
|
|
|
|
|
|
|
|
# Create /route-saves directory in $FG_HOME/Export/Addons/org.flightgear.addons.Aerotow/
|
|
|
|
path = os.path.new(addon.storagePath ~ "/" ~ aerotow.RouteDialog.ROUTE_SAVES_DIR ~ "/dummy-file.txt");
|
|
|
|
path.create_dir();
|
|
|
|
}
|