Results 1 to 6 of 6

Thread: Help with wait function

  1. #1
    Join Date
    Apr 2012
    Location
    Land of the Rising Sun
    Posts
    207
    Mentioned
    0 Post(s)
    Quoted
    77 Post(s)

    Default Help with wait function

    I'm trying to use a simple wait function while my character climbs an obstacle, so he doesn't try and go onto the next procedure.
    The annoying thing is, sometimes it works and sometimes it ignores the wait completely, and I have no idea why

    The wait is right at the end of the code.


    Code:
    Function FindShortcut:boolean;
    var
      PathTPA, WallTPA:TPointArray;
      PathATPA:T2DPointArray;
      PathBox:TBox;
      i, r, counter:integer;
    begin
     if not(loggedin) then
        exit;
      Wait(RandomRange(2000, 200));
      SetColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.13, 0.43);
      if FindColorsSpiralTolerance(MSX1, MSY1, PathTPA, 4413280, MSX1, MSY1, MSX2, MSY2, 20) then
        begin
          PathATPA := SplitTPAEx(PathTPA, 25, 25);
          SortATPASize(PathATPA, True);
          for i := 0 to high(PathATPA) do
            begin
              PathBox := GetTPABounds(PathATPA[i]);
              SetColorSpeed2Modifiers(0.20, 3.85);
              if FindColorsSpiralTolerance(MSX1, MSY1, WallTPA, 12118515, PathBox.X1, Pathbox.Y1, Pathbox.X2, Pathbox.Y2, 10) then
                Break;
              if i = high(PathATPA) then
                begin
                  writeln('Couldnt find wall color');
                  Terminatescript;
                end;
            end;
          SetColorToleranceSpeed(1);
          SetColorSpeed2Modifiers(0.2, 0.2);
          marktime(counter);
          while (not isuptext('wall')) do
            begin
              r := random(length(WallTPA));
              mmouse(WallTPA[r].x, WallTPA[r].y, 2, 2);
              wait(randomrange(200, 500));
              if timefrommark(counter) > 10000 then
                begin
                  writeln('couldnt find it');
                  Logout;
                  Terminatescript;
                end;
             end;
              ClickMouse2(Mouse_left);
        end;
        Wait(RandomRange(7000, 1000));     //This is my wait...... :(
    end;
    Last edited by Thief; 05-01-2013 at 01:47 PM.

  2. #2
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    I notice it's
    Simba Code:
    Wait(RandomRange(7000, 1000));  //between 7 and 1 seconds
    Did you mean it to be
    Simba Code:
    Wait(RandomRange(7000, 10000)); //between 7 and 10 seconds
    ?

    I'm just wondering because usually the smaller number is first.

  3. #3
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    Quote Originally Posted by BMWxi View Post
    I notice it's
    Simba Code:
    Wait(RandomRange(7000, 1000));  //between 7 and 1 seconds
    Did you mean it to be
    Simba Code:
    Wait(RandomRange(7000, 10000)); //between 7 and 10 seconds
    ?

    I'm just wondering because usually the smaller number is first.
    Good catch

    Creds to DannyRS for this wonderful sig!

  4. #4
    Join Date
    Apr 2012
    Location
    Land of the Rising Sun
    Posts
    207
    Mentioned
    0 Post(s)
    Quoted
    77 Post(s)

    Default

    Oh snap, I always thought the second number was random, while the first was the minimum wait time. Thanks!!!
    Last edited by Thief; 05-01-2013 at 02:08 PM.

  5. #5
    Join Date
    Jun 2012
    Posts
    4,867
    Mentioned
    74 Post(s)
    Quoted
    1663 Post(s)

    Default

    Quote Originally Posted by pure_thief View Post
    Oh snap, I always thought the second number was random, while the first was the minimum wait time. Thanks!!!
    Np, glad I could help

  6. #6
    Join Date
    Dec 2007
    Posts
    174
    Mentioned
    0 Post(s)
    Quoted
    43 Post(s)

    Default

    Quote Originally Posted by pure_thief View Post
    I'm trying to use a simple wait function while my character climbs an obstacle, so he doesn't try and go onto the next procedure.
    The annoying thing is, sometimes it works and sometimes it ignores the wait completely, and I have no idea why

    The wait is right at the end of the code.


    Code:
    Function FindShortcut:boolean;
    var
      PathTPA, WallTPA:TPointArray;
      PathATPA:T2DPointArray;
      PathBox:TBox;
      i, r, counter:integer;
    begin
     if not(loggedin) then
        exit;
      Wait(RandomRange(2000, 200));
      SetColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.13, 0.43);
      if FindColorsSpiralTolerance(MSX1, MSY1, PathTPA, 4413280, MSX1, MSY1, MSX2, MSY2, 20) then
        begin
          PathATPA := SplitTPAEx(PathTPA, 25, 25);
          SortATPASize(PathATPA, True);
          for i := 0 to high(PathATPA) do
            begin
              PathBox := GetTPABounds(PathATPA[i]);
              SetColorSpeed2Modifiers(0.20, 3.85);
              if FindColorsSpiralTolerance(MSX1, MSY1, WallTPA, 12118515, PathBox.X1, Pathbox.Y1, Pathbox.X2, Pathbox.Y2, 10) then
                Break;
              if i = high(PathATPA) then
                begin
                  writeln('Couldnt find wall color');
                  Terminatescript;
                end;
            end;
          SetColorToleranceSpeed(1);
          SetColorSpeed2Modifiers(0.2, 0.2);
          marktime(counter);
          while (not isuptext('wall')) do
            begin
              r := random(length(WallTPA));
              mmouse(WallTPA[r].x, WallTPA[r].y, 2, 2);
              wait(randomrange(200, 500));
              if timefrommark(counter) > 10000 then
                begin
                  writeln('couldnt find it');
                  Logout;
                  Terminatescript;
                end;
             end;
              ClickMouse2(Mouse_left);
        end;
        Wait(RandomRange(7000, 1000));     //This is my wait...... :(
    end;
    try this out it will wait untill your not moving and not climbing an obstacle
    Simba Code:
    Function FindShortcut:boolean;
    var
      PathTPA, WallTPA:TPointArray;
      PathATPA:T2DPointArray;
      PathBox:TBox;
      i, r, counter:integer;
      Pbox: Tbox
    begin
     if not(loggedin) then
        exit;
       PBox := IntToBox(206, 137, 309, 230);  
      Wait(RandomRange(2000, 200));
      SetColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.13, 0.43);
      if FindColorsSpiralTolerance(MSX1, MSY1, PathTPA, 4413280, MSX1, MSY1, MSX2, MSY2, 20) then
        begin
          PathATPA := SplitTPAEx(PathTPA, 25, 25);
          SortATPASize(PathATPA, True);
          for i := 0 to high(PathATPA) do
            begin
              PathBox := GetTPABounds(PathATPA[i]);
              SetColorSpeed2Modifiers(0.20, 3.85);
              if FindColorsSpiralTolerance(MSX1, MSY1, WallTPA, 12118515, PathBox.X1, Pathbox.Y1, Pathbox.X2, Pathbox.Y2, 10) then
                Break;
              if i = high(PathATPA) then
                begin
                  writeln('Couldnt find wall color');
                  Terminatescript;
                end;
            end;
          SetColorToleranceSpeed(1);
          SetColorSpeed2Modifiers(0.2, 0.2);
          marktime(counter);
          while (not isuptext('wall')) do
            begin
              r := random(length(WallTPA));
              mmouse(WallTPA[r].x, WallTPA[r].y, 2, 2);
              wait(randomrange(200, 500));
              if timefrommark(counter) > 10000 then
                begin
                  writeln('couldnt find it');
                  Logout;
                  Terminatescript;
                end;
             end;
              ClickMouse2(Mouse_left);
        end;
        while (isMoving) do
        wait(50);
      while (AveragePixelShift(PBox, 250, 500) > 300) do
        wait(150);      
    end;

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
  •