Walk view: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
(don't query same property multiple times; don't use fixed view index numbers, but view names)
No edit summary
Line 1: Line 1:
{{stub}}
{{stub}}
 
{{Languages|Walk View}}
==Easy walk==
==Easy walk==
This is the most easy walk mode: you just walk at the same level (compared to the plane) and you will not fall if you get outside the plane.
This is the most easy walk mode: you just walk at the same level (compared to the plane) and you will not fall if you get outside the plane.

Revision as of 17:46, 15 October 2009

This article is a stub. You can help the wiki by expanding it.

Template:Languages

Easy walk

This is the most easy walk mode: you just walk at the same level (compared to the plane) and you will not fall if you get outside the plane.

walk.nas

# view nodes and offsets --------------------------------------------
var zNoseNode = props.globals.getNode("sim/view/config/y-offset-m", 1);
var xViewNode = props.globals.getNode("sim/current-view/z-offset-m", 1);
var yViewNode = props.globals.getNode("sim/current-view/x-offset-m", 1);
var hViewNode = props.globals.getNode("sim/current-view/heading-offset-deg", 1);

var walk_about = func(wa_distance) {
	var i = getprop("sim/current-view/view-number");
	if (i == view.indexof("Pilot View") or i == view.indexof("Model View") or i == view.indexof("View 8")) {
		var wa_heading_rad = hViewNode.getValue() * 0.01745329252;
		var new_x_position = xViewNode.getValue() - (math.cos(wa_heading_rad) * wa_distance);
		var new_y_position = yViewNode.getValue() - (math.sin(wa_heading_rad) * wa_distance);
		xViewNode.setValue(new_x_position);
		yViewNode.setValue(new_y_position);
	}
}

-set.xml

<input>
 <keyboard>
  <key n="119">
   <name>w</name>
    <desc>Walk forward toward view</desc>
    <repeatable>true</repeatable>
    <binding>
     <command>nasal</command>
     <script>walk.walk_about(0.1)</script>
    </binding>
  </key>
  <key n="87">
   <name>W</name>
   <desc>Walk backward from view</desc>
   <repeatable>true</repeatable>
   <binding>
    <command>nasal</command>
    <script>walk.walk_about(-0.1)</script>
   </binding>
  </key>
 </keyboard>
</input>

Advanced walk with jump and parachute

This advanced mode is way more complicated than the easy walk (see above). With this mode you can jump out of the plane and land with a parachute.

walk.nas

See the Pilatus PC-6 Porter‎'s PC-6/Nasal/walk.nas

-set.xml

<walker>
 <outside type="bool">false</outside>
 <walking type="bool">false</walking>
 <speed type="double">0.000006</speed>
 <latitude-deg type="double">0.0</latitude-deg>
 <longitude-deg type="double">0.0</longitude-deg>
 <altitude-at-exit-ft type="double">0.0</altitude-at-exit-ft>
 <altitude-ft type="double">0.0</altitude-ft>
 <heading-deg type="double">0.0</heading-deg>
 <pitch-deg type="double">0.0</pitch-deg>
 <roll-deg type="double">0.0</roll-deg>
 <internal>
  <x-offset-m type="double">4.3</x-offset-m>
  <y-offset-m type="double">0.0</y-offset-m>
  <z-offset-m type="double">0.0</z-offset-m>
  <heading-deg type="double">0.0</heading-deg>
 </internal>
 <keep-inside-offset-x type="double">0.0</keep-inside-offset-x>
 <keep-inside-offset-y type="double">0.0</keep-inside-offset-y>
 <keep-inside-offset-z type="double">0.0</keep-inside-offset-z>
 <keep-pitch-offset-deg type="double">0.0</keep-pitch-offset-deg>
 <key-triggers>
  <forward type="double">0</forward>
  <outside-toggle type="bool">0</outside-toggle>
  <slide type="double">0</slide>
 </key-triggers>
 <parachute-opened-altitude-ft type="double">0</parachute-opened-altitude-ft>
 <parachute-opened-sec type="double">0</parachute-opened-sec>
 <starting-trajectory-lat type="double">0</starting-trajectory-lat>
 <starting-trajectory-lon type="double">0</starting-trajectory-lon>
 <time-of-exit-sec type="double">0</time-of-exit-sec>
</walker>
<keyboard>
 </input>
  <key n="111">
  	<name>o</name>
  	<desc>Toggle walker outside/inside</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-toggle</command>
  	   <property>sim/walker/key-triggers/outside-toggle</property>
  	</binding>
  </key>
  <key n="119"> 
  	<name>w</name>
  	<desc>Walk forward</desc>
  	<repeatable>false</repeatable>
  	<binding n="0">
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/forward</property>
  	   <value>1</value>
  	</binding>
  	<binding n="1">
  	   <command>property-assign</command>
  	   <property>sim/walker/speed</property>
  	   <value>0.000006</value>
  	</binding>
  	<mod-up>
  	   <binding n="0">
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/forward</property>
  	   	<value>0</value>
  	   </binding>
  	   <binding n="1">
  	   	<command>property-assign</command>
  	   	<property>sim/walker/speed</property>
  	   	<value>0.000006</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="87"> 
  	<name>W</name>
  	<desc>Run forward</desc>
  	<repeatable>false</repeatable>
  	<binding n="0">
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/forward</property>
  	   <value>1</value>
  	</binding>
  	<binding n="1">
  	   <command>property-assign</command>
  	   <property>sim/walker/speed</property>
  	   <value>0.000018</value>
  	</binding>
  	<mod-up>
  	   <binding n="0">
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/forward</property>
  	   	<value>0</value>
  	   </binding>
  	   <binding n="1">
  	   	<command>property-assign</command>
  	   	<property>sim/walker/speed</property>
  	   	<value>0.000006</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="115"> 
  	<name>s</name>
  	<desc>Walk backward</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/forward</property>
  	   <value>-1</value>
  	</binding>
  	<mod-up>
  	   <binding>
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/forward</property>
  	   	<value>0</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="97"> 
  	<name>a</name>
  	<desc>Slide left</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/slide</property>
  	   <value>-1</value>
  	</binding>
  	<mod-up>
  	   <binding>
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/slide</property>
  	   	<value>0</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="65"> 
  	<name>A</name>
  	<desc>Slide left2, override default assignment</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/slide</property>
  	   <value>-1</value>
  	</binding>
  	<mod-up>
  	   <binding>
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/slide</property>
  	   	<value>0</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="100"> 
  	<name>d</name>
  	<desc>Slide right</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/slide</property>
  	   <value>1</value>
  	</binding>
  	<mod-up>
  	   <binding>
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/slide</property>
  	   	<value>0</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="68"> 
  	<name>D</name>
  	<desc>Slide right2</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>property-assign</command>
  	   <property>sim/walker/key-triggers/slide</property>
  	   <value>1</value>
  	</binding>
  	<mod-up>
  	   <binding>
  	   	<command>property-assign</command>
  	   	<property>sim/walker/key-triggers/slide</property>
  	   	<value>0</value>
  	   </binding>
  	</mod-up>
  </key>
  <key n="114"> 
  	<name>r</name>
  	<desc>open parachute</desc>
  	<repeatable>false</repeatable>
  	<binding>
  	   <command>nasal</command>
  	   <script>walk.open_chute()</script>
  	</binding>
  </key>
 </input>
<keyboard>