- cleaning/moving data

- can be run as addon (mostly working)
This commit is contained in:
Slawek Mikula
2017-10-19 23:24:56 +02:00
parent 579b1b69d8
commit 08a4fcb0ee
68 changed files with 436 additions and 9775 deletions

View File

@@ -3,22 +3,12 @@
<PropertyList>
<name>mission-browser</name>
<layout>vbox</layout>
<!--width>850</width-->
<!--height>600</height-->
<!--color>
<alpha>0.0</alpha>
</color-->
<!--x>20</x>
<y>10</y>
<draggable>false</draggable>
<resizable>false</resizable-->
<group>
<layout>hbox</layout>
<empty><stretch>1</stretch></empty>
<text>
<label>Mission browser</label>
<!--halign>center</halign-->
</text>
<empty><stretch>1</stretch></empty>
<button>
@@ -51,13 +41,9 @@
<binding>
<command>nasal</command>
<script>
#mission.start_mission(getprop("/sim/mission/gui/selected-mission"))
select_mission();
</script>
</binding>
<!--binding>
<command>dialog-close</command>
</binding-->
<value>...</value>
<value>...</value>
</list>
@@ -68,7 +54,6 @@
<name>mission-image</name>
<valign>fill</valign>
<halign>fill</halign>
<!-- stretch>true</stretch -->
<pref-width>250</pref-width>
<pref-height>250</pref-height>
<nasal>
@@ -76,17 +61,12 @@
var myCanvas1 = canvas.get( cmdarg() );
myCanvas1.setColorBackground(1,1,1,0);
var img = myCanvas1.createGroup().createChild("image");
#img.setFile(mission.mission_root ~ "/image.png")
# .setSize(250, 250);
]]> </load>
</nasal>
</canvas>
</group>
</group>
<!--hrule/-->
<textbox>
<name>mission_description</name>
<halign>fill</halign>
@@ -108,11 +88,11 @@
<pref-height>30</pref-height>
<binding>
<command>nasal</command>
<script>fgcommand("dialog-close", {"dialog-name":"mission-browser"});mission.start_mission(selected_mission)</script>
<script>
fgcommand("dialog-close", {"dialog-name" : "mission-browser"});
mission.start_mission(selected_mission);
</script>
</binding>
<!--binding>
<command>dialog-close</command>
</binding-->
</button>
<nasal>
@@ -123,7 +103,6 @@
var data_node = props.getNode("sim/mission/gui/data", 1);
data_node.setValues({description: ""});
var dialog_update = func () {
forindex (var i; arg) {
var hash = {
@@ -137,10 +116,16 @@
var update_list = func {
list.removeChildren("value");
var dir = directory(getprop("/sim/mission/root_path") ~ "/Missions");
foreach (var a; dir)
if (a != "." and a != ".." and a != "Generic")
list.addChild("value").setValue(a);
var mission_path = getprop("/sim/mission/root_path") ~ "/Missions";
foreach (var a; directory(mission_path)) {
if (a != "." and a != ".." and a != "Generic") {
foreach (var b; directory(mission_path ~ "/" ~ a)) {
if (b != "." and b != "..") {
list.addChild("value").setValue(a ~ "/" ~ b);
}
}
}
}
dialog_update("mission_list");
}
@@ -153,9 +138,7 @@
io.read_properties(mission_root ~ "/metadata.xml", data_node);
dialog_update("mission_description");
img.set("src", mission_root ~ "/image.png").setSize(250, 250);
}
update_list();

View File

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 246 KiB

View File

Before

Width:  |  Height:  |  Size: 899 KiB

After

Width:  |  Height:  |  Size: 899 KiB

View File

Before

Width:  |  Height:  |  Size: 246 KiB

After

Width:  |  Height:  |  Size: 246 KiB

View File

Before

Width:  |  Height:  |  Size: 445 KiB

After

Width:  |  Height:  |  Size: 445 KiB

View File

@@ -1,14 +1,8 @@
<?xml version="1.0"?>
<PropertyList>
<name>Hoops mission #2</name>
<skill-level>0</skill-level>
<description>
--------------------------------
This is an experimental mission.
--------------------------------
This is an experimental mission. You have to start at Livermore (KLVK) Airport!
</description>
</PropertyList>

View File

@@ -266,7 +266,7 @@
<name>Hoop1_active</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/hoop-40x40.xml</path>
<path>Aircraft/Missions/Generic/Models/hoop-40x40.xml</path>
<orientation>
<heading-deg>88.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -283,7 +283,7 @@
<name>Hoop1_active</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/Numbers/num_1.xml</path>
<path>Aircraft/Missions/Generic/Models/Numbers/num_1.xml</path>
<orientation>
<heading-deg>88.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -300,7 +300,7 @@
<name>Hoop1_inactive</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/hoop-100x100-red.xml</path>
<path>Aircraft/Missions/Generic/Models/hoop-100x100-red.xml</path>
<orientation>
<heading-deg>88.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -318,7 +318,7 @@
<name>Hoop2_active</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/hoop-40x40.xml</path>
<path>Aircraft/Missions/Generic/Models/hoop-40x40.xml</path>
<orientation>
<heading-deg>56.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -335,7 +335,7 @@
<name>Hoop2_active</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/Numbers/num_2.xml</path>
<path>Aircraft/Missions/Generic/Models/Numbers/num_2.xml</path>
<orientation>
<heading-deg>56.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -352,7 +352,7 @@
<name>Hoop2_inactive</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/hoop-100x100-red.xml</path>
<path>Aircraft/Missions/Generic/Models/hoop-100x100-red.xml</path>
<orientation>
<heading-deg>56.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -370,7 +370,7 @@
<name>Model_Hoop_3</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/hoop-100x100-red.xml</path>
<path>Aircraft/Missions/Generic/Models/hoop-100x100-red.xml</path>
<orientation>
<heading-deg>24.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -388,7 +388,7 @@
<name>Model_Hoop_4</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/hoop-100x100-red.xml</path>
<path>Aircraft/Missions/Generic/Models/hoop-100x100-red.xml</path>
<orientation>
<heading-deg>20.0</heading-deg>
<pitch-deg>0.0</pitch-deg>

View File

@@ -1,11 +1,9 @@
<?xml version="1.0"?>
<PropertyList>
<name>Hoops mission</name>
<description>
This is an experimental mission.
</description>
<description><![CDATA[
This is an experimental mission. You have to start at Livermore (KLVK) Airport !
]]></description>
</PropertyList>

View File

@@ -1,7 +1,8 @@
<?xml version="1.0"?>
<PropertyList>
<!--presets>
<presets>
<airport-id>KLVK</airport-id>
<altitude>-9999</altitude>
<altitude-ft>-9999</altitude-ft>
@@ -9,14 +10,14 @@
<longitude-deg>-9999</longitude-deg>
</presets>
<timeofday>noon</timeofday-->
<timeofday>noon</timeofday>
<!--object>
<object>
<name>Timer 1</name>
<type>timer-trigger</type>
<activated>1</activated>
<single-shot>1</single-shot>
<stop-time>5.0</stop-time>
<stop-time>3.0</stop-time>
<actions>
<object-reference>Intro 1</object-reference>
<object-reference>Timer 2</object-reference>
@@ -28,7 +29,7 @@
<type>timer-trigger</type>
<activated>0</activated>
<single-shot>1</single-shot>
<stop-time>4.0</stop-time>
<stop-time>2.0</stop-time>
<actions>
<object-reference>Intro 2</object-reference>
<object-reference>Timer 3</object-reference>
@@ -260,7 +261,7 @@
<name>Hoop1_active</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/hoop-40x40.xml</path>
<path>/Missions/Generic/Models/hoop-40x40.xml</path>
<orientation>
<heading-deg>88.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -277,7 +278,7 @@
<name>Hoop1_active</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/Numbers/num_1.xml</path>
<path>/Missions/Generic/Models/Numbers/num_1.xml</path>
<orientation>
<heading-deg>88.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -294,7 +295,7 @@
<name>Hoop1_inactive</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/hoop-100x100-red.xml</path>
<path>/Missions/Generic/Models/hoop-100x100-red.xml</path>
<orientation>
<heading-deg>88.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -312,7 +313,7 @@
<name>Hoop2_active</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/hoop-40x40.xml</path>
<path>/Missions/Generic/Models/hoop-40x40.xml</path>
<orientation>
<heading-deg>56.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -329,7 +330,7 @@
<name>Hoop2_active</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/Numbers/num_2.xml</path>
<path>/Missions/Generic/Models/Numbers/num_2.xml</path>
<orientation>
<heading-deg>56.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -346,7 +347,7 @@
<name>Hoop2_inactive</name>
<type>model</type>
<activated>0</activated>
<path>Missions/Generic/Models/hoop-100x100-red.xml</path>
<path>/Missions/Generic/Models/hoop-100x100-red.xml</path>
<orientation>
<heading-deg>56.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
@@ -390,161 +391,6 @@
<y-offset-m>0.0</y-offset-m>
<z-offset-m>70.0</z-offset-m>
</attached-world-object>
</object-->
<object>
<name>MSG_KLVK</name>
<type>dialog-action</type>
<text>Welcome to KLVK</text>
<sound-file>glassbell.wav</sound-file>
<delay-sec>3</delay-sec>
</object>
<object>
<name>KLVK_landing</name>
<type>airport-landing-trigger</type>
<activated>0</activated>
<single-shot>0</single-shot>
<airport-id>KLVK</airport-id>
<!--runway>25R</runway>
<runway>25L</runway-->
<landing-type>full stop</landing-type>
<actions>
<object-reference>MSG_KLVK</object-reference>
<object-reference>ENABLE_property_trigger</object-reference>
</actions>
</object>
<object>
<name>helipad_landing</name>
<type>area-landing-trigger</type>
<activated>1</activated>
<areas>
<object-reference>area_helipad1</object-reference>
<object-reference>area_helipad2</object-reference>
</areas>
<landing-type>full stop</landing-type>
<actions>
<object-reference>MSG_KLVK</object-reference>
<object-reference>ENABLE_property_trigger</object-reference>
<object-reference>Goal_completed</object-reference>
</actions>
</object>
<object>
<name>PROP_TRIGGER_landing_KLVK</name>
<type>property-trigger</type>
<activated>1</activated>
<condition>
<greater-than>
<property>/position/altitude-agl-ft</property>
<value>50.0</value>
</greater-than>
</condition>
<actions>
<object-reference>ENABLE_landing_trigger</object-reference>
</actions>
</object>
<object>
<name>ENABLE_landing_trigger</name>
<type>object-activation-action</type>
<object-state>1</object-state>
<reference-list>
<object-reference>helipad_landing</object-reference>
</reference-list>
</object>
<object>
<name>ENABLE_property_trigger</name>
<type>object-activation-action</type>
<object-state>1</object-state>
<reference-list>
<object-reference>PROP_TRIGGER_landing_KLVK</object-reference>
</reference-list>
</object>
<object>
<name>area_helipad1</name>
<type>rectangle-area</type>
<width>20.0</width>
<height>20.0</height>
<length>20.0</length>
<orientation>
<heading-deg>0.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
<roll-deg>0.0</roll-deg>
</orientation>
<attached-world-position>
<latitude-deg>37.69558033</latitude-deg>
<longitude-deg>-121.8204298</longitude-deg>
<altitude-m>116.4220694</altitude-m>
<altitude-is-AGL>0</altitude-is-AGL>
</attached-world-position>
</object>
<object>
<name>area_helipad2</name>
<type>rectangle-area</type>
<width>20.0</width>
<height>20.0</height>
<length>20.0</length>
<orientation>
<heading-deg>0.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
<roll-deg>0.0</roll-deg>
</orientation>
<attached-world-position>
<latitude-deg>37.69023415</latitude-deg>
<longitude-deg>-121.8233606</longitude-deg>
<altitude-m>116.0338283</altitude-m>
<altitude-is-AGL>0</altitude-is-AGL>
</attached-world-position>
</object>
<object>
<name>POI_helipad1</name>
<type>point-of-interest</type>
<activated>1</activated>
<target-name>Helipad 1</target-name>
<attached-world-position>
<latitude-deg>37.69558033</latitude-deg>
<longitude-deg>-121.8204298</longitude-deg>
<altitude-m>116.4220694</altitude-m>
<altitude-is-AGL>0</altitude-is-AGL>
</attached-world-position>
</object>
<object>
<name>POI_helipad2</name>
<type>point-of-interest</type>
<activated>1</activated>
<target-name>Helipad 2</target-name>
<attached-world-position>
<latitude-deg>37.69023415</latitude-deg>
<longitude-deg>-121.8233606</longitude-deg>
<altitude-m>116.0338283</altitude-m>
<altitude-is-AGL>0</altitude-is-AGL>
</attached-world-position>
</object>
<object>
<name>Goal_land</name>
<type>goal</type>
<activated>1</activated>
<goal-state>pending</goal-state>
<text>Land on any helipad.</text>
<order>0</order>
</object>
<object>
<name>Goal_completed</name>
<type>goal-resolution-action</type>
<goal-resolution>completed</goal-resolution>
<goals>
<object-reference>Goal_land</object-reference>
</goals>
</object>
</PropertyList>

Binary file not shown.

After

Width:  |  Height:  |  Size: 445 KiB

View File

@@ -0,0 +1,8 @@
<?xml version="1.0"?>
<PropertyList>
<name>Hoops mission #3</name>
<skill-level>0</skill-level>
<description>
Placeholder for mach loop challenge
</description>
</PropertyList>

Binary file not shown.

After

Width:  |  Height:  |  Size: 899 KiB

View File

@@ -0,0 +1,9 @@
<?xml version="1.0"?>
<PropertyList>
<name>Landing skills</name>
<description>
Experimental landing skills. You have to start at Livermore (KLVK) Airport !
</description>
</PropertyList>

View File

@@ -0,0 +1,159 @@
<?xml version="1.0"?>
<PropertyList>
<object>
<name>MSG_KLVK</name>
<type>dialog-action</type>
<text>Welcome to KLVK</text>
<sound-file>glassbell.wav</sound-file>
<delay-sec>3</delay-sec>
</object>
<object>
<name>KLVK_landing</name>
<type>airport-landing-trigger</type>
<activated>0</activated>
<single-shot>0</single-shot>
<airport-id>KLVK</airport-id>
<!--runway>25R</runway>
<runway>25L</runway-->
<landing-type>full stop</landing-type>
<actions>
<object-reference>MSG_KLVK</object-reference>
<object-reference>ENABLE_property_trigger</object-reference>
</actions>
</object>
<object>
<name>helipad_landing</name>
<type>area-landing-trigger</type>
<activated>1</activated>
<areas>
<object-reference>area_helipad1</object-reference>
<object-reference>area_helipad2</object-reference>
</areas>
<landing-type>full stop</landing-type>
<actions>
<object-reference>MSG_KLVK</object-reference>
<object-reference>ENABLE_property_trigger</object-reference>
<object-reference>Goal_completed</object-reference>
</actions>
</object>
<object>
<name>PROP_TRIGGER_landing_KLVK</name>
<type>property-trigger</type>
<activated>1</activated>
<condition>
<greater-than>
<property>/position/altitude-agl-ft</property>
<value>50.0</value>
</greater-than>
</condition>
<actions>
<object-reference>ENABLE_landing_trigger</object-reference>
</actions>
</object>
<object>
<name>ENABLE_landing_trigger</name>
<type>object-activation-action</type>
<object-state>1</object-state>
<reference-list>
<object-reference>helipad_landing</object-reference>
</reference-list>
</object>
<object>
<name>ENABLE_property_trigger</name>
<type>object-activation-action</type>
<object-state>1</object-state>
<reference-list>
<object-reference>PROP_TRIGGER_landing_KLVK</object-reference>
</reference-list>
</object>
<object>
<name>area_helipad1</name>
<type>rectangle-area</type>
<width>20.0</width>
<height>20.0</height>
<length>20.0</length>
<orientation>
<heading-deg>0.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
<roll-deg>0.0</roll-deg>
</orientation>
<attached-world-position>
<latitude-deg>37.69558033</latitude-deg>
<longitude-deg>-121.8204298</longitude-deg>
<altitude-m>116.4220694</altitude-m>
<altitude-is-AGL>0</altitude-is-AGL>
</attached-world-position>
</object>
<object>
<name>area_helipad2</name>
<type>rectangle-area</type>
<width>20.0</width>
<height>20.0</height>
<length>20.0</length>
<orientation>
<heading-deg>0.0</heading-deg>
<pitch-deg>0.0</pitch-deg>
<roll-deg>0.0</roll-deg>
</orientation>
<attached-world-position>
<latitude-deg>37.69023415</latitude-deg>
<longitude-deg>-121.8233606</longitude-deg>
<altitude-m>116.0338283</altitude-m>
<altitude-is-AGL>0</altitude-is-AGL>
</attached-world-position>
</object>
<object>
<name>POI_helipad1</name>
<type>point-of-interest</type>
<activated>1</activated>
<target-name>Helipad 1</target-name>
<attached-world-position>
<latitude-deg>37.69558033</latitude-deg>
<longitude-deg>-121.8204298</longitude-deg>
<altitude-m>116.4220694</altitude-m>
<altitude-is-AGL>0</altitude-is-AGL>
</attached-world-position>
</object>
<object>
<name>POI_helipad2</name>
<type>point-of-interest</type>
<activated>1</activated>
<target-name>Helipad 2</target-name>
<attached-world-position>
<latitude-deg>37.69023415</latitude-deg>
<longitude-deg>-121.8233606</longitude-deg>
<altitude-m>116.0338283</altitude-m>
<altitude-is-AGL>0</altitude-is-AGL>
</attached-world-position>
</object>
<object>
<name>Goal_land</name>
<type>goal</type>
<activated>1</activated>
<goal-state>pending</goal-state>
<text>Land on any helipad.</text>
<order>0</order>
</object>
<object>
<name>Goal_completed</name>
<type>goal-resolution-action</type>
<goal-resolution>completed</goal-resolution>
<goals>
<object-reference>Goal_land</object-reference>
</goals>
</object>
</PropertyList>

View File

@@ -1,25 +0,0 @@
<?xml version="1.0" standalone="no" ?>
<!DOCTYPE project PUBLIC "-//audacityproject-1.3.0//DTD//EN" "http://audacity.sourceforge.net/xml/audacityproject-1.3.0.dtd" >
<project xmlns="http://audacity.sourceforge.net/xml/" projname="effects_data" version="1.3.0" audacityversion="2.1.2" sel0="0.0000000000" sel1="2.6244897959" vpos="0" h="0.0000000000" zoom="300.2500000000" rate="44100.0" snapto="off" selectionformat="hh:mm:ss + milliseconds" frequencyformat="Hz" bandwidthformat="octaves">
<tags/>
<wavetrack name="Audio Track" channel="2" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="0" rate="44100" gain="1.0" pan="0.0">
<waveclip offset="0.00000000">
<sequence maxsamples="262144" sampleformat="262159" numsamples="107328">
<waveblock start="0">
<simpleblockfile filename="e00002f7.au" len="107328" min="-0.999989" max="0.976547" rms="0.191624"/>
</waveblock>
</sequence>
<envelope numpoints="0"/>
</waveclip>
</wavetrack>
<wavetrack name="white noise" channel="2" linked="0" mute="0" solo="0" height="150" minimized="0" isSelected="0" rate="44100" gain="1.0" pan="0.0">
<waveclip offset="0.00000000">
<sequence maxsamples="262144" sampleformat="262159" numsamples="115740">
<waveblock start="0">
<simpleblockfile filename="e0000663.au" len="115740" min="-0.159301" max="0.159937" rms="0.05041"/>
</waveblock>
</sequence>
<envelope numpoints="0"/>
</waveclip>
</wavetrack>
</project>

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 246 KiB

View File

@@ -1,12 +0,0 @@
<?xml version="1.0"?>
<PropertyList>
<path>scientist.ac</path>
<animation>
<type>range</type>
<min-m>0</min-m>
<max-m>100</max-m>
</animation>
</PropertyList>

70
Nasal/extensions.nas Normal file
View File

@@ -0,0 +1,70 @@
var extensions_load = func {
globals["__mission"] = {};
var i = 0;
var k = "";
#load mission extension
foreach(var script; mission_node.getChildren("include")) {
globals["__mission"][k = "__" ~ i] = {};
load_nasal(mission_root ~ "/extensions/" ~ script.getValue(), k);
i += 1;
}
#load core extensions
foreach(var script; extension_list()) {
globals["__mission"][k = "__" ~ i] = {};
load_nasal(getprop("/sim/mission/root_path") ~ "/Nasal/extensions/" ~ script, k);
i += 1;
}
}
var extension_add = func (type, h) {
if (type == "MissionObject") {
append (objects, h);
} elsif (type == "Handler") {
append (handlers, h);
}
}
var extension_list = func {
var v = [];
var path = getprop("/sim/mission/root_path") ~ "/Nasal/extensions";
if((var dir = directory(path)) == nil) {
return;
}
foreach(var file; sort(dir, cmp)) {
if(size(file) > 4) {
if (substr(file, -4) == ".nas") {
append(v, file);
}
}
}
return v;
}
var load_nasal = func(file, module) { # (copy-paste from io.nas)
var code = call(func compile(io.readfile(file), file), nil, var err = []);
if (size(err)) {
if (substr(err[0], 0, 12) == "Parse error:") { # hack around Nasal feature
var e = split(" at line ", err[0]);
if (size(e) == 2) {
err[0] = string.join("", [e[0], "\n at ", file, ", line ", e[1], "\n "]);
}
}
for (var i = 1; (var c = caller(i)) != nil; i += 1) {
err ~= subvec(c, 2, 2);
}
debug.printerror(err);
return 0;
}
call(bind(code, globals), nil, nil, globals.__mission[module], err);
debug.printerror(err);
}

View File

@@ -48,4 +48,4 @@ var adjust_payload_action = {
del: func,
};
mission.addExtension("MissionObject", adjust_payload_action);
mission.extension_add("MissionObject", adjust_payload_action);

View File

@@ -14,7 +14,7 @@ var ground_speed = func getprop("/velocities/groundspeed-kt");
var full_stop = func math.abs(ground_speed()) <= 1;
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "airport-landing-trigger",
new: func(n) {

View File

@@ -16,7 +16,7 @@ var ground_speed = func getprop("/velocities/groundspeed-kt");
var full_stop = func math.abs(ground_speed()) <= 1;
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "area-landing-trigger",
new: func(n) {

View File

@@ -1,5 +1,5 @@
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "goal",
new: func(n) {

View File

@@ -33,7 +33,7 @@ var draw_message = func (s = 1) {
window.show();
}
mission.addExtension("Handler", {
mission.extension_add("Handler", {
init: func {
me.listeners = [
setlistener(me.node.getNode("goal-state-changed", 1), func me.update()),

View File

@@ -12,7 +12,7 @@ var goal_group_status = func (group, status) {
goal_status(ref.getValue(), status);
}
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "goal-resolution-action",
new: func(n) {

View File

@@ -129,4 +129,4 @@ var menu_prompt_trigger = {
del: func me._window.del(),
};
mission.addExtension("MissionObject", menu_prompt_trigger);
mission.extension_add("MissionObject", menu_prompt_trigger);

View File

@@ -13,11 +13,12 @@ var show_message = func (m, delay, snd = nil) {
setprop("/sim/mission/message/message-delay", delay);
setprop("/sim/mission/message/show-message", 1);
if (snd != nil)
if (snd != nil) {
mission.play_sound(snd);
}
}
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "dialog-action",
new: func(n) {

View File

@@ -2,7 +2,7 @@
var play_sound = nil;
var show_message = nil;
mission.addExtension("Handler", {
mission.extension_add("Handler", {
init: func {
#me.DELAY = 4;
me.timer = maketimer(0, func me._hide_msg());

View File

@@ -1,6 +1,6 @@
mission.addExtension("Handler", {
mission.extension_add("Handler", {
init: func {
me.timer = maketimer(0.1, func me._loop());
me.timer.start();

View File

@@ -1,5 +1,5 @@
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "model",
new: func(n) {
@@ -18,7 +18,7 @@ mission.addExtension("MissionObject", {
#m.object_N = props.getNode("/sim/mission/objects", 1).addChild("model");
#m.position_N = n.getNode("world-position");
m.model = mission.put_model(m._path, m._coord, m._heading, m._pitch, m._roll);
m.model = mission.put_model(getprop("/sim/mission/root_path") ~ m._path, m._coord, m._heading, m._pitch, m._roll);
if (!m._activated)
m._hide();

View File

@@ -1,6 +1,6 @@
var get = mission.get;
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "object-activation-action",
new: func(n) {

View File

@@ -1,6 +1,6 @@
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "point-of-interest",
@@ -49,7 +49,7 @@ mission.addExtension("MissionObject", {
];
me._apply_offsets();
}
me._model = mission.put_model(getprop("/sim/fg-root") ~ me._path, me._mdl_coord);
me._model = mission.put_model(getprop("/sim/mission/root_path") ~ me._path, me._mdl_coord);
me.node.setValues({
"latitude-deg" : me._coord.lat(),
"longitude-deg" : me._coord.lon(),

View File

@@ -82,7 +82,7 @@ var loop = func {
poi("hdg", crs - getprop("/orientation/heading-deg"));
}
mission.addExtension("Handler", {
mission.extension_add("Handler", {
init: func {
listeners = [
setlistener("/sim/mission/point-of-interest/signals/POI-changed", func update()),

View File

@@ -10,7 +10,7 @@
# </object>
#
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "property-trigger",

View File

@@ -1,5 +1,5 @@
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "proximity-trigger",
new: func(n) {

View File

@@ -53,4 +53,4 @@ var random_action = {
del: func,
};
mission.addExtension("MissionObject", random_action);
mission.extension_add("MissionObject", random_action);

View File

@@ -1,5 +1,5 @@
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "rectangle-area",
new: func(n) {

View File

@@ -37,4 +37,4 @@ var refuel_action = {
del: func,
};
mission.addExtension("MissionObject", refuel_action);
mission.extension_add("MissionObject", refuel_action);

View File

@@ -1,5 +1,5 @@
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "single-shot-sound-action",
new: func(n) {

View File

@@ -1,5 +1,5 @@
mission.addExtension("Handler", {
mission.extension_add("Handler", {
init: func {
me.timer = maketimer(0.02, func me._loop());

View File

@@ -3,7 +3,7 @@ __mission.timer = {current_time: nil};
var dtN = props.getNode("/sim/time/delta-sec");
mission.addExtension("MissionObject", {
mission.extension_add("MissionObject", {
type: "timer-trigger",
new: func(n) {

52
Nasal/gui.nas Normal file
View File

@@ -0,0 +1,52 @@
var scr_x = func getprop("/sim/startup/xsize");
var scr_y = func getprop("/sim/startup/ysize");
var init_gui = func {
# do not reinit gui
foreach(var menu; props.getNode("/sim/menubar/default").getChildren("menu")) {
if (menu.getValue("label") == "Missions") {
return;
}
}
gui.Dialog.new("/sim/gui/dialogs/mission-browser/dialog",
getprop("/sim/mission/root_path") ~ "/GUI/mission_browser.xml");
var h = {
label: "Missions",
item: [
{ #0
label: "Mission browser",
binding: {
command: "nasal",
script: "gui.showDialog('mission-browser')",
},
},
{ #1
label: "Toggle compass",
},
{ #2
label: "Stop mission",
binding: {
command: "nasal",
script: "mission.stop_mission()",
},
},
],
};
props.getNode("/sim/menubar/default").addChild("menu").setValues(h);
fgcommand("gui-redraw");
}
var fdm_init_listener = _setlistener("/sim/signals/fdm-initialized", func {
removelistener(fdm_init_listener);
setprop("/sim/sound/chatter/enabled", 1);
setprop("/sim/sound/chatter/volume", 1.0);
init_gui();
print("Mission initalized");
});

View File

@@ -9,64 +9,21 @@ var handlers = [];
var hasmember = view.hasmember;
var addExtension = func (type, h) {
if (type == "MissionObject") {
append (objects, h);
} elsif (type == "Handler") {
append (handlers, h);
}
}
var extension_list = func {
var v = [];
var path = getprop("/sim/mission/root_path") ~ "/Nasal/extensions";
if((var dir = directory(path)) == nil) {
return;
}
foreach(var file; sort(dir, cmp)) {
if(size(file) > 4) {
if (substr(file, -4) == ".nas") {
append(v, file);
}
}
}
return v;
}
var load_nasal = func(file, module) { # (copy-paste from io.nas)
var code = call(func compile(io.readfile(file), file), nil, var err = []);
if (size(err)) {
if (substr(err[0], 0, 12) == "Parse error:") { # hack around Nasal feature
var e = split(" at line ", err[0]);
if (size(e) == 2) {
err[0] = string.join("", [e[0], "\n at ", file, ", line ", e[1], "\n "]);
}
}
for (var i = 1; (var c = caller(i)) != nil; i += 1) {
err ~= subvec(c, 2, 2);
}
debug.printerror(err);
return 0;
}
call(bind(code, globals), nil, nil, globals.__mission[module], err);
debug.printerror(err);
}
var load_preferences = func() {
foreach (var a; directory(mission_root))
if (a == "preferences.xml") {
io.read_properties(mission_root ~ "/preferences.xml", props.getNode(""));
break;
}
foreach (var a; directory(mission_root)) {
if (a == "preferences.xml") {
io.read_properties(mission_root ~ "/preferences.xml", props.getNode(""));
break;
}
}
}
var start_mission = func(name) {
if (mission_started) return;
if (mission_started) {
return;
}
# FIXME - ResourceLoader in FG Source
# FIXME - FIX ResourceLoader in FG Source
mission_root = resolvepath("/Aircraft/Missions/" ~ name);
if (mission_root == "") {
return;
@@ -78,32 +35,18 @@ var start_mission = func(name) {
io.read_properties(mission_root ~ "/mission.xml", mission_node);
var presets = mission_node.getChild("presets");
if (presets != nil) {
props.copy(presets, props.getNode("/sim/presets"));
fgcommand("reposition");
}
# causes FG reload and reinit all data
# if (presets != nil) {
# props.copy(presets, props.getNode("/sim/presets"));
# fgcommand("reposition");
# }
var timeofday = mission_node.getChild("timeofday");
if (timeofday != nil) {
fgcommand("timeofday", props.Node.new({ "timeofday" : timeofday.getValue() }));
}
globals["__mission"] = {};
#load_extensions();
var i = 0;
var k = "";
foreach(var script; mission_node.getChildren("include")) {
globals["__mission"][k = "__" ~ i] = {};
load_nasal(mission_root ~ "/extensions/" ~ script.getValue(), k);
i += 1;
}
foreach(var script; extension_list()) {
globals["__mission"][k = "__" ~ i] = {};
load_nasal(getprop("/sim/fg-root") ~ "/Nasal/mission/extensions/" ~ script, k);
i += 1;
}
extensions_load();
settimer (func _start_mission(), 0);
}
@@ -128,9 +71,11 @@ var _start_mission = func {
}
}
foreach(var obj; mission_objects)
if( hasmember(obj, "init") )
foreach(var obj; mission_objects) {
if( hasmember(obj, "init") ) {
obj.init();
}
}
mission_started = 1;
}
@@ -142,16 +87,23 @@ var splash_screen = func {
}
var stop_mission = func {
if (!mission_started) return;
if (!mission_started) {
return;
}
foreach(var obj; mission_objects) obj.del();
foreach(var obj; mission_objects) {
obj.del();
}
setsize(mission_objects, 0);
setsize(objects, 0);
foreach (var h; handlers)
if (hasmember(h, "stop"))
foreach (var h; handlers) {
if (hasmember(h, "stop")) {
h.stop();
}
}
setsize(handlers, 0);
delete(globals, "__mission");
@@ -161,15 +113,19 @@ var stop_mission = func {
var activate_object = func(name, start = 1) {
if (name == nil)
if (name == nil) {
return;
foreach(var obj; mission_objects)
}
foreach(var obj; mission_objects) {
if (obj.name == name) {
if (start)
if (start) {
obj.start();
else
} else {
obj.stop();
}
}
}
}
@@ -192,11 +148,12 @@ var put_model = func(path, coord, heading = 0, pitch = 0, roll = 0) {
var models = props.getNode("/models");
var model = nil;
for (var i = 0; 1; i += 1)
for (var i = 0; 1; i += 1) {
if (models.getChild("model", i, 0) == nil) {
model = models.getChild("model", i, 1);
break;
}
}
var model_path = model.getPath();
@@ -231,9 +188,11 @@ var model = {
};
var get = func(node, path, default = nil) {
if ( (var value = node.getValue(path)) == nil)
if ( (var value = node.getValue(path)) == nil) {
default;
else value;
} else {
value;
}
}
var play_sound = func (file) {
@@ -245,80 +204,4 @@ var play_sound = func (file) {
fgcommand("play-audio-sample", props.Node.new(sound));
}
var scr_x = func getprop("/sim/startup/xsize");
var scr_y = func getprop("/sim/startup/ysize");
var init_gui = func {
gui.Dialog.new("/sim/gui/dialogs/mission-browser/dialog", getprop("/sim/mission/root_path") ~ "/GUI/mission_browser.xml");
#reset handling
foreach(var menu; props.getNode("/sim/menubar/default").getChildren("menu"))
if (menu.getValue("label") == "Missions")
return;
#/reset handling
var h = {
label: "Missions",
item: [
{ #0
label: "Mission browser",
binding: {
command: "nasal",
script: "gui.showDialog('mission-browser')",
},
},
{ #1
label: "Toggle compass",
},
{ #2
label: "Stop mission",
binding: {
command: "nasal",
script: "mission.stop_mission()",
},
},
],
};
props.getNode("/sim/menubar/default").addChild("menu").setValues(h);
fgcommand("gui-redraw");
}
###
var save_data = func {
var path = getprop("/sim/fg-home") ~ "/Export/state.xml";
var fdm_node = props.getNode("fdm");
var engines_node = props.getNode("engines");
var rotors_node = props.getNode("rotors");
var systems_node = props.getNode("systems");
var controls_node = props.getNode("controls");
var data = props.Node.new();
props.copy(fdm_node, data.getNode("fdm", 1));
props.copy(engines_node, data.getNode("engines", 1));
props.copy(rotors_node, data.getNode("rotors", 1));
props.copy(systems_node, data.getNode("systems", 1));
props.copy(controls_node, data.getNode("controls", 1));
io.write_properties(path, data);
data.remove();
}
var load_data = func {
var path = getprop("/sim/fg-home") ~ "/Export/state.xml";
io.read_properties(path, "/");
}
###
var fdm_init_listener = _setlistener("/sim/signals/fdm-initialized", func {
removelistener(fdm_init_listener);
setprop("/sim/sound/chatter/enabled", 1);
setprop("/sim/sound/chatter/volume", 1.0);
init_gui();
print("Mission initalized");
});
print("Mission loaded");

26
Nasal/persistence.nas Normal file
View File

@@ -0,0 +1,26 @@
var save_data = func {
var path = getprop("/sim/fg-home") ~ "/Export/state.xml";
var fdm_node = props.getNode("fdm");
var engines_node = props.getNode("engines");
var rotors_node = props.getNode("rotors");
var systems_node = props.getNode("systems");
var controls_node = props.getNode("controls");
var data = props.Node.new();
props.copy(fdm_node, data.getNode("fdm", 1));
props.copy(engines_node, data.getNode("engines", 1));
props.copy(rotors_node, data.getNode("rotors", 1));
props.copy(systems_node, data.getNode("systems", 1));
props.copy(controls_node, data.getNode("controls", 1));
io.write_properties(path, data);
data.remove();
}
var load_data = func {
var path = getprop("/sim/fg-home") ~ "/Export/state.xml";
io.read_properties(path, "/");
}

View File

@@ -12,8 +12,7 @@ var main = func( root ) {
setprop("/sim/mission/root_path", root);
# load scripts
foreach(var f; ['mission.nas'] ) {
io.load_nasal( root ~ "/Nasal/" ~ f, "missions" );
foreach(var f; ['mission.nas', 'extensions.nas', 'persistence.nas', 'gui.nas'] ) {
io.load_nasal( root ~ "/Nasal/" ~ f, "mission" );
}
}
}