immat.nas 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. # ===========================
  2. # Immatriculation by Zakharov
  3. # ===========================
  4. var refresh_immat = func {
  5. var immat = props.globals.getNode("/sim/model/immat",1).getValue();
  6. var immat_size = size(immat);
  7. if (immat_size != 0) immat = string.uc(immat);
  8. for (var i = 0; i < 6; i += 1) {
  9. if (i >= immat_size)
  10. glyph = -1;
  11. elsif (string.isupper(immat[i]))
  12. glyph = immat[i] - `A`;
  13. elsif (string.isdigit(immat[i]))
  14. glyph = immat[i] - `0` + 26;
  15. else
  16. glyph = 36;
  17. props.globals.getNode("/sim/multiplay/generic/int["~i~"]", 1).setValue(glyph+1);
  18. }
  19. }
  20. var immat_dialog = gui.Dialog.new("/sim/gui/dialogs/F-4EJ_ADTW/status/dialog",
  21. "Aircraft/F-4EJ_ADTW/Dialogs/immat.xml");
  22. setlistener("/sim/signals/fdm-initialized", func {
  23. if (props.globals.getNode("/sim/model/immat") == nil) {
  24. var immat = props.globals.getNode("/sim/model/immat",1);
  25. var callsign = props.globals.getNode("/sim/multiplay/callsign").getValue();
  26. if (callsign != "callsign") immat.setValue(callsign);
  27. else immat.setValue("F-HLBL");
  28. }
  29. refresh_immat();
  30. setlistener("sim/model/immat", refresh_immat, 0);
  31. },0);