Results 1 to 7 of 7

Thread: First script, help?

  1. #1
    Join Date
    Jan 2007
    Posts
    181
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default First script, help?

    Hey guys, managed to piece together a script through a lot of reading and learning by example from other chopping scripts. Was wondering if any experienced scripters here could take a look through my code below and let me know what i'm doing wrong and where I could improve. Script doesn't seem to move onto my fletching procedure after the inventory is full and i'm not sure why

    Simba Code:
    program oakFletcher;

    {$I SRL/SRL.Simba}
    {$I P07Include.Simba}

    var
      X,Y, knifeDTM,logDTM: Integer;


    //procedure P07_DeclarePlayers;
    //  begin
    //    P07_PlayerName := u;
    //    P07_PlayerPass := password;
    //  end;

      Procedure DTMshere;
      begin
      knifeDTM := DTMFromString('mQwAAAHicY2ZgYKhlYWDoBuJWIE5iZGDwBOJQIC7MzGTISU1lyEtPZ+AEqoNhRiQMBAAPugZz');
      logDTM := DTMFromString('mggAAAHicY2NgYDjExMCwG4hPA/EOID4GxFuB+AlQ7i0QvwTih0B8D8quiDFnWNYWy9CT4wCmW1JtGGbVhDFgA5xAzIgDQwAAE1ER5Q==');
      //longBow := DTMFromString('mWAAAAHicY2EAAkYGBhEg5gdicSBuAeLFQDwViFcCcXY4L8PkcgGGufUCDJ35AgzogBENgwAAYo0GzQ==');
      end;
    Procedure ChopOak;
    Begin

    repeat
      if p07_findobjCustom(x,y, ['Oak'], [3103827, 1123615], 5) then
    writeln('Found Oak');
        Wait(500 + Random(153));
          P07_MouseBox(X, Y, X, Y, mouse_left);  //Moves Mouse to tree
     Writeln('Clicked Oak');
      P07_MakeCompassDegree(RandomRange(25,260));
          Wait (RandomRange(5000,6000))
    until(P07_InvFull)
     end;

    Procedure FletchBows;
    bEGIN

    wait(random(1100));
    if(findDTM(knifeDTM, x, y, P07_MIX1, P07_MIY1, P07_MIX2, P07_MIY2)) then
    begin
     p07_mousebox(x, y, x, y, mouse_left);  // Found and clicked on knife

     wait(random(300));
     if(FindDTM(logDTM, x, y, P07_MIX1, P07_MIY1, P07_MIX2, P07_MIY2)) then
     mmouse(x, y, 4, 4);
     clickmouse2(mouse_left);
     writeln('Found Log')
     wait(random(259));
     //if(findDTM(longBow, x, y, P07_MIX1, P07_MIY1, P07_MIX2, P07_MIY2)) then
          mmouse( x, y, 4, 4);
          wait(15+random(8));
          clickmouse2(mouse_right);
        P07_ChooseOptionMulti(['10']);
        wait(18000+random(12700));


    end;

    //Procedure FreeDTMs;
    //begin
    //(knifeDTM);
    //FreeDTM(OakLogDTM);
    //FreeDTM(longBow);
    end;

    begin
    MouseSpeed := 15;
    //SetupSRL();
    //ClearDebug;
    //writeln '- Oak Cutter and Fletcher (v0.1)
      SetupP07Include;
      repeat
    ChopOak;
    FletchBows;
    //FreeDTMs;
    until(not p07_loggedin);
    end.

  2. #2
    Join Date
    Oct 2012
    Posts
    758
    Mentioned
    6 Post(s)
    Quoted
    282 Post(s)

    Default

    Hey, this is looking really good - good job!
    http://villavu.com/forum/showthread.php?t=78418
    AddOnTerminate('FreeDTMs') before the start of main loop after calling them.
    If DTMExist(etc..) Then
    Free DTM ---

    Also you might want to see http://villavu.com/forum/showthread.php?t=60288 on standards.

    As for your procedure fletch bows...
    Please see //comments I added!
    Simba Code:
    Procedure FletchBows;
    bEGIN

    wait(random(1100));
    if(findDTM(knifeDTM, x, y, P07_MIX1, P07_MIY1, P07_MIX2, P07_MIY2)) then
    begin
     p07_mousebox(x, y, x, y, mouse_left);  //I think your problem is here ..Use mmouse(x,y and clickmouse2 as with the others!
     wait(random(300));
     if(FindDTM(logDTM, x, y, P07_MIX1, P07_MIY1, P07_MIX2, P07_MIY2)) then
    //begin here
     mmouse(x, y, 4, 4);
     clickmouse2(mouse_left);
     writeln('Found Log')
     wait(random(259));
     //if(findDTM(longBow, x, y, P07_MIX1, P07_MIY1, P07_MIX2, P07_MIY2)) then
    //begin also needed here since more than 1 line follows
          mmouse( x, y, 4, 4);
          wait(15+random(8));
          clickmouse2(mouse_right);
        P07_ChooseOptionMulti(['10']);
        wait(18000+random(12700));

    //for every begin an end - sorry I can't really see well with this :)
    end
    else
    Writeln('We didn't find the DTM knifeDTM') //more writeln if you don't know what's going on or where it's messing up on! Debug everything!
    end;

    Chances are it's not finding your DTM, but until then you just need to debug Writeln more to see what's happening.

  3. #3
    Join Date
    Jan 2007
    Posts
    181
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for the feed back, have you got any idea why after the inventory is full it doesn't move onto the Fletch procedure and merely continues to click the tree?

  4. #4
    Join Date
    Oct 2012
    Posts
    758
    Mentioned
    6 Post(s)
    Quoted
    282 Post(s)

    Default

    Quote Originally Posted by Hamish View Post
    Thanks for the feed back, have you got any idea why after the inventory is full it doesn't move onto the Fletch procedure and merely continues to click the tree?
    Are you sure that's what is happening? You have ChopOak and FletchBows looping and if it doesn't find the DTM in FletchBows it just does ChopOak again.
    Now over to ChopOak ->
    Since you are in a repeat until loop it checks the condition at the end so naturally it would just go ahead and try to chop more oak since it only checks the condition after going through it once at the end of the loop!
    You need more writeln etc... to see exactly what is going on and include If p07_InvFull Then Exit; in your ChopOak procedure at the start or change that repeat loop to a while do.

  5. #5
    Join Date
    Jan 2007
    Posts
    181
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I hadn't called my DTM's haha, silly me.

    Simba Code:
    program oakFletcher;

    {$I SRL/SRL.Simba}
    {$I P07Include.Simba}

    var
      X,Y, knifeDTM,logDTM: Integer;


    //procedure P07_DeclarePlayers;
    //  begin
    //    P07_PlayerName := u;
    //    P07_PlayerPass := password;
    //  end;

      Procedure DTMshere;
      begin
      knifeDTM := DTMFromString('mQwAAAHicY2ZgYKhlYWDoBuJWIE5iZGDwBOJQIC7MzGTISU1lyEtPZ+AEqoNhRiQMBAAPugZz');
      logDTM := DTMFromString('mggAAAHicY2NgYDjExMCwG4hPA/EOID4GxFuB+AlQ7i0QvwTih0B8D8quiDFnWNYWy9CT4wCmW1JtGGbVhDFgA5xAzIgDQwAAE1ER5Q==');
      //longBow := DTMFromString('mWAAAAHicY2EAAkYGBhEg5gdicSBuAeLFQDwViFcCcXY4L8PkcgGGufUCDJ35AgzogBENgwAAYo0GzQ==');
      end;
    Procedure ChopOak;
    Begin

    repeat
      if p07_findobjCustom(x,y, ['Oak'], [3103827, 1123615], 5) then
    writeln('Found Oak');
        Wait(500 + Random(153));
          P07_MouseBox(X, Y, X, Y, mouse_left);  //Moves Mouse to tree
     Writeln('Clicked Oak');
      P07_MakeCompassDegree(RandomRange(25,260));
          Wait (RandomRange(5000,6000))
    until(P07_InvFull)
     end;

    Procedure FletchBows;
    bEGIN

    wait(random(900));
    if(findDTM(knifeDTM, x, y, P07_MIX1, P07_MIY1, P07_MIX2, P07_MIY2)) then
    //writeln('found knife')
    begin
    mmouse(x, y, 4, 4); // Found and clicked on knife
    clickmouse2(mouse_left);
     wait(random(300));
    if(FindDTM(logDTM, x, y, P07_MIX1, P07_MIY1, P07_MIX2, P07_MIY2)) then
    //writeln('found log')
     Begin
     mmouse(x, y, 4, 4);
     clickmouse2(mouse_left);
     //writeln('Found Log')
     wait(random(259));

     //if(findDTM(longBow, x, y, P07_MIX1, P07_MIY1, P07_MIX2, P07_MIY2)) then
     Begin
          mmouse( 255, 394, 4, 4);
          wait(15+random(8));
          clickmouse2(mouse_right);
          wait(50+random(35));
        P07_ChooseOptionMulti(['10']);
        wait(18000+random(12700));

    end;
    end;

     end else
    //Writeln('We didn't find the DTM knifeDTM') //more writeln if you don't know what's going on or where it's messing up on! Debug everything!
    end;

    Procedure FreetheDTM;
    begin
    FreeDTM(knifeDTM);
    FreeDTM(logDTM);
    //FreeDTM(longBow);
    end;

    begin
    //MouseSpeed := 15;
    //SetupSRL();
    //ClearDebug;
    //writeln '- Oak Cutter and Fletcher (v0.1)
      SetupP07Include;
      DTMshere;
    ChopOak;
    FletchBows;
    FreetheDTM;
    writeln('free the dtms')
    //until(not p07_loggedin);
    end.


    This chops a full load of oaks then fletches 10 longbows, can't believe that took so long.

  6. #6
    Join Date
    Oct 2012
    Posts
    758
    Mentioned
    6 Post(s)
    Quoted
    282 Post(s)

    Default

    Good job! Keep it up!

  7. #7
    Join Date
    Jan 2007
    Posts
    181
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks for your help mate

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
  •