Howto:Persistent Nasal configuration: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 4: | Line 4: | ||
Create a file for your settings, save it as [[$FG_HOME]]/Nasal/rgatc.config | Create a file for your settings, save it as [[$FG_HOME]]/Nasal/rgatc.config | ||
We will be using a Nasal hash, that is treated as JSON | |||
We will be using a Nasal hash, that is treated as JSON - this has a number of advantages, i.e. you don't need to write a parser for a custom configuration format, and your configuration can even include comments and arbitrary Nasal values, including even functions or objects | |||
<syntaxhighlight lang="nasal"> | <syntaxhighlight lang="nasal"> | ||
{ | { | ||
# you can also add comments | |||
width: 100, | width: 100, | ||
length : 200, | length : 200, | ||
scale: 10, | scale: 10, | ||
range: 25 | range: 25, | ||
less_than: func(a,b) {return a<b;}, | |||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 16:04, 12 January 2020
This article is a stub. You can help the wiki by expanding it. |
Consider the following setup
Create a file for your settings, save it as $FG_HOME/Nasal/rgatc.config
We will be using a Nasal hash, that is treated as JSON - this has a number of advantages, i.e. you don't need to write a parser for a custom configuration format, and your configuration can even include comments and arbitrary Nasal values, including even functions or objects
{
# you can also add comments
width: 100,
length : 200,
scale: 10,
range: 25,
less_than: func(a,b) {return a<b;},
};
Next, open the Nasal Console, and paste the follwing code:
var filename = "rgatc.config";
var path = getprop("/sim/fg-home") ~ '/Nasal/' ~ filename;
var mySettings = io.load_nasal( path );
debug.dump(mySettings);