Results 1 to 7 of 7

Thread: A newby question about FindObj().

  1. #1
    Join Date
    Jul 2012
    Location
    System 32
    Posts
    47
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default A newby question about FindObj().

    I followed Griff's tutorial on 'Scripting down your first tree' and found that ..

    Simba Code:
    FindObj(x, y, 'hop_down_Oak', 3623506, 35)

    //Instead of ...

    FindObj(x, y, 'hop', 3623506, 35)

    .. works more accurately for chopping down specifically oak trees (for example), since the colours on trees are so similar.

    Is there a better way of making it more accurate? Any reason I SHOULDN'T do this?

    Any advice is appreciated.

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    The color tolerance of 35 is pretty high, u can try use ACA and autocolor and reduce the tolerance such that the color dont conflict with other trees. Also u can just change the up text check to 'Oak' or similar to fasten the search. (unless there are other items with similar color to oak trees and has 'Oak' as their up text too)

    Usually for skills like wc/mining we use spiral functions so that it starts searching from the centre (i.e. closest tree to you) but for a first script you may not want to go into that yet

  3. #3
    Join Date
    Jul 2012
    Location
    System 32
    Posts
    47
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hmm. I did some messing around and found that a tolerance of 13-17 works much better than 35; so thanks for that tip.

    About the up text thing.. I noticed that when it finds the colour and recognizes it as an Oak tree, it right clicks and selects chop, like it should. But, if the mouse happens to move off of the tree (thus removing the up text of 'Oak'), it starts the search all over again. In all logic by the way I have my loop scripted, this SHOULD happen.

    Simba Code:
    procedure CutOak;

    begin
      repeat
        if FindObj(x, y, 'hop down Oak', 3623506, 15) then
          Mouse(x, y, 2, 2, false);
          ChooseOption('hop down Oak');
        repeat
          Wait(1200 + Random(250));
        until not IsUpText('Oak') or (InvFull); //Based on this line, of course.
      until (InvFull);
    end;

    Would there be a better way to script this so it will actually wait for the tree to finish being cut? I've looked into pixel shift a little, but don't completely have that down. Maybe I'll take another look at the tutorial on it. However, if there's a better way, please let me know.

    PS: I've tried using DTMs to find Oak trees. I can get it pretty accurate, but I can't see to find the right points to be spot on, without detecting a normal (or any other) tree.

  4. #4
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Simba Code:
    procedure CutOak;
    var
      t: Integer;
    begin
      repeat
        if FindObj(x, y, 'hop down Oak', 3623506, 15) then
        begin  //need a begin to perform >1 actions after a conditional statement
          Mouse(x, y, 2, 2, false);
          WaitOption('hop down Oak',1000); //in case of lag the option wont appear right after u click
         t:=GetSystemTime+RandomRange(10000,15000);
         repeat
          Wait(1200 + Random(250));
          if t<GetSystemTime then break;
        until not IsUpText('Oak') or (InvFull); //Based on this line, of course.
      until (InvFull);
    end;
    I've added a break that it will break out of the wait after 10-15 sec (u can change the timing), uptext check would be highly unreliable though as your character will move when u run to the tree and ur mouse will be off the tree right away. AveragePixelShift is the most reliable/efficient method but u can use a loop with GetXpBar to make it stop until say, no xp gained for 5sec, not to efficient if u take quite long to cut the tree though.

  5. #5
    Join Date
    Jul 2012
    Location
    System 32
    Posts
    47
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Great tip on the WaitOption.

    A question though, just for clarity:
    I couldn't find an explained documentation for GetSystemTime, but I'm assuming that the line " t:=GetSystemTime+RandomRange(10000,15000); " sets the integer 't' to the current system time + anywhere between 10 and 15 seconds? If this is the case, then does the line " if t<GetSystemTime then break; " mean that if t (system time + 10-15 seconds) becomes less than the new current system time, it will stop the current loop to prevent an accidental infinite loop?

    Sorry if it's a dumb question; I just learn by asking.

    With that said...
    Is this debug written correctly?
    Simba Code:
    t := GetSystemTime+RandomRange(10000,15000);
    repeat
      Wait(1200 + Random(250));
      if t < GetSystemTime then
        begin
          Break;
          Writeln('Waited too long, ending loop');
        end;
    until not IsUpText('ak') or (InvFull);
    Last edited by Etrnl Fear; 07-31-2012 at 01:02 AM.

  6. #6
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Etrnl Fear View Post
    Great tip on the WaitOption.

    A question though, just for clarity:
    I couldn't find an explained documentation for GetSystemTime, but I'm assuming that the line " t:=GetSystemTime+RandomRange(10000,15000); " sets the integer 't' to the current system time + anywhere between 10 and 15 seconds? If this is the case, then does the line " if t<GetSystemTime then break; " mean that if t (system time + 10-15 seconds) becomes less than the new current system time, it will stop the current loop to prevent an accidental infinite loop?

    Sorry if it's a dumb question; I just learn by asking.
    Yeah you are right, you can also use MarkTime and TimeFromMark to achieve the same effect, though an extra variable will have to be created to exit on a RandomRange.
    Quote Originally Posted by Etrnl Fear View Post
    With that said...
    Is this debug written correctly?
    Simba Code:
    t := GetSystemTime+RandomRange(10000,15000);
    repeat
      Wait(1200 + Random(250));
      if t < GetSystemTime then
        begin
          Break;
          Writeln('Waited too long, ending loop');
        end;
    until not IsUpText('ak') or (InvFull);
    You should put the writeln before the break, because once it breaks its going to ignore everything within that loop so writeln wont be executed.

  7. #7
    Join Date
    Jul 2012
    Location
    System 32
    Posts
    47
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hah, yeah I caught that later on.

    It runs better than it did, so thanks for the help.
    Without chaos... There would be no organization.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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