Board index FlightGear Development Nasal

Create new property through ".xml"  Topic is solved

Nasal is the scripting language of FlightGear.

Create new property through ".xml"

Postby tsalkt » Wed Jul 26, 2017 11:55 am

I have just seen in this post, which is kind of related with my question, how to create a property with code. But I would like to know if it is possible to add a custom variable to the property tree using any of the ".xml" files of FG. I just want to add a simple variable, lets say an integer.

In here it says "In addition, it is made very straightforward to publish/expose new variables from C++ space to the property tree. In addition, new property tree variables can be easily created using XML files or Nasal scripts". Any idea?
tsalkt
 
Posts: 3
Joined: Thu Mar 16, 2017 8:18 am

Re: Create new property through ".xml"

Postby Bomber » Wed Jul 26, 2017 12:16 pm

It's so easy it'll surprise ya...

Is it just a simple static number or one that's variable based on others factors/properties?
"If anyone ever tells you anything about an aeroplane which is so bloody complicated you can't understand it, take it from me - it's all balls" - R J Mitchel
Bomber
 
Posts: 1933
Joined: Fri Dec 14, 2007 8:06 pm
OS: Windows XP and 10

Re: Create new property through ".xml"  

Postby Thorsten » Wed Jul 26, 2017 5:43 pm

Code: Select all
<PropertyList>

<my-first-directory>
  <my-second-directory>
    <my-variable type="int">1</my-variable>
  </my-second-directory>
</my-first-directory>

</PropertyList


in any file that's read on init creates

/my-first-directory/my-second-directory/my-variable

with type integer and initializes it to 1. This is exemplified in pretty much every configuration xml file you can open.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am


Return to Nasal

Who is online

Users browsing this forum: No registered users and 3 guests