diff --git a/Docs/README.tutorials b/Docs/README.tutorials index 1b9d494ad..e58a1623a 100644 --- a/Docs/README.tutorials +++ b/Docs/README.tutorials @@ -341,8 +341,11 @@ view to a new view position/direction. All parameters are optional. If, for example, only is set, then the view will only zoom in -- the direction and position will remain the same. This feature is meant for cockpit tutorials, where the pilot's view is directed to some switch or instrument. +view-number can be used to switch between different views, i.e. to tower-view, +copilot view etc. Default view-number is 0 (captain's view). + 0 0=captain's view, 1=copilot,... 20 positive is left -4 positive is up 0 positive is roll right diff --git a/Nasal/tutorial.nas b/Nasal/tutorial.nas index 85a4cf825..f086d2c2f 100644 --- a/Nasal/tutorial.nas +++ b/Nasal/tutorial.nas @@ -345,6 +345,9 @@ var set_view = func(node = nil) { node != nil or return; var v = node.getChild("view"); if (v != nil) { + # when changing view direction, switch to view 0 (captain's view), + # unless another view is explicitly specified + v.initNode("view-number", 0, "INT", 0); view.point.move(v); return 1; } diff --git a/Nasal/view.nas b/Nasal/view.nas index f94ae02b5..0cdab4466 100644 --- a/Nasal/view.nas +++ b/Nasal/view.nas @@ -593,6 +593,9 @@ var point = { }, move : func(prop, time = nil) { prop != nil or return; + var n = prop.getNode("view-number"); + if (n != nil) + setprop("/sim/current-view/view-number",n.getValue()); foreach (var a; keys(me.axes)) { var n = prop.getNode(a); me.axes[a].reset();