Results 1 to 16 of 16

Thread: I need some help/direction for first script

  1. #1
    Join Date
    Mar 2012
    Location
    Canada! Eh!
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default I need some help/direction for first script

    EDIT: I've already had a couple issues solved here but I keep progressing and I keep adding more features to my script. Inevitably that means more problems.

    I.e Rather then post a new question I'm just going to retailer this one. The title still fits.

    What I want the script to do is, first Chop Willows, then when the inventory is full, walk to destination and begin lighting the logs, when finished lighting the logs, return to chopping willows.

    My current problem is that once it has chopped down the willows, inventory is full, it walks to destination, then it wants to chop more trees rather then start the procedure for lighting the logs.

    I think the problem is in my mainloop.



    Simba Code:
    program ChopNBurn;

    {$i srl/srl.simba}
    {$i sps/sps.simba}


    Procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name :='';
      Players[0].Pass :='';
      Players[0].Nick :='';
      Players[0].Active:=True;
    end;

    procedure AntiBan;
    begin
      if(not(LoggedIn))then
      Exit;
      FindNormalRandoms;
      case Random(1000) of
        0:
       begin
         HoverSkill('Woodcutting', false);
         wait(2000+Random(1000));
       end;
        1: PickUpMouse;
        2:
       begin
         MakeCompass('N');
         wait(100+random(133));
         MakeCompass('S');
         wait(50+random(133));
         MakeCompass('NE');
         FindNormalRandoms;
       end;
        1: RandomRClick;
        2:
      end;
    end;

    function WillowTrunk: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(1.12, 3.02);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 1449756, MSX1, MSY1, MSX2, MSY2, 1);
      if (Length(arP) = 0) then
      begin
        Writeln('Failed to find the color, no result.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

      arC := GetColors(arP);
      ClearSameIntegers(arC);
      arL := High(arC);

      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 1.02) and (X <= 1.23) and (Y >= 1.19) and (Y <= 1.43) and (Z >= 0.82) and (Z <= 1.04) then
        begin
          Result := arC[i];
          Writeln('AutoColor = ' + IntToStr(arC[i]));
          Break;
        end;
      end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

      if (i = arL + 1) then
        Writeln('AutoColor failed in finding the color.');
    end;

    Function Chopping: Boolean;
      var
        PBox: TBox;
      begin
        PBox := IntToBox(245, 130, 285, 195);
        Result := (AveragePixelShift(PBox, 250, 500) > 750);
      end;

    procedure ChopTree;
    var
      x, y: integer;
    begin
         if (not Chopping) then
        repeat
        if FindObj(x, y, 'hop', WillowTrunk, 20) then
        begin
          Mouse(x, y, 0, 0, false);
          ChooseOption('hop');
        end;
        repeat
          wait(400+random(250));
          AntiBan;
        Until not IsUpText('illow') or (InvFull);
      until(InvFull);
    end;

    procedure WalkToFirePit;
    var
      myPath:TPointArray;
    begin
      SetupSRL;
      SPS_Setup(RUNESCAPE_SURFACE,['8_8','9_8','10_9','8_9','7_9','8_7','9_7','10_8']);
      myPath := [Point(3488, 3470), Point(3499, 3470), Point(3508, 3470), Point(3517, 3470),
                 Point(3531, 3470), Point(3543, 3470), Point(3555, 3470), Point(3568, 3470),
                 Point(3579, 3470), Point(3591, 3470), Point(3597, 3470), Point(3605, 3470)];
      SPS_WalkPath(myPath);
    end;


    procedure DropLogs;
    var
      x, y, LogDTM, I:Integer;
      SlotBox:TBox;
      LogPattern:TIntegerArray;

    begin
      LogDTM := DTMFromString('m1gAAAHic42JgYJjCwsDQBsT9QDwTiOcC8UIgngbEvVC5ZiBWZmRgkAFiSSAWBWJZRoiYNhDrQWklILYyFgKaykQEJg4wEokRAAB/sAfX');
      LogPattern := [1,5,9,13,17,21,25,2,6,10,14,18,22,26,3,7,11,15,19,23,27,4,8,12,16,20,24,28];

      for I := 0 to 27 do
      begin
        SlotBox := InvBox(LogPattern[I]);
        if FindDTM(LogDTM, x, y, SlotBox. X1, SlotBox. Y1, SlotBox. X2, SlotBox. Y2) then
        begin
          MouseItem (LogPattern[I], mouse_Right);
          wait(400+random(200));
          ChooseOption ('Light');
          wait (1500+random(500));
        end;
      end;
    end;

    begin
      SetUpSRL;
      ActivateClient;
      DeclarePlayers;
      LoginPlayer;
    repeat
    ChopTree;
    if invfull then
    begin
    WalkToFirePit;
    DropLogs;
    end;
      until (False);
    end.
    Last edited by coldblitz; 03-19-2012 at 03:45 PM. Reason: Better then opening a new question?
    Working On First Script
    .01% Completed
    <--- Me while I learn

  2. #2
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

    Default

    shouldn't it be until (True);?

    Also in the drop procedure what isn't it doing? is it right clicking then not dropping? I need a bit more of a detailed explanation as to what it DOES and what you WANT

  3. #3
    Join Date
    Jan 2009
    Location
    Turlock/LA, California
    Posts
    1,494
    Mentioned
    3 Post(s)
    Quoted
    66 Post(s)

    Default

    Quote Originally Posted by xtrapsp View Post
    shouldn't it be until (True);?
    repeat ... until(false); is just a standard infinite loop.

    maybe ur dtm isnt correct?

  4. #4
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

    Default

    Quote Originally Posted by x[Warrior]x3500 View Post
    repeat ... until(false); is just a standard infinite loop.

    maybe ur dtm isnt correct?
    Sorry it's late haha

    read over the OP a few times.. I still don't understand the issue fully

    Simba Code:
    procedure ChopTree;
    var
      x, y: integer;
    begin
        repeat
        if FindObj(x, y, 'hop', WillowTrunk, 20) then
        begin
          Mouse(x, y, 0, 0, false);
          ChooseOption('hop');
        end;
        repeat
          wait(400+random(250));
          AntiBan;
        Until not IsUpText('illow');
        if InvFull then  // It does the function before but if the inventory is full here while chopping it then drops logs ;) having it in the main loop could act as a backup?
        begin
         DropLogs;
        end;
    end;

    feel free to correct me if im wrong it's midnight and I'm tired as hell :P
    Last edited by xtrapsp; 03-17-2012 at 11:47 PM.

  5. #5
    Join Date
    Jul 2010
    Posts
    1,115
    Mentioned
    1 Post(s)
    Quoted
    10 Post(s)

    Default

    Simba Code:
    program WillowChopShop;

    {$i srl/srl.simba}

    Procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name :='';
      Players[0].Pass :='';
      Players[0].Nick :='';
      Players[0].Active:=True;
    end;

    procedure AntiBan;
    begin
      if(not(LoggedIn))then
      Exit;
      FindNormalRandoms;
      case Random(8) of
       0:
       begin
         HoverSkill('Woodcutting', false);
         wait(2000+Random(1000));
       end;
        1: PickUpMouse;
        2:
       begin
         MakeCompass('N');
         wait(100+random(133));
         MakeCompass('S');
         wait(50+random(133));
         MakeCompass('N');
         FindNormalRandoms;
       end;
        1: RandomRClick;
        2:
      end;
    end;

    function WillowTrunk: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(1.12, 3.02);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 1449756, MSX1, MSY1, MSX2, MSY2, 1);
      if (Length(arP) = 0) then
      begin
        Writeln('Failed to find the color, no result.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

      arC := GetColors(arP);
      ClearSameIntegers(arC);
      arL := High(arC);

      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 1.02) and (X <= 1.23) and (Y >= 1.19) and (Y <= 1.43) and (Z >= 0.82) and (Z <= 1.04) then
        begin
          Result := arC[i];
          Writeln('AutoColor = ' + IntToStr(arC[i]));
          Break;
        end;
      end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

      if (i = arL + 1) then
        Writeln('AutoColor failed in finding the color.');
    end;

    procedure ChopTree;
    var
      x, y: integer;
    begin
        repeat
        if FindObj(x, y, 'hop', WillowTrunk, 20) then
        begin
          Mouse(x, y, 0, 0, false);
          ChooseOption('hop');
        end;
        repeat
          wait(400+random(250));
          AntiBan;
        Until not IsUpText('illow') or (InvFull);
      until(InvFull);
    end;



    procedure DropLogs;
    var
      x, y, LogDTM, I:Integer;
      SlotBox:TBox;
      LogPattern:TIntegerArray;

    begin
      LogDTM := DTMFromString('mggAAAHicY2NgYHBjYmCwBmJzJgjbC4iDgPgpIwPDbSB+C8Q3gfgNED8CYgtDQaAuJiwYO2DEgSEAANXrB5E=');
      LogPattern := [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28];

      for I := 0 to 27 do
      begin
        SlotBox  := InvBox(LogPattern[I]);
        if FindDTM(LogDTM, x, y, SlotBox. X1, SlotBox. Y1, SlotBox. X2, SlotBox. Y2) then
        begin
          MouseItem (LogPattern[I], mouse_Right);
          ChooseOption ('Dro');
        end;
      end;
    end;


    begin
      SetUpSRL;
      ActivateClient;
      DeclarePlayers;
      LoginPlayer;
      repeat
      ChopTree;
      if InvFull then
      DropLogs;
      until (False);
    end.

    compiles for me.
    you were missing an end in droplogs, and its no longer true/false for mouse procedures. i changed it to mouse_right because im assuming thats what you wanted. and more help you need?

    Havent tested the script to see if it actually works, but i did get it to compile

  6. #6
    Join Date
    Feb 2012
    Location
    DON'T PM ME ASKING FOR STUFF
    Posts
    2,170
    Mentioned
    38 Post(s)
    Quoted
    423 Post(s)

    Default

    Quote Originally Posted by bolshak25 View Post
    Simba Code:
    program WillowChopShop;

    {$i srl/srl.simba}

    Procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name :='';
      Players[0].Pass :='';
      Players[0].Nick :='';
      Players[0].Active:=True;
    end;

    procedure AntiBan;
    begin
      if(not(LoggedIn))then
      Exit;
      FindNormalRandoms;
      case Random(8) of
       0:
       begin
         HoverSkill('Woodcutting', false);
         wait(2000+Random(1000));
       end;
        1: PickUpMouse;
        2:
       begin
         MakeCompass('N');
         wait(100+random(133));
         MakeCompass('S');
         wait(50+random(133));
         MakeCompass('N');
         FindNormalRandoms;
       end;
        1: RandomRClick;
        2:
      end;
    end;

    function WillowTrunk: Integer;
    var
      arP: TPointArray;
      arC: TIntegerArray;
      tmpCTS, i, arL: Integer;
      X, Y, Z: Extended;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(1.12, 3.02);

      FindColorsSpiralTolerance(MSCX, MSCY, arP, 1449756, MSX1, MSY1, MSX2, MSY2, 1);
      if (Length(arP) = 0) then
      begin
        Writeln('Failed to find the color, no result.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

      arC := GetColors(arP);
      ClearSameIntegers(arC);
      arL := High(arC);

      for i := 0 to arL do
      begin
        ColorToXYZ(arC[i], X, Y, Z);

        if (X >= 1.02) and (X <= 1.23) and (Y >= 1.19) and (Y <= 1.43) and (Z >= 0.82) and (Z <= 1.04) then
        begin
          Result := arC[i];
          Writeln('AutoColor = ' + IntToStr(arC[i]));
          Break;
        end;
      end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

      if (i = arL + 1) then
        Writeln('AutoColor failed in finding the color.');
    end;

    procedure ChopTree;
    var
      x, y: integer;
    begin
        repeat
        if FindObj(x, y, 'hop', WillowTrunk, 20) then
        begin
          Mouse(x, y, 0, 0, false);
          ChooseOption('hop');
        end;
        repeat
          wait(400+random(250));
          AntiBan;
        Until not IsUpText('illow') or (InvFull);
      until(InvFull);
    end;



    procedure DropLogs;
    var
      x, y, LogDTM, I:Integer;
      SlotBox:TBox;
      LogPattern:TIntegerArray;

    begin
      LogDTM := DTMFromString('mggAAAHicY2NgYHBjYmCwBmJzJgjbC4iDgPgpIwPDbSB+C8Q3gfgNED8CYgtDQaAuJiwYO2DEgSEAANXrB5E=');
      LogPattern := [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28];

      for I := 0 to 27 do
      begin
        SlotBox  := InvBox(LogPattern[I]);
        if FindDTM(LogDTM, x, y, SlotBox. X1, SlotBox. Y1, SlotBox. X2, SlotBox. Y2) then
        begin
          MouseItem (LogPattern[I], mouse_Right);
          ChooseOption ('Dro');
        end;
      end;
    end;


    begin
      SetUpSRL;
      ActivateClient;
      DeclarePlayers;
      LoginPlayer;
      repeat
      ChopTree;
      if InvFull then
      DropLogs;
      until (False);
    end.

    compiles for me.
    you were missing an end in droplogs, and its no longer true/false for mouse procedures. i changed it to mouse_right because im assuming thats what you wanted. and more help you need?

    Havent tested the script to see if it actually works, but i did get it to compile

    didn't realise it was the compiling that was the issue Didn't try it :P

  7. #7
    Join Date
    Mar 2012
    Location
    Canada! Eh!
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by bolshak25 View Post
    compiles for me.
    you were missing an end in droplogs, and its no longer true/false for mouse procedures. i changed it to mouse_right because im assuming thats what you wanted. and more help you need?

    Havent tested the script to see if it actually works, but i did get it to compile
    Would you believe I spent three hours trying to do the same thing over and over again while expecting a different result? Definition of insanity right there.

    Only other thing I wouldn't mind knowing is how do I stop my script from trying to chop another tree, or even the same tree, while still chopping the current one?

    +rep... if I can figure out how

    Quote Originally Posted by xtrapsp View Post
    didn't realise it was the compiling that was the issue Didn't try it :P
    Ya, I guess that was kind of my fault. I should have mentioned it was a compiling issue.
    Last edited by coldblitz; 03-18-2012 at 01:07 AM.
    Working On First Script
    .01% Completed
    <--- Me while I learn

  8. #8
    Join Date
    Jul 2010
    Posts
    1,115
    Mentioned
    1 Post(s)
    Quoted
    10 Post(s)

    Default

    Quote Originally Posted by coldblitz View Post
    Only other thing I wouldn't mind knowing is how do I stop my script from trying to chop another tree, or even the same tree, while still chopping the current one?
    http://villavu.com/forum/showthread.php?t=74090

    Pixelshift should be what your looking for. i havent read up on how to use it, but its good for this kind of thing

  9. #9
    Join Date
    Mar 2012
    Location
    Canada! Eh!
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    As it turns out all this script is good for is right clicking the trees, selecting chop, then repeating that process. Such a headache. Thanks for the help guys. Much obliged. Time to scrap it and start anew. I'll get one right eventually.
    Working On First Script
    .01% Completed
    <--- Me while I learn

  10. #10
    Join Date
    Jul 2010
    Posts
    1,115
    Mentioned
    1 Post(s)
    Quoted
    10 Post(s)

    Default

    try in the mainloop putting
    if invfull then
    drop
    before
    choptree
    otherwise it would keep doing choptree forever

  11. #11
    Join Date
    Mar 2012
    Location
    Canada! Eh!
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by bolshak25 View Post
    try in the mainloop putting
    if invfull then
    drop
    before
    choptree
    otherwise it would keep doing choptree forever
    You saved my script from going straight into the garbage and also got me excited again for what I've achieved and what I aim to achieve. Thank you.

    Mind you after I tried this it still didn't work but that was because my LogDTM needed to be reworked. I don't think I made enough points the first time.

    I can hardly believe I've actually put together a working script. It's primitive, but it works. Also, I switched things up a little and rather then simply dropping the logs, I'm lighting them. Why not train two skills at once? That part is working.

    Two things left to do

    1. Figure out pixelshift so my guy stops trying to chop the same tree over and over. So annoying and I'm sure that's something jagex will spot. [DONE]

    2. Incorporate some walking into the script so it walks to a set destination and begins lighting the logs... I've herd this is tough to do but lucky for me I only need to walk one way. After that, lighting the logs can be done in one long line which will bring me right back to the base of a willow tree.
    Last edited by coldblitz; 03-19-2012 at 12:06 AM.
    Working On First Script
    .01% Completed
    <--- Me while I learn

  12. #12
    Join Date
    Jul 2010
    Posts
    1,115
    Mentioned
    1 Post(s)
    Quoted
    10 Post(s)

    Default

    well change the mainloop to
    repeat
    chop;
    if invfull then
    begin
    walk;
    light;
    end;
    until ... blah blah

    that would keep chopping until the inv is full then it will do the other items because they are in the begin end. in yours it would light them even if inv wasnt full. i dont know anything with sps so im no help there

  13. #13
    Join Date
    Mar 2012
    Location
    Canada! Eh!
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by bolshak25 View Post
    well change the mainloop to
    repeat
    chop;
    if invfull then
    begin
    walk;
    light;
    end;
    until ... blah blah

    that would keep chopping until the inv is full then it will do the other items because they are in the begin end. in yours it would light them even if inv wasnt full. i dont know anything with sps so im no help there
    I fixed the sps issue. It was simple once I noticed I was missing a single line

    Simba Code:
    SetupSRL;

    I tried your mainloop recommendation but it's not working for me. The individual procedures all work on there own, I know that, now it's simply a matter of putting them together in a way that works.

    Chop willows > Walk > Light > repeat
    Working On First Script
    .01% Completed
    <--- Me while I learn

  14. #14
    Join Date
    Jul 2010
    Posts
    1,115
    Mentioned
    1 Post(s)
    Quoted
    10 Post(s)

    Default

    try putting a
    writeln('walked now lighting');
    right after the first begin in droplogs. thatsll tell us if it gets there

  15. #15
    Join Date
    Mar 2012
    Location
    Canada! Eh!
    Posts
    18
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by bolshak25 View Post
    try putting a
    writeln('walked now lighting');
    right after the first begin in droplogs. thatsll tell us if it gets there
    It was a stupid problem. When I previously fixed the DTM I didn't save so when I reopened the script I couldn't for the life of me figure out why... fixed the DTM once again and made sure I saved it this time.

    Mind you I have more problems... forever more.

    1. I need to set my DropLog procedure so it only goes to light another log once it has -1 log in inventory (I don't know how to do that but if I search the forums long enough I sure I can find the proper code.

    2. If I let the script run for any length of time it eventually goes to chop a tree that is not a willow. I'm again not entirely sure how to fix this but I'm sure with enough playing around I'll find a solution.

    EDIT:

    3. I also need to free the LogDTM.
    Working On First Script
    .01% Completed
    <--- Me while I learn

  16. #16
    Join Date
    Jul 2010
    Posts
    1,115
    Mentioned
    1 Post(s)
    Quoted
    10 Post(s)

    Default

    add some variables to the droplogs. integers.
    wait(400+random(200));
    ChooseOption ('Light');
    m:=Invcount;
    repeat
    wait (1500+random(500));
    until invcount<m

    something similar to that.
    put
    Freedtm(LOGDTM);
    before the last end; in droplogs

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
  •