Results 1 to 15 of 15

Thread: Starting to script - Development Diary

  1. #1
    Join Date
    Nov 2011
    Location
    Australia
    Posts
    418
    Mentioned
    2 Post(s)
    Quoted
    86 Post(s)

    Default Starting to script - Development Diary

    Hi guys, I have decided I wanted to learn how to script for Simba. I thought I'd make this thread to share my code on and get some advice and also have it here as a sort of "record" I guess so I can see the progress I have made.
    I'm planning on making a new post everyday with progress or stuff I am doing, but I'll see how it goes.

    -Syntax
    Last edited by Syntax; 01-27-2015 at 08:17 AM.

  2. #2
    Join Date
    Nov 2011
    Location
    Australia
    Posts
    418
    Mentioned
    2 Post(s)
    Quoted
    86 Post(s)

    Default

    Done quite a bit tonight and learnt a lot. Using The Mayors guide here: https://villavu.com/forum/showthread.php?t=109161
    And a lot of searching through my old topics and on here solving bugs.
    This is what I have came up with so far:
    Simba Code:
    program ChopnFletch;
    //{$DEFINE SMART} //Starts SMART client
    {$i srl-6/srl.simba} //Includes SRL

    procedure findTree;
    var
      x, y: integer; //Variables that findObject output
    begin
    mainScreen.setAngle(MS_ANGLE_LOW); //sets camera angle low
    minimap.setAngle(MM_DIRECTION_SOUTH); //sets minimap to the south
      repeat
       if mainscreen.findObject(x, y, 1711645, 4, ['ree'], MOUSE_RIGHT) then  //finds a normal tree
      begin
        writeln('Found a Normal tree'); //For debug, only runs if script finds a tree
        chooseOption.select(['hop down']); //Chops tree
        wait(randomrange(6000,7000)); //Waits for 6-7 seconds
      end
      until(not isLoggedIn() or tabBackpack.isFull())
    end

    //procedure fletchlogs;  //Fletch into arrowshafts
    //repeat
    //begin
    //if tabBackpack.isFull() then
    //Find log in inventory from research using DTMs?
    //Fletch log, navigate menu
    //end
    //until(no normal logs in inventory)


    begin
      clearDebug();
      setupSRL();
      findTree;
    end.
    Last edited by Syntax; 01-26-2015 at 01:14 PM.

  3. #3
    Join Date
    Nov 2011
    Location
    Australia
    Posts
    418
    Mentioned
    2 Post(s)
    Quoted
    86 Post(s)

    Default

    Pretty happy with the progress the script has made today, it went from hovering over everything to finding trees a lot more quickly and accurately to the point you couldn't make it any better.
    98% of the progress on the script was thanks to The Mayors tutorials.
    Also thanks to Olly and ianhedoesit on IRC.

    Still a lot more to do for the ChopnFletch script, chopping is working though as expected which feels great.
    Simba Code:
    program ChopnFletch;
    {$DEFINE SMART} //Starts SMART client
    {$i srl-6/srl.simba} //Includes SRL

    procedure prepareplayer;
    begin
      //Wait(randomrange(800,1800));
      Writeln('Please Wait...Setting Player up');
      if not isLoggedIn() then
        exit;
      exitTreasure;
      mainScreen.setAngle(MS_ANGLE_LOW); //sets camera low
      minimap.setAngle(MM_DIRECTION_SOUTH); //sets compass south
    end;
    procedure chopDownTree;
    var
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    //if mainscreen.findObject(x, y, 1711645, 4, ['ree'], MOUSE_RIGHT) then  //finds a normal tree

    begin
      prepareplayer;
       FindColorsSpiralTolerance(x, y, TPA, 2640486, mainscreen.getBounds(), 4, colorSetting(2, 0.40, 0.25));  //Function to findcolors


       if length(TPA) < 1 then
        exit;
        //maybe move to different area or rotate display instead of exit?
        ATPA := TPA.toATPA(30, 30);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      //smartImage.debugATPA(ATPA); not functional atm

      for i := 0 to high(ATPA) do
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['ree'], 500) then
        begin
          writeln('Found a Normal tree'); //For debug, only runs if script finds a tree
        wait(randomrange(300,800));
        fastClick(MOUSE_RIGHT);
        chooseOption.select(['hop down']); //Chops tree
        tabBackpack.waitForShift(5000)
      end else
      begin
      writeln('No trees found, please adjust color' +
      'or move to a section with trees');
      exit;
        end;
      end;
    end;
      //create an additional failsafe?


      //repeat
      //begin
        //writeln('Found a Normal tree'); //For debug, only runs if script finds a tree
       // chooseOption.select(['hop down']); //Chops tree
        //wait(randomrange(6000,7000)); //Waits for 6-7 seconds
      //end
     // until(not isLoggedIn() or tabBackpack.isFull())

    //procedure fletchlogs;  //Fletch into arrowshafts
    //repeat
    //begin
    //if tabBackpack.isFull() then
    //Find log in inventory from research using DTMs?
    //Fletch log, navigate menu
    //end
    //until(no normal logs in inventory)


    begin
      clearDebug();
      setupSRL();
      repeat
      chopDownTree;
      until(not isLoggedIn() or tabBackpack.isFull())
    end.

  4. #4
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    Some hints from personal experience:

    Remove code you know you wont use again instead of commenting them out

    Add "TODO:" in front of comments made to your future self for improvements.

    When commenting out code for longer as one debug run use /* code */ instead of tons of //
    Working on: Tithe Farmer

  5. #5
    Join Date
    Sep 2010
    Location
    Finland
    Posts
    298
    Mentioned
    8 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    When commenting out code for longer as one debug run use /* code */ instead of tons of //
    This isn't C, so I think you mean (* code *) or { code }?
    Rusting away

  6. #6
    Join Date
    Nov 2011
    Location
    Australia
    Posts
    418
    Mentioned
    2 Post(s)
    Quoted
    86 Post(s)

    Default

    Quote Originally Posted by masterBB View Post
    Some hints from personal experience:

    Remove code you know you wont use again instead of commenting them out

    Add "TODO:" in front of comments made to your future self for improvements.

    When commenting out code for longer as one debug run use /* code */ instead of tons of //
    Ah thanks masterBB those are some great points will definitely incorporate it now

  7. #7
    Join Date
    Jun 2007
    Location
    The land of the long white cloud.
    Posts
    3,702
    Mentioned
    261 Post(s)
    Quoted
    2006 Post(s)

    Default

    Quote Originally Posted by Syntax View Post
    Ah thanks masterBB those are some great points will definitely incorporate it now
    If you know what good standards look like, you should run it through the parser (it will remove all comments though). You can enable formatter.sex via extensions.


  8. #8
    Join Date
    Mar 2013
    Posts
    1,010
    Mentioned
    35 Post(s)
    Quoted
    620 Post(s)

    Default

    Quote Originally Posted by The Mayor View Post
    If you know what good standards look like, you should run it through the parser (it will remove all comments though). You can enable formatter.sex via extensions.

    https://github.com/JohnPeel/ScriptFormater
    Quite sure this doesn't remove comments and gives you hints
    #slack4admin2016
    <slacky> I will build a wall
    <slacky> I will ban reflection and OGL hooking until we know what the hell is going on

  9. #9
    Join Date
    Nov 2011
    Location
    Australia
    Posts
    418
    Mentioned
    2 Post(s)
    Quoted
    86 Post(s)

    Default

    Quote Originally Posted by Harrier View Post
    https://github.com/JohnPeel/ScriptFormater
    Quite sure this doesn't remove comments and gives you hints
    Looks great Harrier, thanks a lot!

    Quote Originally Posted by The Mayor View Post
    If you know what good standards look like, you should run it through the parser (it will remove all comments though). You can enable formatter.sex via extensions.

    Oh wow, this is definitely a good extension, I just used it on my script one section isn't formatted though because I just wrote it.
    Thanks The Mayor

    ------

    Here is what I have been up to today:
    Simba Code:
    {{TODO: In chopDownTree function, move to different area or rotate the display
    instead of exiting the script.
    Perfect chopDownTree, seems to be an issue chopping more than one tree at
    a time.
    Clean up code.
    Anti-ban.
    Progress report.
    Fix up fletching/chopping not working with seperate procedures

     }

    program ChopnFletch;
    {$DEFINE SMART}
    {$i srl-6/srl.simba}

    procedure prepareplayer;
    begin
      ClearDebug;
      Writeln('Please Wait...Setting Player up');
      if not isLoggedIn() then
        exit;
      exitTreasure;
      mainScreen.setAngle(MS_ANGLE_HIGH);
      minimap.setAngle(MM_DIRECTION_NORTH);
    end;


    procedure chopDownTree;
    var
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      if not tabBackpack.isfull then
      begin
      prepareplayer;
      FindColorsSpiralTolerance(x, y, TPA, 2107688, mainscreen.getBounds(), 2, colorSetting(2, 1.69, 0.80));
      fletchLogs;
      if length(TPA) < 10 then
        exit;
      ATPA := TPA.toATPA(30, 30);
      ATPA.filterBetween(0, 10);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      smartImage.debugATPA(ATPA);
      for i := 0 to high(ATPA) do
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['ree'], 500) then
        begin
          writeln('Found a Normal tree');
          wait(randomrange(300, 800));
          fastClick(MOUSE_RIGHT);
          chooseOption.select(['hop down']);
          tabBackpack.waitForShift(7900);
        end else
        begin
          writeln('No trees found, please adjust color' + ' ' + 'or move to a section with trees');
          exit;
        end;
      end;
    end else
    writeln('Inventory full, fletching the logs');
    fletchLogs;
    end;

    procedure findLog;
    var
      Log, l, o: Integer;
    begin
    Log := DTMFromString('mlwAAAHicY2dgYHjHzMDwEIj/MUPY74H4JxA/AuJ5jAwMK4F4KRBPA+JVQDwDiGcDcYKHNlA3ExAzQmlkjBsw4sFQAAClmgvt');
    if findDTM(Log, l, o, tabBackpack.getBounds()) then
    begin
     mouse(l, o, 3, 3, MOUSE_MOVE);
     fastClick(MOUSE_LEFT);
     FreeDTM(Log);
    end else
    FreeDTM(Log);
    exit;
    end;

    procedure fletchLogs;
    begin
    //if tabBackpack.isFull then
    begin
    findLog;
    if toolScreen.isOpen(3000) then
    toolScreen.select('Knife');
    if productionScreen.isOpen(10000) then
    else end
    writeln('Inventory isnt full');
    begin
    productionScreen.selectBox(1);
    productionScreen.clickStart();
    if progressScreen.isOpen(10000) then
    begin
    repeat
    wait(1000);
    until(not progressScreen.isOpen());
    end;
    end;
    end;

    begin
      clearDebug();
      smartEnableDrawing := true;
      setupSRL();
      fletchLogs;
      {repeat
        chopDownTree;
      until (not isLoggedIn() or tabBackpack.isFull())}

    end.

    Ran into a few bugs today, when writing the fletchLogs function I ran into an issue where I was dependent on the logs always being in whichever slot was hardcoded. Instead I decided to use DTMs which I remember reading about in The Mayors tutorial, so I went back to the tutorial and incorporated it into my script to find the logs.
    This allows a log to be anywhere in the inventory and it will still find it/fletch it.

    Fletching is working as expected, tying it together is going to be a bit harder though. I can't call fletchLogs from chopDownTree and the other way around pretty sure that's because of the order I have written the procedures, won't help changing it.

    Thinking about placing fletching on top of chopDownTree, then inside chopDownTree running a check if the inventory is full, then if it is will find the log dtm, fletch the logs whilst waiting until there is no change in the inventory. Do another check if the inventory is full then start chopping.
    Not sure if that is the most efficent way though.

  10. #10
    Join Date
    Feb 2007
    Location
    Alberta, Canada
    Posts
    4,615
    Mentioned
    50 Post(s)
    Quoted
    429 Post(s)

    Default

    Quote Originally Posted by Syntax View Post
    Fletching is working as expected, tying it together is going to be a bit harder though. I can't call fletchLogs from chopDownTree and the other way around pretty sure that's because of the order I have written the procedures, won't help changing it.

    Thinking about placing fletching on top of chopDownTree, then inside chopDownTree running a check if the inventory is full, then if it is will find the log dtm, fletch the logs whilst waiting until there is no change in the inventory. Do another check if the inventory is full then start chopping.
    Not sure if that is the most efficent way though.
    I'm not sure I see your problem. Do you mean you want to be able to call chopping and fletching together? Your main loop could have something like this:

    Simba Code:
    begin
      repeat
        repeat
          chopDownTree();
        until (not isLoggedIn() or tabBackpack.isFull())
        fletchLogs();
      until (not isLoggedIn())
    end.

    That would do what I think you're trying to describe. No reason for it to be inside your chopDownTree function though, you can just make functions for the key events (in your case chopping and fletching) and then make the logic happen in your main loop.

    If you have any other trouble with the logic part of scripting, I suggest you write things down. I keep scrap paper around all the time and I've got about 10 sheets of paper with random writing for how I could make the logic work with my merchant script. It really helps me keep track of my thoughts and logically lay out Action 1 -> Action 2 -> Action 3 and whatever network comes from that.

    E: If you want to look through my Edgeville chopper and fletcher, it might help you. It isn't complicated compared to Asha's or Cohen's scripts, so it might be easier to break down for you, especially since it does the same function that you're working through so it might be easier to follow the logic.
    Last edited by 3Garrett3; 01-29-2015 at 03:55 PM.

    Scripts: Edgeville Chop & Bank, GE Merchanting Aid
    Tutorials: How to Dominate the Grand Exchange

    Quote Originally Posted by YoHoJo View Post
    I like hentai.

  11. #11
    Join Date
    Oct 2006
    Location
    Netherlands
    Posts
    3,285
    Mentioned
    105 Post(s)
    Quoted
    494 Post(s)

    Default

    restructuring would be better. But a dirty and dangerous solution would be with forwards:

    Simba Code:
    program new;

    procedure b(); forward;

    procedure a();
    begin
      writeln('a');
      b();
    end;

    procedure b();
    begin
      writeln('b');
    end;

    begin
      b();
      a();
    end.

    Using forwards is perfectly fine. But if b cals a which calls b which calls a.... etc etc. That is bad.
    Working on: Tithe Farmer

  12. #12
    Join Date
    Nov 2011
    Location
    Australia
    Posts
    418
    Mentioned
    2 Post(s)
    Quoted
    86 Post(s)

    Default

    Quote Originally Posted by 3Garrett3 View Post
    I'm not sure I see your problem. Do you mean you want to be able to call chopping and fletching together? Your main loop could have something like this:

    Simba Code:
    begin
      repeat
        repeat
          chopDownTree();
        until (not isLoggedIn() or tabBackpack.isFull())
        fletchLogs();
      until (not isLoggedIn())
    end.

    That would do what I think you're trying to describe. No reason for it to be inside your chopDownTree function though, you can just make functions for the key events (in your case chopping and fletching) and then make the logic happen in your main loop.

    If you have any other trouble with the logic part of scripting, I suggest you write things down. I keep scrap paper around all the time and I've got about 10 sheets of paper with random writing for how I could make the logic work with my merchant script. It really helps me keep track of my thoughts and logically lay out Action 1 -> Action 2 -> Action 3 and whatever network comes from that.

    E: If you want to look through my Edgeville chopper and fletcher, it might help you. It isn't complicated compared to Asha's or Cohen's scripts, so it might be easier to break down for you, especially since it does the same function that you're working through so it might be easier to follow the logic.
    Ah putting it in the main loop, I didn't think of this.
    Genius.

  13. #13
    Join Date
    Nov 2011
    Location
    Australia
    Posts
    418
    Mentioned
    2 Post(s)
    Quoted
    86 Post(s)

    Default

    Haven't done any updates lately because I finished the script and is working great.
    I want to move onto a more challenging project. What do you guys think?
    I will release the script here once I am back on my main computer again.

  14. #14
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by Syntax View Post
    Haven't done any updates lately because I finished the script and is working great.
    I want to move onto a more challenging project. What do you guys think?
    I will release the script here once I am back on my main computer again.
    Nice work!
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

  15. #15
    Join Date
    Jun 2014
    Location
    Lithuania
    Posts
    475
    Mentioned
    27 Post(s)
    Quoted
    200 Post(s)

    Default

    Quote Originally Posted by Syntax View Post
    Haven't done any updates lately because I finished the script and is working great.
    I want to move onto a more challenging project. What do you guys think?
    I will release the script here once I am back on my main computer again.
    I wanted but had no time green drag bots pker bot That would be hilarious. And even better than botting green drags, considering you arent botting for charms+cash combination. Bots finding on screen could be done using minimap to mainscreen functions and filtering out background and dragons colors. Not toohard combat system would be needed either. Then again after pk just minimap to mainscreen and filter again background and drags to pick loot, rebank and repeat. basicly could use like 1item or so not to risk much.

    That would be epic next generation head above other drags bots. Farming drag bots instead of drags Also wondering how fast would other developers update their bots to use glories for instant teleportation out, but hen you could add teleblocking support

    You would get alot of experience using sps/tpa/dtm walking methods. Would use various tpa filtering methods. Would learn combat basics at scripting. Would learn and develop surviving/teleporting/running after getting atacked by legit pkers skills.

    Other suggestions would be farming runs bot. Elder/crystal trees bot.

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
  •