Problems with a script

  • Hello


    I'm trying to get my head around this new scripting system and it's going okay for now. At least we don't have to twist our brains with RPN anymore, but I actually find the old scripting language easier, maybe because I never did anything like Pascal. I have a problem here, I'm trying to make throttle that would be increased by 1 notch everytime you press the throttle button, but no matter what I do, it'll increase by 2 notches instead of 1 for every click. What am I doing wrong?



    2nd question:


    From the main-file I have this procedure:


    Code
    1. procedure OnButton(id: string; value: boolean; cockpitIndex: byte);
    2. begin
    3. Cockpit_OnButton(id, value);
    4. end


    But if I then wrote in the cockpit script to send the "id" (Throttle) to a specific procedure for the throttle mode:


    Code
    1. procedure Cockpit_OnButton(id: string; value: boolean);
    2. begin
    3. if (id = 'Throttle') then
    4. begin
    5. Cockpit_Throttle_Mode(id);
    6. end;
    7. end;

    ... I keep getting an unknown identifier error when trying to pack the script!

  • It's very easy: The OnButton procedure will be called twice: On mouse button down and on mouse button up - you have to check "value", wether it was pressed (true) or released (false).

  • throttle_mode := throttle_mode_last + 1;
    throttle_mode_last := throttle_mode;

    Why the extra _last variable, why don't you do this instead:

    Code
    1. throttle_mode := throttle_mode + 1;

    Or do we even have shorthands like throttle_mode++ and throttle_mode-- in the script language now?

  • shorthands like throttle_mode++ and throttle_mode--

    No, that's not implemented, because it is not Pascal conform.


    The "original" Pascal has inc(x) and dec(x), but I did not tested it in our "Script Pascal"... ;-)

  • It did the trick, thanks!


    ACMG, I just tried many things, couldn't understand why it added 2 but there was a good explanation .. ;)

  • Neu erstellte Beiträge unterliegen der Moderation und werden erst sichtbar, wenn sie durch einen Moderator geprüft und freigeschaltet wurden.

    Die letzte Antwort auf dieses Thema liegt mehr als 60 Tage zurück. Das Thema ist womöglich bereits veraltet. Bitte erstellen Sie ggf. ein neues Thema.

    Maximale Anzahl an Dateianhängen: 5
    Maximale Dateigröße: 500 kB
    Erlaubte Dateiendungen: bmp, cfg, ini, jpeg, jpg, lct, ldl, llg, lob, log, lpmtl, lptmt, ltx, pas, pdf, png, railtrack, rar, txt, veh, wav