Results 1 to 10 of 10

Thread: Laake's FindObjOnScreen Guide

  1. #1
    Join Date
    Dec 2011
    Posts
    1,162
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Thumbs up Laake's FindObjOnScreen Guide

    FindObjOnScreen

    What this allows you to do?

    Have one function with the availability of to use it for many many many many many many many many many things!

    This is my first TUT So dont hate!


    Things Needed:
    ACA/Auto Color Aid found Here
    Simba


    First step:

    The function itself!
    Simba Code:
    Function FindObjOnScreen(Up:Array of String;Color,Tolerance:Integer;MC2:Variant;Hmod,Smod:Extended): Boolean;
      var
      X,Y:Integer;
        CTS,I,T: Integer;
        TPA: TPointArray;
        begin
      repeat
        Result := False;
        CTS := GetColorToleranceSpeed;

        ColorToleranceSpeed(2);

        SetColorSpeed2Modifiers(Hmod,Smod);//These are the modifiers you got from the ACA

         FindColorsSpiralTolerance(MSCX, MSCY, TPA,(Color), MSX1, MSY1, MSX2, MSY2, Tolerance);//This finds the actual item on screen calls the color and the tolerance when finding the o0bject.
        ColorToleranceSpeed(CTS);

        if (Length(TPA) < 1) then
          Exit;

        MMouse(TPA[0].X, TPA[0].Y, 5, 5);
         if WaitUpTextMulti(Up, 400) then//This is the uptext that it waits to see.
        begin
          GetMousePos(X, Y);//this goes to the declared position from FindColorsSpiralTolerance
          ClickMouse2(MC2);//This is the Is the type of mouse Click that you want it to do.
          ChooseOptionMulti(Options);//If the MC2 Was false then you use this to choose the options!
          Result := True;
          Exit;
        end;

        Until(Result = True);
        end;

    Now that is the function that does all the work!


    2nd Step:
    Calling that function into use!

    This is part from my ghouler. As you can see i called it here, you can use it whereever you want as long as its below the actual function that we declared ^^^^^ there
    Simba Code:
    begin
      Startup;
      SetupChar;
      LoadBMP;
      LoadVars;
      repeat
     ToGhouls;
     repeat
      DoThePainting;
     KillGhouls;
     MarkTime(P);
     Repeat
      PickupCharms;
      Until (TimeFromMark(P) > 500);
      FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);//Here is the function.
       until (hppercent<50);
      ToBank;
      Proggy;
    OpenBankNPC;
    if BankScreen then
    begin
      DoThePainting;
    DepositAll;
    wait(50 + Random(250));
      DoThePainting;
    Withdraw(0, 0, 28);
    wait(50 + Random(250));
      DoThePainting;
    Deposit(1,1,false);
    wait(50 + Random(250));
      DoThePainting;
    CloseBank;
    end;
      FindNormalRandoms;
      until not LoggedIn
      writeln('stopping script');
      Proggy;
    TerminateScript;
    end.

    Now what each one of those things are!

    FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
    ..........................................^^^ Is the up text it looks for!

    FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
    .................................................. ..............^^^^^ The color you found with ACA

    FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
    .................................................. .......................^^The 1 is the color tolerance that ACA showed you.

    FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
    .................................................. ..............................^^^True is for it to left Click false is for it to right click!

    FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
    .................................................. .....................................^^1.73 is the Hue Mod

    FindObjOnScreen(['ake', 'Take', 'ke', 'ak'],8290940,1,False,1.73,0.01);
    .................................................. ...........................................^^^ is the Saturation modifier!


    Earlier in the Tut i had the function posted and in the function i had put The Mutliple Option choice, now for step 3 which shows you how this works!

    Step 3:
    Multiple uptext!

    In the running of your script usually located at the bottom and has a
    begin
    end.
    with the period you need to put this
    Simba Code:
    LoadVars;

    What that does is make sure that the variable load into the script, the ones that we will declare like this!

    Simba Code:
    procedure LoadVars;
    begin
      Options:=['old charm','ffigy', 'rimson charm', 'reen charm', 'lue charm']

    end;
    This is an array of uptexts that we use, you put the text you want inbeetween 2 'like this' and seperate those by commas 'o','k','a','y','','e','t','c','.',

    Drops:=['old charm','ffigy', 'rimson charm', 'reen charm', 'lue charm']

    You can call it whatever you want, in my scripts i mainly use this for many different drops, or many different objects, ex rocks water table then furnace and so on!

    Now for you not to get compile errors of not finding that variable you need to go to the top of your script.

    the top should be something like this

    Simba Code:
    program WoodCutter;

    {$DEFINE SMART}
    {$i SRL/srl.simba}
    {$i sps/sps.simba}
    {$i SRL/SRL/misc/paintsmart.simba}

    //put
    Var

      Options: Array of String;//or whatever you want to call it instead of Options! :)
    //Unless you already have your Variables declared up here! :)



    procedure DeclarePlayers;    

    and so on! :)




    And thats the end of the TuT, this is good to have a cleaner script that is more accurate!

    I got the base of this function from Flight!

    This is my first TuT so please dont hate.

    I take no credit for ACA, the creators of that are in freaking sanely smart!
    Last edited by laakerules; 02-24-2012 at 05:38 AM.

  2. #2
    Join Date
    Jan 2012
    Posts
    522
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    This will for sure help out those who need help

  3. #3
    Join Date
    Dec 2011
    Location
    Kosovo
    Posts
    831
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    Thanks for this awesome tut
    Goals:
    Understanding TPAs
    Making Proggy for fighting
    Getting on SRL members
    Get 500 posts

  4. #4
    Join Date
    Jan 2012
    Posts
    915
    Mentioned
    13 Post(s)
    Quoted
    87 Post(s)

  5. #5
    Join Date
    Jun 2007
    Posts
    108
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    I'll try this out on my Chaos Druid script, good guide :P.

  6. #6
    Join Date
    Nov 2011
    Posts
    92
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Amazing! aha, my zammy wine grabber now works flawlessly(: Thanks laake!

  7. #7
    Join Date
    Dec 2011
    Posts
    1,162
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yup your welcome guys, this is my first tut and it was hard to write without using my own laake terms! :P So hope you guys enjoy!

  8. #8
    Join Date
    Jun 2008
    Location
    United States
    Posts
    818
    Mentioned
    60 Post(s)
    Quoted
    90 Post(s)

    Default

    It's good to see you writing your own custom finding functions. That is a step in the right direction. A few things you might want to change though:

    Simba Code:
    Repeat
    Until(Result)

    What is this? An infinite loop is what it is. If you never find the uptext, the script using this function will be forced into an infinite loop, moving the mouse all over the screen. Not good.

    Simba Code:
    MMouse(TPA[0].X, TPA[0].Y, 5, 5);

    Within your infinite loop, you find the color and then do this. ^ You move to the first pixel in the TPA no matter what. and if your character is not moving, it's likely that as you loop over and over again, you'll just be mousing to the same exact point. Over and over.

    If anything, try getting rid of your infinite loop, and looping through your TPA instead. That way, you'll be sure to mouse over all found instances of the color.

    Tip: Grouping the points in your TPA into an ATPA will greatly increase speed, accuracy, and reliability. Try looking at this tutorial for a better understanding of TPAs and how to use them more effectively.

    Simba Code:
    Up:String
    and
    Simba Code:
    if WaitUpText(Up, 400) then

    Try using a string array along with 'WaitUpTextMulti' you are more likely to find 'ele', or 'eto', or 'kel', or 'el', or even 'k' than you are the complete word 'Skeleton'. (If you were looking for a Skeleton archer, for example.)

    Simba Code:
    ChooseOptionMulti(Options)

    What is 'Options'? You have no options parameter.

    ----

    Just a few things I saw with a quick look-over. You're off to a good start though.
    [10/14/13:19:03] <BenLand100> this is special relatively, just cleverly disguised with yachts

  9. #9
    Join Date
    Dec 2011
    Posts
    1,162
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    THanks euphanism!

    The options, i changed it when writing the TuT. And forgot to change it down below when declaring the Vars and in the Var.!

    And ill look into that infinite loop thingy. didnt notice i was doing that! :P


    Updated it, thanks Euphanism!

    Still working on atpa though will do tomorow!
    Last edited by laakerules; 02-12-2012 at 07:32 AM.

  10. #10
    Join Date
    Oct 2011
    Location
    Chicago
    Posts
    3,352
    Mentioned
    21 Post(s)
    Quoted
    437 Post(s)

    Default

    Great job! I will remember your effort here! wink wink.




    Anti-Leech Movement Prevent Leeching Spread the word
    Insanity 60 Days (Killer workout)
    XoL Blog (Workouts/RS/Misc)

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
  •