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 .. ;)

  • Newly created posts will remain inaccessible for others until approved by a moderator.

    The last reply was more than 60 days ago, this thread is most likely obsolete. It is recommended to create a new thread instead.

    The maximum number of attachments: 5
    Maximum File Size: 500 kB
    Allowed extensions: bmp, cfg, ini, jpeg, jpg, lct, ldl, llg, lob, log, lpmtl, lptmt, ltx, pas, pdf, png, railtrack, rar, txt, veh, wav