From FlightGear wiki
Jump to navigation Jump to search
Note  The Canvas system is a more recent, and much simpler, option to add immatriculation support to an aircraft using CanvasText/osgText nodes (typically, 5 lines of code), for details see: Howto:Dynamic Liveries via Canvas
Immatriclation at the tail of the DR400.

Immatriculation makes it possible to add a user changeable callsign to an aircraft.

Examples are based on the Robin DR400.

Please note that this article does not cover the model part! Following only this page, will not result in a working immatriclation!


Add this to enable the immatriculation:


Let's make a menu button:

  <menu n="100">
   <label>Robin DR400</label>
   <enabled type="bool">true</enabled>

And place a path to the immat.nas file we will create in the next step.



# ===========================
# Immatriculation by Zakharov
# ===========================

var refresh_immat = func {
    var immat = props.globals.getNode("/sim/model/immat",1).getValue();
    var immat_size = size(immat);
    if (immat_size != 0) immat = string.uc(immat);
    for (var i = 0; i < 6; i += 1) {
	if (i >= immat_size)
	    glyph = -1;
	elsif (string.isupper(immat[i]))
		glyph = immat[i] - `A`;
	elsif (string.isdigit(immat[i]))
	    glyph = immat[i] - `0` + 26;
	   glyph = 36;
	props.globals.getNode("/sim/multiplay/generic/int["~i~"]", 1).setValue(glyph+1);

var immat_dialog ="/sim/gui/dialogs/DR400/status/dialog",

setlistener("/sim/signals/fdm-initialized", func {
  if (props.globals.getNode("/sim/model/immat") == nil) {
    var immat = props.globals.getNode("/sim/model/immat",1);
    var callsign = props.globals.getNode("/sim/multiplay/callsign").getValue();
    if (callsign != "callsign") immat.setValue(callsign);
  else immat.setValue("F-GHYQ");
  setlistener("sim/model/immat", refresh_immat, 0);