Talk:Real Live AI traffic

From FlightGear wiki
Jump to navigation Jump to search

Nasal use

Thanks for documenting your journey - regarding the API you are using, and the Perl script in particular, you may want to check out Nasal's built-in support for doing HTTP requests using the http module - depending on the web service and its requirements, the http module could be extended to support this use case, or may already work well enough "as is":

--Hooray (talk) 08:59, 31 December 2016 (EST)

Nasal module feedback

Here's some feedback after looking at your code (take it with a grain of salt obviously):

  • you can get rid of system-specific hard-coded assumptions like /mnt/GameData/flightgear-fgdata/AI/rttemp by using getprop() to look up the whole thing using a more flexible scheme, e.g. you could even use getprop("/sim/fg-root") (see the property browser for details), that would make it much easier for people to use/adapt your code without having to replicate your whole setup. That goes also for other assumptions like /mnt/cache1/testpipe.txt, /mnt/cache1/pipein.txt etc
  • Regarding stuff like /RealPlanes, most nodes in the property tree are generally lower cases (no came case) and use dashes to separate things - equally, it may be easier to set up a single variable once (at the top of the file) and use it from then on.
  • In general, you probably don't want to use settimer() but only maketimer() these days
  • introducing a few smaller helper functions (splitting up huge code blocks) may help make things better readable and more easily reusable for other/similar purposes
  • if you need any fgdata changes, it would make sense to post those for review (e.g. a merge request) and get those committed

You may also want to upload a few screenshots (or even embed a youtube video) here, so that people can more easily tell what you are doing with that code. Besides, such media would be useful to also add your work to the corresponding newsletter (e.g. for 01/2017).

Overall, this is looking really good and really promising.

I guess, that with a little more work the whole thing could probbaly be added to FLightGear as an option sooner or later, and maybe the approach could even be generalized to support other websites some day.

--Hooray (talk) 10:06, 31 December 2016 (EST)