Page 1 of 2 12 LastLast
Results 1 to 25 of 39

Thread: Re-organized BankScreen for faster result

  1. #1
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default Re-organized BankScreen for faster result

    For comparison I timed each function 5 times.

    Five tries with Current BankScreen:
    SCAR Code:
    102
    137
    104
    131
    117
    5 tries with re-organized BankScreen:
    SCAR Code:
    8
    15
    18
    13
    37
    All I did was make the function check for the result first so it doesn't get held up on the filasafes if it doesn't need to.

    Re-organized version:
    SCAR Code:
    {*******************************************************************************
    function BankScreen: Boolean;
    by: NCDS, Coh3n, Sabzi, nielsie95, and Timer
    Description: Finds Bankscreen. Returns true if Found.
    *******************************************************************************}

    function BankScreen: Boolean;
    var
      c: Integer;
    begin
      c := GetTimeRunning + 5000;
      repeat
        Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
        if Result then
          Exit;
        Wait(50);
      until ((GetTimeRunning > c));
      Wait(RandomRange(100, 150));
    end;
    Doesn't it make more sense to have it this way?
    Last edited by NCDS; 01-21-2010 at 11:12 PM.

  2. #2
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    Doesn't it make more sense to have it this way?
    Yes it does. What's with all the CountColor and MouseBox mumbo jumbo? Can't you just have it wait until the text is found or timed out?

  3. #3
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    I thought about all that too, it's in there from the previous BankScreen function. I'm assuming it checks for BlackScreen for SMART users?

  4. #4
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    I thought about all that too, it's in there from the previous BankScreen function. I'm assuming it checks for BlackScreen for SMART users?
    Again, you could just use a while..do statement to wait for the screen, otherwise it times out, and therefore can't find the screen. Seems much easier to me.

  5. #5
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Again, you could just use a while..do statement to wait for the screen, otherwise it times out, and therefore can't find the screen. Seems much easier to me.
    Fixed to that ^.

  6. #6
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    See, now that makes much more sense to me.

  7. #7
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    See, now that makes much more sense to me.
    I agree.

    Seems no one else has an opinion..?

  8. #8
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Isn't this a possible infinite loop?

  9. #9
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    That's what the GetSystemTime < c is for, I think.

  10. #10
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    The problem is that the c is constantly set, because Bankscreen gets called over and over again.

  11. #11
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    That's what the GetSystemTime < c is for, I think.
    Yeah, but when you call the function again won't it start a new one again and again? I don't really know how these recursive things work but it seems like that it can be infinitive for me too.

    'd, but he knows is better

  12. #12
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    The problem is that the c is constantly set, because Bankscreen gets called over and over again.
    Oh, then shouldn't it be while (not Result)...

  13. #13
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function BankScreen: Boolean;
    var
      c: Integer;
    begin
      Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
      if (Result) then
        Exit;
      c := GetTimeRunning + 45000;
      while (not FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing)) and (GetTimeRunning < c) do
        Wait(50);
      Wait(RandomRange(100, 150));
    end;
    Now it doesn't?

    EDIT:
    SCAR Code:
    function BankScreen: Boolean;
    var
      c: Integer;
    begin
      if (FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing)) then
        Exit;
      c := GetTimeRunning + 45000;
      while (not FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing)) and (GetTimeRunning < c) do
        Wait(50);
      Result := GetTimeRunning < c;
      //Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
      Wait(RandomRange(100, 150));
    end;

  14. #14
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Yeah, there is no infinite loops there
    E: Wow sorry, didn't see the (not BankScreen)

  15. #15
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    @Timer: What I said above.

  16. #16
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function BankScreen: Boolean;
    var
      c: Integer;
    begin
      c := GetTimeRunning + 45000;
      repeat
        Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
        if Result then
          Exit;
        Wait(50);
      until Result and (GetTimeRunning > c)
      Wait(RandomRange(100, 150));
    end;

    Me too! Actually there is no need for Result check in the until because it will just exit before anyway.

    EDIT: I ninja'd back?
    Last edited by Sabzi; 01-21-2010 at 09:41 PM.

  17. #17
    Join Date
    Sep 2006
    Posts
    6,089
    Mentioned
    77 Post(s)
    Quoted
    43 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Oh, then shouldn't it be while (not Result)...
    No, because you never set the result in the loop. If you call a function from itself, it doesn't start over again, it's the same as every other call.

    Timer's function is right, but you need to set the result too.

    EDIT: Sabzi, you need to ditch the "until Result", because result will never be true there (so that's an infinite loop too).
    Last edited by nielsie95; 01-21-2010 at 09:42 PM.

  18. #18
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by nielsie95 View Post
    No, because you never set the result in the loop. If you call a function from itself, it doesn't start over again, it's the same as every other call.

    Timer's function is right, but you need to set the result too.
    Oh yeah, you're right.

  19. #19
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Sabzi View Post
    SCAR Code:
    function BankScreen: Boolean;
    var
      c: Integer;
    begin
      c := GetTimeRunning + 45000;
      repeat
        Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
        if Result then
          Exit;
        Wait(50);
      until Result and (GetTimeRunning > c)
      Wait(RandomRange(100, 150));
    end;

    Me too!
    No need for
    if Result then
    Exit;
    AND
    until Result and (GetTimeRunning > c)

    would have to be
    SCAR Code:
    function BankScreen: Boolean;
    var
      c: Integer;
    begin
      c := GetTimeRunning + 45000;
      repeat
        Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
        Wait(50);
      until (Result or (GetTimeRunning > c));
      Wait(RandomRange(100, 150));
    end;
    or
    SCAR Code:
    function BankScreen: Boolean;
    var
      c: Integer;
    begin
      c := GetTimeRunning + 45000;
      repeat
        Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
        if Result then
          Exit;
        Wait(50);
      until ((GetTimeRunning > c));
      Wait(RandomRange(100, 150));
    end;

  20. #20
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    @Timer: Wahaha so funny while I write or edit a post there is 2 more post already. I have already found that out. But I wanted to post the first version fast XD.

  21. #21
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Wow, this thread blew up..

    Updated first post to the version Timer posted. I chose the one I did because this one will exit immediately after Result returns true instead of waiting, then exiting.

  22. #22
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Timer View Post
    SCAR Code:
    function BankScreen: Boolean;
    var
      c: Integer;
    begin
      if (FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing)) then
        Exit;
      c := GetTimeRunning + 45000;
      while (not FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing)) and (GetTimeRunning < c) do
        Wait(50);
      Result := GetTimeRunning < c;
      //Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
      Wait(RandomRange(100, 150));
    end;
    Is better, I say.

  23. #23
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Quote Originally Posted by Timer View Post
    Is better, I say.
    it never set's the Result though if it finds then BankScreen on first check?

  24. #24
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    it never set's the Result though if it finds then BankScreen on first check?
    Oh. There...
    SCAR Code:
    function BankScreen: Boolean;
    var
      c: Integer;
    begin
      Result := True;
      if (FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing)) then
        Exit;
      c := GetTimeRunning + 45000;
      while (not FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing)) and (GetTimeRunning < c) do
        Wait(50);
      Result := GetTimeRunning < c;
      //Result := FindTextTPA(4106994, 20, 20, 22, 400, 45, 'Bank', upchars, Nothing);
      Wait(RandomRange(100, 150));
    end;

  25. #25
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    I think the one I picked already has the least repetitive/smoothest flowing code.

Page 1 of 2 12 LastLast

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
  •