Board index FlightGear Support Flying

Making Tutorial

Controlling your aircraft, using the autopilot etc.

Making Tutorial

Postby RobAndrew » Sat Jan 05, 2019 7:04 pm

Well.....All it took was a day to get stuck... :lol: :evil:

At first, I thought I had it, I went through the Properties and found which ones changed when I turned on the scenario I wanted to include. I came across /sim/ai/scenario[1], the value being the scenario name (in this case, Alpha_1) which came and left when I was switching the scenario on and off. I thought "Great, thats it! Just refer to that In the set tag under step and that'll do it!"

How wrong I was.....

It turns out that that property was JUST the marker in the box appearing and disappearing. In other words, /sim/ai/scenario[1] is just the marker in the box.

Start again....

I have tried a few things since: I have tried to find any other properties that appear and disappear during the switching on/off of the scenario. I found /ai/models/tanker was coming and going as well. (I will say I was playing around with a tanker) So again, "Fine, lets just refer to /ai/models/tanker in the set tag under property...." but what was the value? there wasn't one, just a load of properties and values under /tanker. It could've been any one of them! So what I did was try and put all of the properties and values under separate set, Property and value tags in the tutorial xml. Did that work? No. although I did notice that when I made the list of properties in the tutorial xml, and activated it, most of the property values in the property branch had "(string)" behind them, whereas when activating the scenario manually in game, some had "(bool) standing for boolean? Perhaps that's why its not working?
I finally tried to load an aircraft model in outside the step tag and then find some form of speed/rpm property to refer to. there were none. I tried to make one in the tutorial xml, but it didn't work.

So i've tried a few things and am still trying to get my head around it. Clearly you can't make a model move in game as there is no allocated tag for it (A chance to get developers to make one?) and I can't find a property to refer to when It comes to activating a scenario. I thought activating the marker in the box would work but somehow it doesn't. Maybe I have to refer to the marker in the box appearing, in the scenario xml to activate it?

...Any thoughts?

(to anyone reading, this is of a course a branch off from a separate discussion, "Pop up messages in Scenario")
RobAndrew
 
Posts: 83
Joined: Thu Jul 12, 2018 4:59 pm
Version: 2017.3.1
OS: Mac OSX 10.11.6

Re: Making Tutorial

Postby wlbragg » Sat Jan 05, 2019 7:12 pm

Clearly you can't make a model move in game as there is no allocated tag for it (A chance to get developers to make one?) and I can't find a property to refer to when It comes to activating a scenario.

What exactly it is your trying to do.
It would help if you could be really specific in what it is your wanting to achieve.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
User avatar
wlbragg
 
Posts: 4274
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Debain/nVGT640

Re: Making Tutorial

Postby wlbragg » Sat Jan 05, 2019 7:24 pm

Maybe this code snippet would be of help. At its root is how you can loop through the list of ai/models and target their properties. Keep in mined, some of the code here is irrelevant and in this context won't even work without the rest of the extensive code.
Code: Select all
foreach(var cargoN; props.globals.getNode( "/ai/models", 1).getChildren( "aircraft" )) {
  if(me.hooked == 0) {
      var dlat = cargoN.getNode( "position/latitude-deg" ).getValue() - me.latNode.getValue();
      var dlon = cargoN.getNode( "position/longitude-deg" ).getValue() - me.lonNode.getValue();
      var dist = dlat * dlat + dlon*dlon;
      if(dist < me.minDist) {
         me.minDist = dist;
      }
      if(dist <= me.hookDistance) {
         gui.popupTip( "Cargo in Range", 1);
         #print( "Cargo in Range\n" );
         if (me.hookNode.getValue() == 1 or me.autoHookNode.getValue() == 1) {
            me.hooked = 1;
            me.cargoParent = cargoN.getNode( "callsign" ).getParent().getName() ~ "[" ~ cargoN.getNode( "callsign" ).getParent().getIndex() ~ "]";
            me.cargoName = cargoN.getNode( "callsign" ).getValue();
            if (me.realTime.getValue() == 0) { #submodel ai and rope update
               me.onHookNode.setBoolValue( 1 );
               cargoN.getNode( "position/altitude-ft" ).setDoubleValue(-999);
            }
         }
      }
   }
}
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
User avatar
wlbragg
 
