Howto:Transmit properties over MP: Difference between revisions

Jump to navigation Jump to search
Added an example of aliases created by the 3d model XML file.
(Feel free to extend.)
 
(Added an example of aliases created by the 3d model XML file.)
Line 22: Line 22:
'''Note:''' true and false are synonyms from 1 and 0, so in those cases (boolean properties) an integer should be used. Also note that each type is seperately numbered; you can have an int n="0" besided a float n="0".
'''Note:''' true and false are synonyms from 1 and 0, so in those cases (boolean properties) an integer should be used. Also note that each type is seperately numbered; you can have an int n="0" besided a float n="0".


The value behind alias= is the (local) path to the property that has to be transmitted.
The value behind alias= is the (local) path to the property that has to be transmitted. Make sure that the local property has the same type as the generic MP enabled one.
 
==In the 3d model XML file==
 
If the MP enabled properties are to be used in animations it is preferable to create aliases for them on the remote systems so that the animations can be written using the logical properties rather than the "sim/multiplay/generic/..." ones. The example below creates the "fdm/jsbsim/propulsion/engine[x]/pitch-angle-rad" properties in the AI/MP aircrafts property subtree as aliases for the MP properties. In that way the relevant animations can use the more meaningful property name "fdm/jsbsim/propulsion/engine[x]/pitch-angle-rad" instead of "sim/multiplay/generic/float[x]".
 
<nasal>
  <load>
  ##############################################################################
  # The on-load Nasal is not executed when this file is loaded as the user
  # aircraft.
  ##############################################################################
  var rplayer = cmdarg();
  # Set up property aliases for animations.
  rplayer.getNode("fdm/jsbsim/propulsion/engine[0]/pitch-angle-rad", 1).
    alias(rplayer.getNode("sim/multiplay/generic/float[0]"));
  rplayer.getNode("fdm/jsbsim/propulsion/engine[1]/pitch-angle-rad", 1).
    alias(rplayer.getNode("sim/multiplay/generic/float[1]"));
  rplayer.getNode("fdm/jsbsim/propulsion/engine[2]/pitch-angle-rad", 1).
    alias(rplayer.getNode("sim/multiplay/generic/float[2]"));
  ##############################################################################
  </load>
</nasal>
 


[[Category:Aircraft enhancement|Transmit properties over MP]]
[[Category:Aircraft enhancement|Transmit properties over MP]]
[[Category:Nasal|Transmit properties over MP]]
[[Category:Nasal|Transmit properties over MP]]
789

edits

Navigation menu