Results 1 to 5 of 5

Thread: Script seems to be skipping a step.

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

    Default Script seems to be skipping a step.

    Kind of stuck on this part of my first script. It's supposed to check if it's at the Oak trees north of Falador, and if it isn't, it teleports to the Falador Lodestone and walks there. It went great at first, but it wouldn't continue after arriving at the Lodestone and waiting 5 seconds (to make sure the player has stepped off the Lodestone). So, I tried to fix it (can't remember what exactly I changed) and now it seems to skip a step. I added in a few Writeln functions to see where it was skipping.

    Here's the procedure
    Simba Code:
    var //Variables set after defining smart and SRL.
      x, y, FallyTrees: Integer;
      F: Array [0..6] of Integer;
      aFound: Extended;

    procedure LocationCheck;

    FallyTrees := DTMFromString('mlwAAAHicY2dgYOAFYnkglgFibgYIkARiaSDmgIqB5CWgckxALArEATEKDO6B6gyewRpgtqU5F4N8uAiDfqIEAz9QHhdmxIOhAAAEUgYn');

    begin
      if not FindDTMRotated(FallyTrees, x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) then
      begin
      //Set DTMs to home tele to Falador and walk to trees.
        begin
          F[0] := DTMFromString('m1gAAAHic42JgYHjNxMDwGIg/AfEjIP4MxG+B+AkQf2SCyL8E4jdAtY+B+BEQf4fibwwQ8bdA/AyIPwNxhqcaQ1FKIENWrDeYBmFzZXGG1hBFhg1zKxgaE3UYirJ8GfiBaonBjERiBAAASlwd9g==');
          F[1] := DTMFromString('mlwAAAHicY2dgYLBlgmArIHYCYhsgNgViRyAWZ2RgEABiMSCWBmI5RoiYMBDvO/KJYeXepwx///5laJtzA45b848y8APNxYUZ8WAoAAADIBIy');
          F[2] := DTMFromString('mlwAAAHicY2dgYBBlZGCQB2IuRghbBIj5gVgaiH8D5d9DMQ+Q/xFIMzBC8Pw1Wxj0XCoZXr55w3Bo2UQG5/yFDHzW5Qy8xhkM/EAluDAjHgwFAFhSD0g=');
          F[3] := DTMFromString('mbQAAAHicY2VgYMhlYmAoAuIIIM4A4gAg7gSKpwBxDRBPBOJMIHZy1GR4+5aBwSReksHWUpUhRo+bgR8ojo4ZsWAwAACC+AkU');
          F[4] := DTMFromString('mggAAAHicY2NgYAhiYmCIBmJ3KJ0MxH5A3AaUqwHiRiCewADhlwKxp78yg2KoABi7eigwZCa4MXgHqjDwA+WwYUYcGAIANMEJxA==');
          F[5] := DTMFromString('mlwAAAHicY2dgYAhgYmCIhmI/II4D4nggzgbiBqB8BRB3AnEfENcB8SQgbgbi0FhNMA6KkgFjw3gRhkg9NgbFUAEGfqA8LsyIB0MBAIENC6E=');
          F[6] := DTMFromString('mlwAAAHicY2dgYJjMxMAwDYg7gHgKEM+EsnuB+ANQ/hkQvwHir0D8EYi/APFTIC72lGBYXaTGkGIvBsfmyuIMNV5SDPxAeVyYEQ+GAgCqjBCN');
        end; //It seems to exit the procedure after this point. I'm not sure why, because I didn't change anything before it. :x
               // Also, the spell book shows up as the only matching DTM, if imported into the DTM editor.
        //Click Spell Book
        if FindDTM(F[0], x, y, 0, 0, 502, 502) then
        begin
          Mouse(x, y, 2, 2, True);
          repeat
            Wait(500 + Random(500));
          until FindDTM(F[1], x, y, MIX1, MIY1, MIX2, MIY2);
        end;
        //Click Home Teleport
        if FindDTM(F[1], x, y, MIX1, MIY1, MIX2, MIY2) then
        begin
          Mouse(x, y, 2, 2, True);
          Wait(1000 + Random(500));
        end;
        //Click Falador Lodestone and wait for arrival.
        if FindDTMRotated(F[2], x, y, MSX1, MSY1, MSX2, MSY2, -Pi, Pi, Pi/30, aFound) then
        begin
          Mouse(x, y, 2, 2, True);
          repeat
            wait(500 + Random(250));
          Until FindDTMRotated(F[3], x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound)
          Wait(4000 + Random(1500));
        end;
        //Click first point of path to trees.
        if FindDTMRotated(F[4], x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) then
        begin
          Mouse(x, y, 2, 2, True);
          repeat
            Wait(100 + Random(50));
          until FindDTMRotated(F[5], x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound)
        end;
        //Click second point of path to trees.
        if FindDTMRotated(F[5], x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) then
        begin
          Mouse(x, y, 2, 2, True);
          Wait(500 + Random(250));
        end;
        //Free DTMs.
        begin
          FreeDTM(F[0]);
          FreeDTM(F[1]);
          FreeDTM(F[2]);
          FreeDTM(F[3]);
          FreeDTM(F[4]);
          FreeDTM(F[5]);
          FreeDTM(FallyTrees);
          //F[6] is freed later on before beginning the woodcutting procedure (It's the inventory icon).
        end;
      end;
    end;

    begin //And this is what I have in the main loop that would require it to run.
      ClearDebug;
      SetupSRL;
      DeclarePlayers;
      LoginPlayer;
      MouseSpeed := 18

      LocationCheck;
    end.

    Any help is appreciated.

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

    Default

    Your conditional statement is 'if not FindDTMRotated(FallyTrees', so if it DID find fally tree its going to end str8? You should add a debug (end else writeln('found fally tree').

    Also all your FindDTM procedures following each other are w/o waits, you should use WaitFindDTM in case it haven't finish the previous actions.

    Begin and end at the first part (right after the 2nd begin) is not needed too, u only need it for conditional statements etc.

    Avoid infinite loops like
    Simba Code:
    repeat
            Wait(500 + Random(500));
          until FindDTM(F[1], x, y, MIX1, MIY1, MIX2, MIY2);
    either make it break out after certain time or just use WaitFindDTM (pre-coded loop that breaks out after the preset time)

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

    Default

    I added Writeln functions after each segment to make sure it was finding everything properly. Although, I did take those out before posting, for unknown reasons... :P The last thing it did before moving on to the Chopping procedure (found by adding Writeln at the start) was Set DTMs.

    Ahh. So, if I were to use WaitFindDTMEx instead of FindDTM and loop a Wait until the next DTM was found, I would:

    Replace these conditions
    Simba Code:
    if FindDTM(F[0], x, y, 0, 0, 530, 502) then
      begin
        Mouse(x, y, 2, 2, True);
        repeat
          Wait(500 + Random(500));
        until FindDTM(F[1], x, y, MIX1, MIY1, MIX2, MIY2);
      end;
    if FindDTM(F[1], x, y, MIX1, MIY1, MIX2, MIY2) then
      begin
        Mouse(x, y, 2, 2, True);
        Wait(1000 + Random(500));
      end;

    With these?
    Simba Code:
    if (WaitFindDTMEx(F[0], x, y, 0, 0, 530, 502, 2000)) then
        Mouse(x, y, 2, 2, True);
    if (WaitFindDTMEx(F[1], x, y, MIX1, MIY1, MIX2, MIY2, 2000)) then
        Mouse(x, y, 2, 2, True);

    Or would I still need a wait after the Mouse functions?

    Oh, I see now. The infinite loop would be, if the DTM is 'not' found?
    Last edited by Etrnl Fear; 07-31-2012 at 05:11 AM.

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

    Default

    U can just increase the 2nd wait in case it takes longer than 2 sec to get to the next location. Your parameter is wrong though, u missed a WaitPerLoop.

    Also you should always consider the case where if the DTM is still not found (even after the wait), and make it restart from start or sth.

    Also you can just use GameTab(tab_Magic) to switch to the spell tab.

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

    Default

    Aha; that's why it kept saying invalid number of parameters, even though I mimicked the example on the documentation.. :P The example doesn't show a WaitPerLoop. So, that is fixed for now but as usual with debugging, it just spikes another error. Blah

    Maybe I'm just trying to script too far ahead of where I should be. I'll put this script on hold and read through the basic tutorials again; I probably just need a refresher on things.

    But, thanks a bunch for your replies; you've been a big help!
    + Rep.
    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)

Posting Permissions

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