Results 1 to 4 of 4

Thread: Question about pressing 2 keys at once

  1. #1
    Join Date
    Dec 2006
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Question about pressing 2 keys at once

    ok so i just started doing this again after being gone for quite a while so im probably just making a beginners mistake. But my problem is i need to press the Left Arrow key and keep it held then press the D button. my script runs but it doesn't execute it right. so do i have the correctly written or what can i change?

    Code:
    procedure RockHitLeft;
    begin
      KeyDown (37); // this is Left Arrow key being pressed
      wait (22); 
      KeyDown (44); // this is D key being pressed
      wait (RandomRange (212,218));
      KeyUp (37);
      wait (RandomRange (23,44));
      KeyUp (44);
    end;
    -/Roo7\-

  2. #2
    Join Date
    Dec 2006
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    figured out that the scripting references page about virtual keyboard is wrong, i just looked for ASCII codes

    still would like if someone critiqued my script tho
    -/Roo7\-

  3. #3
    Join Date
    Sep 2012
    Location
    Here.
    Posts
    2,007
    Mentioned
    88 Post(s)
    Quoted
    1014 Post(s)

    Default

    Since there's not much of a script here, it's hard to critique much, but I'll point out what I can (as a side note, welcome back after many years, and sorry I missed this yesterday). As far as "wait (22);" is concerned, I would increase the wait. It's entirely possible that the game did not update the fact your left arrow is pressed within that time - especially for a browser based game. That is about one fiftieth of a second, and in any slower game, or in any case of lag, it simply may not have had time to recognize the left arrow press (not to mention, randomness should be added at a small scale). I would probably use
    Simba Code:
    wait(randomrange(08, 120));//or at least roughly this
    As for anything else, so long as timing doesn't matter as a part of the game, I think the other lines should be fine.

  4. #4
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    Do this to make the code prettier:
    Simba Code:
    KeyDown(VK_LEFT);
      Wait..
      KeyDown(VK_D);
      Wait..
      KeyUp(VK_LEFT);
      Wait..
      KeyUp(VK_D);
    VK_D is actually 68 so that might be why your code wasn't working. Another option is to use something like KeyDown(GetKeyCode('D'));
    Quote Originally Posted by DeSnob View Post
    ETA's don't exist in SRL like they did in other communities. Want a faster update? Help out with updating, otherwise just gotta wait it out.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •