Immatriculation
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 |
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!
-set.xml
Add this to enable the immatriculation:
<model> <immat>true</immat> </model>
Let's make a menu button:
<menubar> <default> <menu n="100"> <label>Robin DR400</label> <enabled type="bool">true</enabled> <item> <label>Immatriculation</label> <binding> <command>nasal</command> <script>dr400.immat_dialog.toggle()</script> </binding> </item> </menu> </default> </menubar>
</sim>
And place a path to the immat.nas file we will create in the next step.
<nasal> <file>Aircraft/DR400/Nasal/immat.nas</file> </nasal>
immat.nas
# =========================== # 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; else glyph = 36; props.globals.getNode("/sim/multiplay/generic/int["~i~"]", 1).setValue(glyph+1); } } var immat_dialog = gui.Dialog.new("/sim/gui/dialogs/DR400/status/dialog", "Aircraft/DR400/Dialogs/immat.xml"); 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"); } refresh_immat(); setlistener("sim/model/immat", refresh_immat, 0); },0);
Example of the model part mentioned above! There are four areas of the aircraft registration that are covered in this file, the Wing, left and right fuselage, and interior panel. The list of model parts on the left side of the image are the individual letter or number positions of the final registration identification string.