Results 1 to 5 of 5

Thread: Left/Right keycodes

  1. #1
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default Left/Right keycodes

    I have a simple RotateCam function, but recently its not working well. It rotates the cam only one direction (right). VK_LEFT works as VK_RIGHT.

    Simba Code:
    procedure RotateCam;
    begin
      ActivateClient;
      case Random(1) of
      0:
      begin
        Wait(100 + random(50));
        KeyDown(VK_RIGHT);
        Wait(500 + random(1000));
        KeyUp(VK_RIGHT);
        Wait(500 + random(1000));
        end;
      1:
      begin
        Wait(100 + random(50));
        KeyDown(VK_LEFT);
        Wait(500 + random(1000));
        KeyUp(VK_LEFT);
        Wait(500 + random(1000));
        end;
      end;
    end;

  2. #2
    Join Date
    Feb 2007
    Location
    Lux Aeterna
    Posts
    171
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    LOL - I didn't think I was going to figure this out.
    I figured it out.. I did not pay close attention at first.
    You have 2 case possibilities but are only telling case to pick from 1 possibility (from 0 to 0);
    Try Random(2)
    Triggers..

  3. #3
    Join Date
    Mar 2012
    Location
    Canada
    Posts
    870
    Mentioned
    1 Post(s)
    Quoted
    5 Post(s)

    Default

    There are already function that do this built in SRL.

    Your function was working before?

    E: ninja'd by OP big time.
    My scripts:
    Advanced Barb Agility Course(outdated), MonkeyThieverV0.11, MahoganyTableV0.4(outdated)
    Questions? I bet that for 98% of those, you'll find answer HERE

  4. #4
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Random(1) will always return 0. You need to change it to Random(2) which will return either 0 or 1.

    Edit: 'd.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  5. #5
    Join Date
    Jan 2012
    Posts
    1,104
    Mentioned
    18 Post(s)
    Quoted
    211 Post(s)

    Default

    Oooh my bad, you are right guys. Thanks.

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
  •