Posts: 4274
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Debain/nVGT640

Re: Making Tutorial

Postby RobAndrew » Sat Jan 05, 2019 8:01 pm

wlbragg wrote in Sat Jan 05, 2019 7:12 pm:
Clearly you can't make a model move in game as there is no allocated tag for it (A chance to get developers to make one?) and I can't find a property to refer to when It comes to activating a scenario.

What exactly it is your trying to do.
It would help if you could be really specific in what it is your wanting to achieve.


As I said in my post, there was a previous post made called "Pop up messages in scenario" it's all explained there, but seeing as it's quite a lengthy conversation, i'll outline the basics:

I'm setting up a navigational scenario where you have to fly from one aircraft to another. At the first aircraft, I would like a message to give heading, speed and altitude of the next aircraft for you to make an intercept course for. Once you get there, you get the next message and so on. The message should be triggered by being in a certain proximity of that aircraft. hopefully.
I will say i'm not exactly experienced with coding (But I am learning), especially nasal as I can't really get my head around it at this time. I have seen exercises for Javascript though so may use them in the future.

Hooray knows what i'm talking about :lol: :lol: :lol:
RobAndrew
 
Posts: 83
Joined: Thu Jul 12, 2018 4:59 pm
Version: 2017.3.1
OS: Mac OSX 10.11.6

Re: Making Tutorial

Postby wlbragg » Sat Jan 05, 2019 8:09 pm

There is actually a method to track an AI object using the property tree. It might help you figure out some of what your looking for. Try searching for it in the forums. Something like ai targeting or ai tracking.
Kansas(2-27-15)/Ohio/Midwest scenery development.
KEQA (2-27-15), 3AU, KRCP Airport Layout
User avatar
wlbragg
 
Posts: 4274
Joined: Sat Aug 25, 2012 11:31 pm
Location: Kansas (Tornado Alley), USA
Callsign: WC2020
Version: next
OS: Win10/Debain/nVGT640

Cross Posting ...

Postby Hooray » Sun Jan 06, 2019 3:53 pm

Hi, just briefly - I did in fact provide the answers to the questions you are now posting in some of my earlier responses.
Which is to say that I am sorry for obviously overwhelming you in terms of feedback, so the following is going to be my first cross-posting, and I would ask moderators not to delete it:

It seems, there are two new users around here who are apparently interested in related features, and wanting to contribute to the project:



Both of you seem to have overlapping interests, and also similar backgrounds - so, may I politely suggest that you try to get in touch and maybe team up in some JV-like effort ? The point being that learning something new can be so much more fun, and you can help each other, because the two of you are obviously interested in learning more about FlightGear internals, and about creating interactive tutorials (scenarios).

The answers you have received in your topics lately contain a ton of pointers already, so it's primarily a matter of structuring things in a sane fashion.

Given your backgrounds, my suggestion would be to start toying with the property browser to learn how XML and properties are related:

http://wiki.flightgear.org/Property_Browser
Image

And once you understand how the property tree works, you can review some of the other property related information (see the wiki).

Personally, I would recommend to ignore Nasal scripting until you really understand the property tree concept and how it relates to XML: http://wiki.flightgear.org/PropertyList_XML_File

http://wiki.flightgear.org/Nasal_Console
Image

The first thing I would suggest playing with when it comes to Nasal scripting is keeping the property browser open and getting/setting variables (properties) to see how they change in the property browser.

The most useful "commands" you will want to learn more about are setprop() and getprop()
And then you could look at timers and listeners: http://wiki.flightgear.org/Nasal_Callbacks_Explained

Once you understand those, you might want to consider learning more about object oriented programming in Nasal and using the object-oriented "props.nas" module to access the property tree.

http://wiki.flightgear.org/Object_orien ... g_in_Nasal
http://wiki.flightgear.org/Object_Orien ... with_Nasal
http://wiki.flightgear.org/Nasal_library/props

The point being, none of this is necessarily difficult or even too material, but it does help to have someone that you can talk to.

