Board index FlightGear Development Nasal

How to add sort of addon?  Topic is solved

Nasal is the scripting language of FlightGear.

How to add sort of addon?

Postby VaLeo » Sat Nov 22, 2014 11:39 am

Hi all.

Say, I made some nasal function for UFO and key binding for it. Now I want to share it, but with most simple way for users - no hand-edit and no diff files.
It may be another aircraft - full copy of that UFO with another name - like AFAIR FG camera assistant.
But can I add couple files to UFO folder, and FG pick up it automagically? For example, a new -set.xml that somehow <include> original -set.xml?

Nasal file I can add to fgdata/Nasal folder and it loads at the start (?), but how can I deal with key bindings?

Or may be there is more elegant solution?
VaLeo
 
Posts: 186
Joined: Wed Nov 29, 2006 10:00 am
Location: Ukraine, Dnipropetrovsk
Version: GIT
OS: Debian 7

Re: How to add sort of addon?  

Postby Hooray » Sat Nov 22, 2014 2:05 pm

Unfortunately, there still is no dedicated "modding" or "addon" framework - however, all required building blocks are definitely there.
Usually, people will just use what works for them, without coming up with a framework for extending the simulator in a seamless fashion.
Like you said, adding a custom -set.xml file is certainly a simple workaround. Equally, you can have custom config/preferences loaded as an overlay by fgfs.
I don't know enough about keyboard/joystick bindings - if those can be reloaded at run-time, you can probably use just Nasal. If they cannot be re-loaded, it's an issue in my opinion, and you should file a feature request - in the meantime, you can use the method you suggested, i.e. including PropertyList files is pretty simple.
Likewise, you could have a "loader.nas" script in $FG_ROOT/Nasal that can load XML-based addons, i.e. simply by doing the equivalent of this:
Code: Select all
foreach(var file; files)
io.load_nasal(file);


That can be trivially done with XML files, too - by using io.read_properties().

Historically, FlightGear tends to re-invent the wheel more often than not unfortunately - but adopting a package/plugin framework would definitely make sense. While we can certainly proceed without one, the outcome is likely to be hugely incompatible and cause a ton of chaos - once you think about just how many features were/are developed as "addons", some more attention should be given to such considerations and requirements (bombable, advanced weather, fgcamera, tutorials etc)

Subject: Alternative camera control
Hooray wrote:The question is how far we'd want to go with something like this - because at some point, it would make more sense to adopt an existing package management system that is multi-platform and open source (e.g. pacm or miniconda). Otherwise, most of the building blocks for a simple package manager are already available to Nasal, i.e. http bindings and SGPath wrappers to download stuff into $FG_HOME and install stuff there. Even though it would probably make sense to also expose zlib (i.e. for extracting compressed archives). Metadata for package names, dependencies, URLs and version/description info could be provided via existing PropertyList XML files. So there's very little missing to pull this off, and a simple prototype for an existing addon, like FGCamera, should be fairly straightforward to build - it's mainly a matter of integrating existing technologies properly, and exposing them first to scripting space.
But most of the infrastructure is already available, i.e. was implemented for installing aircraft and managing scenery via TerraSync.

And particularly pacm is looking pretty good actually.
However, historically, the project tends to "re-invent the wheel" more often than not ... :?
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11312
Joined: Tue Mar 25, 2008 8:40 am

Re: How to add sort of addon?

Postby VaLeo » Sat Nov 22, 2014 10:00 pm

Hooray wrote in Sat Nov 22, 2014 2:05 pm:adding a custom -set.xml file is certainly a simple workaround.


Thanks for reply!

I tried make *-set.xml looking at dhc6F-set.xml. And it work like a charm!
Keybindings, dialogs, nasal - all worked with added few files to git UFO.

/thread
VaLeo
 
Posts: 186
Joined: Wed Nov 29, 2006 10:00 am
Location: Ukraine, Dnipropetrovsk
Version: GIT
OS: Debian 7

Re: How to add sort of addon?

Postby Hooray » Sun Nov 23, 2014 10:08 am

from a structural standpoint, I'd suggest to look at the bluebird - it's basically the "role model" when it comes to reusing existing XML files and supporting different features/fg versions
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11312
Joined: Tue Mar 25, 2008 8:40 am


Return to Nasal

Who is online

Users browsing this forum: No registered users and 3 guests