Results 1 to 10 of 10

Thread: The Beauty of FindObjCustom

  1. #1
    Join Date
    Dec 2007
    Location
    Middle of Here and There
    Posts
    417
    Mentioned
    6 Post(s)
    Quoted
    25 Post(s)

    The Beauty of FindObjCustom

    Hi there! I'm ProphesyOfWolf~

    INTRODUCTION

    What is FindObjCustom, and how can you use it? Well, it's pretty simple. Let me start by showing you what it looks like.

    SCAR Code:
    function FindObjCustom(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray; Tol: Integer): Boolean;

    Okay, so you may be thinking "OMG WTF IS THAT?". All in due time, young Padawan.

    FindObjCustom finds an object with color(s) stored in the TIntegerArray Color, and with the uptext(s) stored in the TStringArray Text. Then, it stores the co-ordinates of said object to the values cx, cy, for use with other functions.
    Tol is the tolerance that the function uses to increase the likelyhood of finding that object.

    Okay, let's try to make this easier to understand.

    Let's start with the TIntegerArray Color. As the name implies, it's an array of integers, which, in this case, are colors. This array stores colors like so:

    SCAR Code:
    FindObjCustom(cx, cy, Text, [234543, 456456, 345765], Tol);

    The nice thing about this function is that you can use as many or as few colors as you'd like to. You can store them the way I did above, with the color value in the array, or you can do something like this:

    SCAR Code:
    procedure Tutorial;
      var
        Color1, Color2, Color3: Integer;
      begin
        Color1 := 1234123;
        Color2 := 3213213;
        Color3 := 4566545;
        FindObjCustom(cx, cy, Text, [Color1, Color2, Color3], Tol);
    end;

    It can save you a lot of time if you're dealing with a lot of colors. So far, so good?

    Okay, next thing we'll talk about is the TStringArray Text. It's basically the same idea as the Colors we just discussed, except!.. You put in parts of the uptext that shows when you put your mouse over the object. For example:

    Let's say you're making a script to find and kill chickens. You'd want to set the colors of the chicken up in Colors (2 or 3 will do) before you do anything else. Then, figure out the uptext that pops up when your mouse over the object, in this example, a chicken. It would say 'Attack Chicken'.

    What do we put in Text? It's pretty easy.

    Take parts out of the uptext. I find that this makes it work alot better in the long run. So, instead of doing:

    SCAR Code:
    FindObjCustom(cx, cy, ['Attack Chicken'], [123412,1234234,123423], Tol);

    You'd want to do something like:

    SCAR Code:
    FindObjCustom(cx, cy, ['tta', 'ack', 'hick', 'ken'], [123412,1234234,123423], Tol);

    That way, it makes sure to pick up your chicken.

    Just remember: At this point, it simply finds the Chicken, but does not click it. You'd just have to follow up with Mouse, which I'll cover later.

    Okay, now for Tol. It's pretty simple, also.

    Each color you chose has a specific value, no? Meaning that it's a very precise color. Tolerance makes the function check for any color within a specified number around your colors that you chose earlier. Okay, easy to use, hard to explain.

    Usually, just use a number from 1 to 10 (higher depending on what you're looking for). I usually use around 5.

    Okay.. Last, but not least, comes CX and CY. They are the x and y values that the function stores the object's location at. Usually, you'd just put in x, y rather than cx, cy. Here, I'll show you.

    SCAR Code:
    FindObjCustom(x, y, ['tta', 'ack', 'hick', 'ken'], [123412,1234234,123423], 5);

    This way, you can use it with other functions (Though, technically, you can put any thing in for the x, y, value. X and Y are just easier to remember ), such as Mouse. Here's what it would look like:

    SCAR Code:
    FindObjCustom(x, y, ['tta', 'ack', 'hick', 'ken'], [123412,1234234,123423], 5);
    Mouse(x, y, 2, 2, True);

    Okay! So now you know how it works! I'll now show you how to work it into a simple script!

    NOT THE INTRODUCTION ANYMORE

    Let's do one of the simplest of scripts out there = a woodcutter. It can just be a script that finds and cuts down trees. I'll show you a simple one:

    SCAR Code:
    program Tutorial;
    {.include SRL/SRL.scar}
    var
      x, y, Color1, Color2, Color3: Integer;
     
    procedure FindAndChopTrees;
      begin
        Color1 := XXXXXXX;      //This won't compile unless you change the X's to an actual number.
        Color2 := XXXXXXX;
        Color3 := XXXXXXX;
        If (FindObjCustom(x, y, ['hop', 'ree'], [Color1, Color2, Color3], 5) then
          begin
            If(IsUptext('Chop Tree')) then  //Forgot to mention this.. It's a great failsafe!
              begin
                Mouse(x, y, 2, 2, True);
              end;
          end;
    end;

    begin
      FindAndChopTrees;
    end.

    (Also.. DON'T ACTUALLY AUTO WITH THIS SCRIPT! IT'S FOR EXAMPLE PURPOSES ONLY!)

    COLOR FINDING

    Confused on what I'm talking about involving colors, and getting them? Look no further!

    SCAR has a nice little color picking tool build in. It looks like a little eyedropper:



    What I do is take a screenshot of what I'm getting colors of. You can do this by hitting Print Screen at the top of your keyboard, then pasting it into Paint. Drag SCAR down so you can see the object above SCAR in paint, and click the tool. Move your mouse around until you find the colors you want on the object (Try to find the colors on it that stick out the most), then click your mouse. Repeat this until you have all the colors you need. Then, look in SCAR's debug box and, wham! It will show you the colors you got, and the location it found them in.

    Example:



    Now your colors are ready to use!

    THE ENDISH

    Okay, it was a short tutorial (sort of). I hope you learned something from it, because I've been here for about an hour working on it. Just post if you have any questions, and I'll answer them the best I can.

    Until next time,

    ProphesyOfWolf AKA Faelstorm

  2. #2
    Join Date
    Mar 2006
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    nice tut.. Wud be better if it had sum examples with pictures =]



    Dont Steal..

  3. #3
    Join Date
    Dec 2007
    Location
    Middle of Here and There
    Posts
    417
    Mentioned
    6 Post(s)
    Quoted
    25 Post(s)

    Default

    I have some examples there, and whatdya mean by pictures? =D

  4. #4
    Join Date
    Mar 2006
    Posts
    795
    Mentioned
    0 Post(s)
    Quoted
    6 Post(s)

    Default

    show them how to get the colour codes etc =].



    Dont Steal..

  5. #5
    Join Date
    Dec 2007
    Location
    Middle of Here and There
    Posts
    417
    Mentioned
    6 Post(s)
    Quoted
    25 Post(s)

    Default

    Updated ^^^


  6. #6
    Join Date
    Apr 2007
    Posts
    994
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    You could also tell them to just

    SCAR Code:
    var
      i:Tintegerarray;

    And

    SCAR Code:
    i:=[XXX,YYY,TTXXYY];

    That would make declaring the colours faster. Incidentally, I think this belongs in the beginners section, because Intermediates to advanced use Findobjtpa and other custom finders. Still, great tut.

    Rep to you.
    [QUOTE]<GoF`> oh no its Raymooond
    <Raymooond> Heya
    <GoF`> is it ray or some other ray?
    <LeeLokHin> No idea
    <LeeLokHin> Raymond, what's the game you like the most?
    <Raymooond> Runescape
    <-- LeeLokHin has kicked Raymooond from #srl (Faker.)[/QUOTE]

  7. #7
    Join Date
    Dec 2007
    Location
    Middle of Here and There
    Posts
    417
    Mentioned
    6 Post(s)
    Quoted
    25 Post(s)

    Default

    Indeed, I forgot about declaring the TIntegerArray's that way. Thanks for including it =D

    Thanks for the rep + =D

    Congratulations! Your rep level has gone from INFINITY to INFINITY + 1!

  8. #8
    Join Date
    Dec 2006
    Posts
    908
    Mentioned
    1 Post(s)
    Quoted
    17 Post(s)

    Default

    FindObjCustom is horrible for me....

  9. #9
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Very nice tutorial, but I would prefer if you taught the use of FindObjectTPA instead, as I (and many others) find it much more efficient.

  10. #10
    Join Date
    Jul 2008
    Posts
    7
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Good tutorial, I might use this function in a powerminer.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. help with FindObjCustom
    By cocodog13 in forum OSR Help
    Replies: 5
    Last Post: 04-17-2008, 09:14 AM
  2. The Beauty of MMBot
    By chubbsenoughsaid in forum The Bashing Club / BBQ Pit
    Replies: 22
    Last Post: 10-27-2007, 03:07 AM
  3. Help with FindObjCustom
    By 1q1q in forum OSR Help
    Replies: 7
    Last Post: 09-12-2007, 02:58 PM
  4. FindObjCustom Help
    By rodnman1234 in forum OSR Help
    Replies: 5
    Last Post: 08-25-2007, 07:25 PM

Posting Permissions

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