Results 1 to 6 of 6

Thread: Help: Simple Copper Mining Script Not Working

  1. #1
    Join Date
    May 2017
    Posts
    5
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default Help: Simple Copper Mining Script Not Working

    Hello!

    This is my first attempt to make an offshoot script from The Mayor's guides.
    I have been following his well written guides somewhat closly and I seem to be overlooking something.
    I run the script starting in the bank and it walks to the mine, does not find the copper and the bot ends up running west.

    I know the script is rough and incomplete but I'm still trying to get the core functions down pat.
    This is the entire code. It compiles without errors.
    What am I missing? Any help would be great!

    Code:
    program SEVarrockMining
    
    {$DEFINE SMART}
    {$I SRL-6/SRL.simba}
    {$I SPS/lib/SPS-RS3.Simba}
    
    var
      LoadsDone: integer;
    
    procedure declarePlayers();
    begin
      setLength(players, 1);
      with players[0] do
      begin
        loginName := 'username';
        password := 'password';
        isActive := true;
        isMember := true;
      end
      currentPlayer := 0;
    end;
    
    procedure runToMine();
    var
      pathToMine:TPointArray;
      teleTimer: TTimeMarker;
    begin
      if not isLoggedIn() then
        exit;
    
      pathToMine := [[258, 287], [256, 253], [311, 254], [362, 254], [387, 282], [399, 325],
    	   [410, 366], [411, 404], [415, 477], [395, 479], [396, 519]];
    
        begin
    
          writeLn('Walking to Mine');
          teleTimer.start();
    
      if not sps.walkPath(pathToMine) then
      begin
        writeLn('walkPath() failed, trying blindWalk()');
        end;
      end;
    end;
    
    procedure mineRocks();
    var
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
      mineTimer: TTimeMarker;
    
    begin
      if not isLoggedIn() then
        exit;
    
      mineTimer.start();
    
      repeat
    
        findColorsSpiralTolerance(x, y, TPA, 3767494, mainScreen.getBounds(), 16, colorSetting(2, 0.19, 0.80));
    
        if (Length(TPA) < 1) 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(['Mine Copper ore rocks'], 500) then
          begin
            fastClick(MOUSE_LEFT);
            smartImage.clear;
            break;
          end;
        end;
    
        tabBackpack.waitForShift(5000);
    
      until tabBackpack.isFull() or (mineTimer.getTime() > 300000);
    
    end;
    procedure runToBank
    
    var
      pathToBank:TPointArray;
    begin
      if not isLoggedIn() then
        exit;
    
      pathToBank := [[398, 516], [398, 474], [417, 439], [412, 399], [410, 354], [393, 313],
    	   [383, 272], [360, 254], [313, 253], [262, 254], [255, 286]];
    
      if not sps.walkPath(pathToBank) then
      begin
        writeLn('walkPath() failed()');
    
      end;
    end;
    
    procedure findBankers();
    var
      x, y, i: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
      mineTimer: TTimeMarker;
    
    begin
      if not isLoggedIn() then
        exit;
    
      findColorsSpiralTolerance(x, y, TPA, 6305854, mainScreen.getBounds(), 7, colorSetting(2, 1.08, 2.00));
    
      if (length(TPA) < 1) then
        exit;
      ATPA := TPA.toATPA(30,30);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      smartImage.debugATPA(ATPA);
    
      for i := 0 to high(ATPA) do
      begin
        mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
        if isMouseOverText(['anker'], 500) then
        begin
          fastClick(MOUSE_LEFT);
          break;
        end;
      end;
    
    end;
    
    procedure depositOre();
    var
      bankTimer: TTimeMarker;
    
    begin
      if not isLoggedIn() then
        exit;
    
      if bankScreen.isOpen() then
      begin
    
        bankTimer.start();
    
        repeat
          if (bankScreen.getPackCount > 0) then
          begin
            bankScreen.quickDeposit(QUICK_DEPOSITBOX_INVENTORY);
            wait(gaussRangeInt(500, 750));
            inc(LoadsDone);
          end;
        until(bankScreen.isPackEmpty()) or (not isLoggedIn()) or (bankTimer.getTime() > 10000)
    
      end;
    
       bankScreen.close();
    
    end;
    
    procedure progressReport();
    var
      oreMined, profit, profitPerHour: integer;
    begin
      oreMined := LoadsDone * 28;
      profit := (oreMined * 61);
      profitPerHour := round((profit * 60) / (getTimeRunning() / 60000));
    
      writeLn('========================================================');
      writeLn('SouthEastVarrockCopperMiner');
      writeLn('Time Run: ' + timeRunning);
      writeLn('Ores Mined: ' + intToStr(oreMined));
      writeLn('Loads Done: ' + intToStr(loadsDone));
      writeLn('Profit Made: ' + intToStr(profit));
      writeLn('Per Hour: ' + intToStr(profitPerHour));
      writeLn('========================================================');
    end;
    
    {Main Loop}
    begin
      clearDebug();
      smartEnableDrawing := true;
      setupSRL();
      declarePlayers();
      findBankers();
    
      SPS.setup('SEVarrockMine', RUNESCAPE_OTHER);
    
      repeat
        if not isLoggedIn() then
        begin
          players[currentPlayer].login();
          exitTreasure();
          mainScreen.setAngle(MS_ANGLE_HIGH);
          minimap.setAngle(MM_DIRECTION_NORTH);
        end;
    
        if tabBackpack.isFull() then
        begin
          runToBank();
          findBankers();
          depositOre();
        end;
    
        progressReport();
    
        runToMine();
        mineRocks();
        runToBank();
        findBankers();
        depositOre();
    
      until(false);
    end

  2. #2
    Join Date
    Jun 2007
    Location
    Michigan
    Posts
    269
    Mentioned
    2 Post(s)
    Quoted
    141 Post(s)

    Default

    I would recheck your colors and preferably get colors from several different worlds since it's been shown that some things can be different based on the world.

    Another things is that the ATPA might be too big or you need to decrease the number of pixels you are looking for. Low pixel counts are filtered out to not get negative matches.

    EDIT: I would also recommend adding in some debug info so you can tell where your script is doing what. For example adding in something like this:

    Simba Code:
    if (Length(TPA) < 1) then
         begin
            writeLn('Failed to find Copper');    
            exit;
         end;

    That way you can for sure say "Oh yea it isn't finding the color correctly" or whatever else may be going on.

    EDIT2: You had the mouse over text look for "Mine Copper Ore Rocks", I am not 100% sure about this but from what I recall the first letter is usually left out due to it causing errors. So removing the "M" might save you further issues. Just another tid bit I've seen.

  3. #3
    Join Date
    May 2017
    Posts
    5
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Thanks for the quick reply!
    I'm pretty new at this so thank you for looking at a thoroughly.
    I will go through the code and add your suggestions.

    When I was picking colors on the Copper ore I only picked the "bronze" looking color. Is that wrong? Or should I be getting colors from all over the copper rock and not just the "vein-y" bronze looking color?
    Also for the "Mine Copper Ore Rocks", I saw some scripts entered them separately as in 'Mine' 'Copper'. Is that necessary or is your method the better way?

  4. #4
    Join Date
    Jun 2007
    Location
    Michigan
    Posts
    269
    Mentioned
    2 Post(s)
    Quoted
    141 Post(s)

    Default

    Quote Originally Posted by Tommygun452 View Post
    Thanks for the quick reply!
    I'm pretty new at this so thank you for looking at a thoroughly.
    I will go through the code and add your suggestions.

    When I was picking colors on the Copper ore I only picked the "bronze" looking color. Is that wrong? Or should I be getting colors from all over the copper rock and not just the "vein-y" bronze looking color?
    Also for the "Mine Copper Ore Rocks", I saw some scripts entered them separately as in 'Mine' 'Copper'. Is that necessary or is your method the better way?
    You definitely want the color that is specific to those rocks, so yes the vein-y part that is copper colored would be the best option for just that color. But you should be grabbing the colors from all around the vein-y area. I can show you a pic here soon if you don't understand.

    And the different ways for it to look for the text "probably" doesn't matter too much, just for starters I'd put in those debug messages so if one day the text does become an issue you will know where to start.

    I also wouldn't say I went through it thoroughly ha. Just noticed those couple things for you to start off with and see how it goes from there

    EDIT: Thinking back to the text, I would say you would really only need "opper" in there since the rocks only say copper rock if it is ready to be mined. But that would be up to you

    EDIT2: here is the colors I picked. You can use them, but I'd suggest hopping several worlds to get a good selection. Lastly, make sure you CTS is set at 2, it is in the bottom right corner. You can see it didn't find some of the rocks fully and that is because when I selected those lighter colors it started identifying the tin rocks too.


  5. #5
    Join Date
    Dec 2014
    Posts
    29
    Mentioned
    0 Post(s)
    Quoted
    13 Post(s)

    Default

    I also tried to make a very simple copper mining script (power mining though) and i use:
    Simba Code:
    mainscreen.findObject(x, y, 4028103, 24, ['opper'], MOUSE_LEFT);
    and it just works. This might not be the best method but for me it works fine. I also use this setup to adjust the screen:
    Simba Code:
    minimap.clickCompass(); mainScreen.setAngle(MS_ANGLE_HIGH);]

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
  •