Board index FlightGear Development Nasal

Lack of documentation (?)

Nasal is the scripting language of FlightGear.

Lack of documentation (?)

Postby Thorsten » Thu Jul 15, 2010 8:00 am

A collection of topics I've come across which is not covered in the Nasal documentation I know of (Wiki and links given there) and which I had to work out by trial and error (which doesn't make me the ideal person to write any documentation, because I don't really understand why something works and something else not):

* generation and use multiple-indexed arrays

* the usage of props.nas: Basically, many function like *.getNode("node", arg) can be called with an option arg, but it's somewhat unclear what the option does or what it can be. Sometimes it's a flag to treat non-existing nodes, for *.getChild it is the index of the required child. I don't think I have ever seen what *.clearValue actually does.

* the handling of sparse arrays in the property tree from Nasal: If I have an array x[0], x[4], x[6] in the tree, a *.getChildren call will give me a Nasal array n[0],n[1],n[2], i.e. the indexing is changed if it was sparse before - that's actually useful to know...

* a general guide what works fast and what works slow - it took me a while to figure out that *.getChildren() is very slow for large vectors for example. Hooray keeps reminding me that *.getNode("node).getValue() is faster than getprop() - I wonder how many other things like this I simply do not know

* spawning models in Nasal by either geo.put_model(), writing into /models/ in the tree or other(?) methods
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Lack of documentation (?)

Postby zakalawe » Thu Jul 15, 2010 8:42 am

All good questions, and many I'd like an answer to. Some I can answer by reading the C++ code, in combination with the Nasal/ scripts; for example the underlying property code explains why getNode().getValue() is faster than getprop, and I can probably find out what the optional arguments do.

The Nasal documentation on the Wiki isn't very well organised: this page: http://wiki.flightgear.org/index.php/Nasal_scripting_language is quite extensive, but should probably be broken into a 'core language' page and some separate pages for the FlightGear specific extensions.

There's a Nasal 'style guide' that is basically empty, I'd much rather see collection of 'common problems and solutions' page, the current 'Nasal FAQ' on the wii is more about the language design, than helping people achieve specific things.
zakalawe
 
Posts: 1259
Joined: Sat Jul 19, 2008 5:48 pm
Location: Edinburgh, Scotland
Callsign: G-ZKLW
Version: next
OS: Mac

Re: Lack of documentation (?)

Postby Thorsten » Thu Jul 15, 2010 8:50 am

Just to clarify - I'm not currently stuck with any of these and I know a working solution in every case (although I don't always understand it...), but I think in general it would be a nice idea to add such issues to the documentation. I would in principle do it, but given my half-knowledge, it may not be such a clever idea.

A 'common problems and solutions' page sounds neat 8)
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Lack of documentation (?)

Postby Hooray » Thu Jul 15, 2010 6:14 pm

Thorsten wrote:A collection of topics I've come across which is not covered in the Nasal documentation I know of (Wiki and links given there) and which I had to work out by trial and error (which doesn't make me the ideal person to write any documentation, because I don't really understand why something works and something else not):


What could already be done now, is to create stubs for the corresponding sections - or simply headlines without contents.
I think we have here some pretty good suggestions about how to improve the Nasal documentation. So I will look into this, if noone beats me to it.
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Lack of documentation (?)

Postby mgma3032 » Sun Jan 12, 2020 6:40 am

hello I want to learn nasal but dont find enough information, where should I look for this? thanks,,,
mgma3032
 
Posts: 4
Joined: Tue Jan 07, 2020 12:41 am

Re: Lack of documentation (?)

Postby Necolatis » Sun Jan 12, 2020 6:44 am

http://wiki.flightgear.org/Nasal_scripting_language

Look in the info boxes on the right side for much more.
"Airplane travel is nature's way of making you look like your passport photo."
— Al Gore
User avatar
Necolatis
 
Posts: 2233
Joined: Mon Oct 29, 2012 1:40 am
Location: EKOD
Callsign: Leto
IRC name: Neco
Version: 2020.3.19
OS: Windows 10

Re: Lack of documentation (?)

Postby Hooray » Sun Jan 12, 2020 11:37 am

mgma3032 wrote in Sun Jan 12, 2020 6:40 am:hello I want to learn nasal but dont find enough information, where should I look for this? thanks,,,



you should be able to run FlightGear, the next steps are:


These two are ways to easily write, test and run your code inside FlightGear, without having to edit/write any files.

To see if everything works as expected, try this: http://wiki.flightgear.org/Nasal_Hello_World


Once you comfortable writing Nasal code, you can also use an external editor: http://wiki.flightgear.org/Howto:Syntax ... _for_Nasal

There are different ways to create new modules:

http://wiki.flightgear.org/Howto:Create ... sal_module
http://wiki.flightgear.org/Howto:Write_ ... s_in_Nasal
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: 12707
Joined: Tue Mar 25, 2008 9:40 am
Pronouns: THOU

Re: Lack of documentation (?)

Postby jsb » Tue May 05, 2020 6:13 am

This article http://wiki.flightgear.org/Howto:Create ... sal_module might need a review. It is not the best idea to advise this to Nasal newbies as it points to the location core libraries and there are several limitations in this place.
jsb
 
Posts: 285
Joined: Sat Oct 25, 2014 9:17 pm
Location: Hamburg, Germany
Callsign: D-JSB
Version: next
OS: Win7/Linux

Re: Lack of documentation (?)

Postby Johan G » Sun Jul 12, 2020 2:03 pm

Some posts were split off to the new topic UFO object placement export to arbitrary file location.
Low-level flying — It's all fun and games till someone looses an engine. (Paraphrased from a YouTube video)
Improving the Dassault Mirage F1 (Wiki, Forum, GitLab. Work in slow progress)
Some YouTube videos
Johan G
Moderator
 
Posts: 6629
Joined: Fri Aug 06, 2010 6:33 pm
Location: Sweden
Callsign: SE-JG
IRC name: Johan_G
Version: 2020.3.4
OS: Windows 10, 64 bit


Return to Nasal

Who is online

Users browsing this forum: No registered users and 2 guests