-
Notifications
You must be signed in to change notification settings - Fork 0
03 How to use it
Assuming the Framework project is in the /framework directory, copy the contents of this framework's /framework/addon-main.nas file and paste it into your add-on's /addon-main.nas file and make the following modifications:
- Modify the entry
io.include('nasal/Application.nas');by adding the directory where you placed the Framework, e.g.:io.include('framework/nasal/Application.nas');. - Use the appropriate hooks (see Application hooks).
- Additionally in the
.gitignorefile, add a line with the.enventry.
Now your /addon-main.nas file (your add-on's, not the framework's) should contain a main function where is using Application class with some hooks functions to fill in. Each hook function is optional, and if you don't need one, you can remove it entirely. If necessary, the /framework/addon-main.nas file will contain the entire template from which you can copy.
Here you can specify vector as a list of Nasal files to be excluded from loading (by default the framework automatically loads almost everything). Files must be specified with a path relative to the add-on's root directory and must start with / (where / represents the add-on's root directory). This can be useful if you don't use a certain Nasal file, but you also don't want to remove it from your project.
This function will be called by the framework upon initialization. Here, you can instantiate your objects, but not those related to Canvas. This could be, for example, some logic in your add-on.
This function will be called by the framework when it's time to initialize the Canvas objects ─ this will happen 3 seconds after hookOnInit(). Here you can instantiate your windows in Canvas. Why this is needed for Canvas is explained in Deferring Canvas loading.
A very specific function to keep the given menu items disabled after loading the Canvas (see Deferring Canvas loading).
The /addon-main.nas file may also contain an unload function, which is run by FlightGear when reloading the add-on's Nasal files. For this restart to be successful, you should free all resources you created in hookOnInit or hookOnInitCanvas here.