getting started should not pose a real problem at all, even if you don't understand everything in the $FG_ROOT/Nasal directory, or the tanker.nas example - what I posted previously is all you need to know to get started, to get a list of all "aircraft" entries under /ai/models, just use a call like this:
- Code: Select all
var list= props.globals.getNode("/ai/models").getChildren("aircraft");
You can get the size of the list by using the size() function:
- Code: Select all
size(list);
Each element then contains a complete props node object for the corresponding aircraft.
You can access each element by using the array notation:
- Code: Select all
var callsign=list[0].getNode("callsign").getValue();
print (callsign);
Where 0 is the index of the list.
So if you want to do this in a loop, you can use foreach or use a conventional for loop and a size() call.
Thus, all properties can be easily accessed by using the helpers provided in $FG_ROOT/Nasal/props.nas
http://gitorious.org/fg/fgdata/blobs/ma ... /props.nasTo see what properties are commonly available, just browse the property tree as previously suggested already.
Each valid aircraft node then gets its own sub trees for position, orientation, velocities respectively.
I would suggest to start with a very simple function for just dumping the callsign of each AI aircraft model to the console, accessing other properties should then be fairly simple actually.
Here is something to get you started:
- Code: Select all
##
# ai_dumper.nas (save in $FG_ROOT/Nasal)
#
var dumper = func {
foreach (var ai_aircraft; props.globals.getNode("/ai/models").getChildren("aircraft"))
{
print( ai_aircraft.getNode("callsign") );
}
settimer(dumper,1); # call this function again with a 1 second delay
}
_setlistener("/sim/signals/nasal-dir-initialized", dumper); # register the dumper function to be invoked
Let us know if you have specific questions