In other words, I would definitely suggest that the two of you get in touch via PM (or skype, whatsapp, google hangout whatever) and see kind of learning environment work for you or not.

Which is to say, I think both of you are trying to run before you can walk, i.e. you should proceed more slowly or things may inevitably get frustrating pretty soon.

PS: To learn more about Nasal why it doesn't need a dedicated "compiler", see:
http://wiki.flightgear.org/What_is_Nasal
http://wiki.flightgear.org/Nasal_FAQ
viewtopic.php?f=30&t=34900&p=337609&#p337609

And even if you should end up deciding that "the learning group" thing is not for you, you may still want to consider sharing a common thread - e.g. to identify common goals.
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: 11263
Joined: Tue Mar 25, 2008 8:40 am

Re: Making Tutorial

Postby RobAndrew » Sun Jan 06, 2019 7:24 pm

....What A good idea!

(Of course its a good Idea! (Monty Python Reference) )

I will say that have learned A LOT about how the xml system works over the past few days and have happily wandered through the property browser, looking at all the corresponding switches and labels, occasionally pressing one to see what it does. I'm merrily getting on with my own project and have actually almost finished it, just need to test it and finish off the edges.
I'll certainly get in contact with said other and explain a few things if they need anything that I know explaining. Granted like you say I don't quite know everything just yet, but I can certainly try and help.
I will say that I am finding all of this very exiting. I thought flying was such but apparently making it is also pretty damn good to!
RobAndrew
 
Posts: 83
Joined: Thu Jul 12, 2018 4:59 pm
Version: 2017.3.1
OS: Mac OSX 10.11.6

Re: Making Tutorial

Postby Hooray » Sun Jan 06, 2019 7:57 pm

After having participated in both topics, I do think that there is a very real opportunity that the two of you can benefit from each other's backgrounds and learning. Also, I will volunteer to fill in any missing information in the form of pointers, code snippets, examples, patches and/or customized tutorials - in turn, I would like to ask both of you to consider documenting and sharing your journey with us - ideally using the wiki.

If that is not possible for some reason, at the very least using the forum by regularly posting here.
Ideally, you should consider coming up with a form that we can easily reuse elsewhere (for instance, I have a certain reputation for copying postings over to the wiki in order to incrementally turn certain postings into documentation, i.e. trying to bootstrap articles that way).

The point being, our documentation can certainly be improved, and many of us have been around for too long to realize that we're talking gibberish at times. So this could be a very interesting opportunities for all of us, especially if you can work out a way to work together and regularly talk to each other about your progress (or even lack of it).

Also, being a wiki admin, I do invite you to create your own articles to document your findings there, I am more than willing to regularly take a look and chime in if I can provide some help. That way, you cannot step on anyone's toes by possibly adding "incorrect" stuff.

That being said, as both of you have noticed, I have the tendency to make rather comprehensive replies, but I am also not regularly around, so it may take me a while to get back to you sometimes. Which is why I think it would definitely be a good idea to establish some kind of learning format (group) to exchange ideas, because both of you already have gained some knowledge to complement each other's journey (even if just temporarily).

Again, none of this is to suggest that I am staying out of this, I just think that the whole experience will be more fruitful for both of you - and from my standpoint, it's admittedly also nice to see something getting "fed back" to the project by documenting and sharing your journey.

And please don't underestimate the knowledge you already have - for instance, newcomers could learn a lot from a tutorial that is augmented with screen shots - imagine walking someone through the process of creating/changing a property and taking a handful of screen shots, added to the wiki.

That way, people can actually follow such tutorials in a 1:1 fashion.

Given that you already know how to create/set and change a property, it would only take 5 screen shots to turn that into an annotated tutorial. While it may seem simple to you, it may make a huge difference for people totally new to the property concept.

For instance, a while ago we walked "dilbert" through the whole process of creating a simple TACAN/VOR frequency converted using a few tailored examples: VOR/TACAN {substitute for {VOR/TACAN frequency conversion}

And who knows, maybe dilbert is still around and would be interested in getting involved in your current effort, too ?
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: 11263
Joined: Tue Mar 25, 2008 8:40 am


Return to Flying

Who is online

Users browsing this forum: No registered users and 1 guest