Results 1 to 9 of 9

Thread: Trouble counting DTMs in a loop.

  1. #1
    Join Date
    May 2016
    Posts
    15
    Mentioned
    1 Post(s)
    Quoted
    5 Post(s)

    Default Trouble counting DTMs in a loop.

    So my little bit of code is as follows; however, it seems to not care what the DTM count is and still just does whatever function the case tells it to. Anyone able to explain what the issue is? Thank you in advance.
    Code:
    var
    x, y, i: integer;
    TPA: TPointArray;
    ATPA: T2DPointArray;
    mineTimer: TTimeMarker;
    
    begin
      mouseSpeed := gaussRangeInt(18, 25);
      if not isLoggedIn() then
        exit;
    
      mineTimer.start();
    
      oreCopperDTM := DTMFromString('mggAAAHicY2NgYFjKxMAwH4inAvEKIN4MxOuB+AsjAwMTkP4EpJ8D8Vsg/gXEe7ItgbqYkDAjmOZnwA4YcWAIAADphQox');
    
      oreTinDTM := DTMFromString('mggAAAHicY2NgYNjKwsCwHoj3A/ERIN4BxEuAeBkjA8MWIF4NxIuAeCYjRCwrNRWoiwmKGeFsfgbsgBEHhgAAyVIJoA==');
      repeat
        if (tabBackPack.countDTM(oreCopperDTM) >= 14) and ((tabBackPack.countDTM(oreCopperDTM) + tabBackPack.countDTM(oreTinDTM)) > 28 )then
          mineTinRock();
        if (tabBackPack.countDTM(oreTinDTM) >= 14) and ((tabBackPack.countDTM(oreCopperDTM) + tabBackPack.countDTM(oreTinDTM)) > 28 )then
          mineCopperRock();
    
        case random(49) of
        0..24:
          begin
            findColorsSpiralTolerance(x, y, TPA, 12181496, mainScreen.getBounds(), 6, colorSetting(2, 0.58, 1.55));
    
            if (Length(TPA) < 1) then
              exit;
    
            ATPA := TPA.toATPA(25, 25);
    
            ATPA.sortFromMidPoint(mainscreen.playerPoint);
            smartImage.debugATPA(ATPA);
    
            for i := 0 to high(ATPA) do
            begin
              mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
              if isMouseOverText(['Copper', 'oppe'], 1000) then
              begin
                fastClick(MOUSE_LEFT);
                smartImage.clear();
                  break;
              end;
            end;
    
            tabBackpack.waitForShift(5000);
    
            dontBanMe();
          end;
        25..49:
          begin
            findColorsSpiralTolerance(x, y, TPA, 13352137, mainScreen.getBounds(), 13, colorSetting(2, 0.48, 1.12));
    
            if (Length(TPA) < 1) then
              exit;
    
            ATPA := TPA.toATPA(25, 25);
    
            ATPA.sortFromMidPoint(mainscreen.playerPoint);
            smartImage.debugATPA(ATPA);
    
            for i := 0 to high(ATPA) do
            begin
              mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
              if isMouseOverText(['Tin', 'in'], 1000) then
              begin
                fastClick(MOUSE_LEFT);
                smartImage.clear();
                  break;
              end;
            end;
    
            tabBackpack.waitForShift(5000);
    
            dontBanMe();
          end;
        end;
      until tabBackpack.isFull() or (mineTimer.getTime() > 300000);
    end;

  2. #2
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Simba Code:
    if (tabBackPack.countDTM(oreCopperDTM) >= 14) and ((tabBackPack.countDTM(oreCopperDTM) + tabBackPack.countDTM(oreTinDTM)) > 28 )then
      mineTinRock();
       
    if (tabBackPack.countDTM(oreTinDTM) >= 14) and ((tabBackPack.countDTM(oreCopperDTM) + tabBackPack.countDTM(oreTinDTM)) > 28 )then
      mineCopperRock();

    Both of these statements will always return false (because you cannot have more than 28 items in your pack).

    You probably want a less than comparison ( < ) for the second condition, or even better, (not tabBackpack.isFull()) which will account for other random items, and avoid counting heaps of DTMs each loop. Although, you really only need to check 1 DTM:

    Simba Code:
    if tabBackpack.isFull() then exit;

    if (tabBackPack.countDTM(oreTinDTM) >= 14) then
      mineCopperRock()
    else
      mineTinRock()

  3. #3
    Join Date
    May 2016
    Posts
    15
    Mentioned
    1 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by Laquisha View Post
    Simba Code:
    if (tabBackPack.countDTM(oreCopperDTM) >= 14) and ((tabBackPack.countDTM(oreCopperDTM) + tabBackPack.countDTM(oreTinDTM)) > 28 )then
      mineTinRock();
       
    if (tabBackPack.countDTM(oreTinDTM) >= 14) and ((tabBackPack.countDTM(oreCopperDTM) + tabBackPack.countDTM(oreTinDTM)) > 28 )then
      mineCopperRock();

    Both of these statements will always return false (because you cannot have more than 28 items in your pack).

    You probably want a less than comparison ( < ) for the second condition, or even better, (not tabBackpack.isFull()) which will account for other random items, and avoid counting heaps of DTMs each loop. Although, you really only need to check 1 DTM:

    Simba Code:
    if tabBackpack.isFull() then exit;

    if (tabBackPack.countDTM(oreTinDTM) >= 14) then
      mineCopperRock()
    else
      mineTinRock()
    Good call on the greater than less than issue.. i dont know why i did that as greater than. However, for the only needing to check 1 dtm, if i mine 17 tin using the random case, ill just have a backpack full of tin. My hope was to get 14 copper and 14 tin per load.

  4. #4
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Quote Originally Posted by Kemosisss View Post
    Good call on the greater than less than issue.. i dont know why i did that as greater than. However, for the only needing to check 1 dtm, if i mine 17 tin using the random case, ill just have a backpack full of tin. My hope was to get 14 copper and 14 tin per load.
    I assume that your mineTinRock() and mineCopperRock() procedures are identical to the code you have in that case statement? If they are, there really is no need to duplicate the code. What you could do is is randomly choose to execute the mineTinRock() or minCopperRock() procedures, but make them exit if there is already >=14 ore of that type:

    Simba Code:
    procedure mineCopperRocks(); // You would do the same for Tin
    var
      x, y, i: Integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
       
      if (tabBackPack.countDTM(oreCopperDTM) >= 14) then  // It will just exit if > 13
        exit;

      if findColorsSpiralTolerance(x, y, TPA, 12181496, mainScreen.getBounds(), 6, colorSetting(2, 0.58, 1.55)) then
      begin

        ATPA := TPA.toATPA(25, 25);
        ATPA.sortFromMidPoint(mainscreen.playerPoint);
        smartImage.debugATPA(ATPA);

        for i := 0 to high(ATPA) do
        begin
          mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
          if isMouseOverText(['Copper', 'oppe'], 1000) then
          begin
            fastClick(MOUSE_LEFT);
            smartImage.clear();
            break;
          end;
        end;

        tabBackpack.waitForShift(5000);
        dontBanMe();
      end;
    end;

    procedure mine();
    begin
      mouseSpeed := gaussRangeInt(18, 25);
     
      if not isLoggedIn() then
        exit;

      mineTimer.start();

      repeat
        if random(2) = 0 then
          mineCopperRocks()    // Randomly call one of the two procedures
        else                   // This should repeat until you have 14 of each
          mineTinRocks();
      until tabBackpack.isFull() or (mineTimer.getTime() > 300000);
    end;

    If you wanted to get fancy, you could create one mining procedure and pass in the rock type as a parameter, and it would choose the colours and text based on that parameter.

  5. #5
    Join Date
    Feb 2015
    Location
    Taguig, Philippines
    Posts
    342
    Mentioned
    15 Post(s)
    Quoted
    137 Post(s)

    Default

    You can try:

    Simba Code:
    repeat
      if randomRange(1, 101) <= 50 then  //This randomizes the ore that you mine
      begin
        if tabBackPack.countDTM(oreCopperDTM) < 14 then  //Counts if you have 14 copper ores already
          mineCopperRock();
      end else
      begin
       if tabBackPack.countDTM(oreTinDTM) < 14 then  //Counts if you have 14 tin ores already
          mineTinRock();
      end;
    until (tabBackPack.isFull()) or (mineTimer.getTime() > 300000);


    This is what my Varrock Miner has but my DTMs are in an array and my rock finder's a separate function.
    Varrock Miner mining part

    Simba Code:
    var
      i: integer;
    begin
      //This is the part where I said it was similar
      repeat
        i := randomRange(0, 2);
        if (tabBackPack.countDTM(ore[i].DTM) < 14) or (not tabBackPack.isFull()) then
          ore[i].Find(9, 9, MOUSE_LEFT, [''], 100, 200);
      until tabBackPack.isFull();
      //Other part of the code
    end;


    And if you want, you can just use the object finder I use on my script.
    renzanityFindObj

    Simba Code:
    //It can be used like this
    renzanityFindObjrenzanityFindObj(HUE, SAT, WIDTH, HEIGHT, COLOR, TOLERANCE, MOUSE_LEFT, ['MOUSE OVER TEXT'], ['CHOOSE OPTION'], MINIMUM WAIT, MAXIMUM WAIT);

    //This finds and clicks the bank
    renzanityFindObj(0.84, 0.75, 5, 5, 4269630, 12, MOUSE_LEFT, ['ank'], [''], 100, 200);

    //So if you will use the findObj function below, it will look like this
    if randomRange(1, 101) <= 50 then
    begin
      if tabBackPack.countDTM(oreCopperDTM) < 14 then
        renzanityFindObj(COPPER_HUE, COPPER_SAT, 10, 10, COPPER_COLOR, COPPER_TOLERANCE, MOUSE_LEFT, ['ine Copper'], [''], 100, 200);
    end else
    begin
      if tabBackPack.countDTM(oreTinDTM) < 14 then
        renzanityFindObj(TIN_HUE, TIN_SAT, 10, 10, TIN_COLOR, TIN_TOLERANCE, MOUSE_LEFT, ['ine Tin'], [''], 100, 200);
    end;
    Simba Code:
    {*Simple Object Finder Function*
    *From The Mayor's generic object finder*}

    function renzanityFindObj(hue, sat: extended; W, H, colour, tolerance, clickType: integer; mouseOverText, chooseOptions: array of string; minWait, maxWait: integer): boolean;
    var
      i, x, y: integer;
      TPA: TPointArray;
      ATPA: T2DPointArray;
    begin
      if (not isLoggedIn()) or (not findColorsSpiralTolerance(x, y, TPA, colour, mainScreen.getBounds(), tolerance, colorSetting(2, hue, sat))) then
        exit(false);

      mouseSpeed := gaussRangeInt(40, 50);  //For a human-like mouse speed movements
      ATPA := TPA.cluster(W, H);
      ATPA.filterBetween(0, 3);
      ATPA.sortFromMidPoint(mainscreen.playerPoint);
      smartImage.debugATPA(ATPA);
      for i := 0 to high(ATPA) do
      begin
        case random(5) of
          0..3: missMouse(ATPA[i].getBounds().getRandomPoint(), true)
        else
          mouse(ATPA[i].getBounds().getRandomPoint(), MOUSE_MOVE, MOUSE_HUMAN);
        end;
        if isMouseOverText(mouseOverText, 170) then
        begin
          fastClick(clickType);

          if clickType = MOUSE_LEFT then
          begin
            if randomRange(1, 100) <= 50 then
            begin
              fastClick(clickType);
              smallRandomMouse(5 + random(50));
            end else smallRandomMouse(5 + random(50));
          end;

          if clickType = MOUSE_RIGHT then
            chooseOption.select(chooseOptions);
          smartImage.clearArea(mainScreen.getBounds());
          wait(randomRange(minWait, maxWait));
          exit(true);
        end;
      end;
    end;

    I'm no good at teaching since I only learned scripting through reading other people's work. Haha.

    Goodluck on your script and have a good one.

    EDIT: Forgot to delete the not's on the first simba tag
    EDIT2: So yeah. I changed the 1st simba tag again...Haha.
    Last edited by Renzanity; 05-14-2016 at 01:22 PM.

  6. #6
    Join Date
    Dec 2013
    Location
    Pitcairn Island
    Posts
    288
    Mentioned
    20 Post(s)
    Quoted
    166 Post(s)

    Default

    Quote Originally Posted by Renzanity View Post
    You can try:
    Simba Code:
    repeat
      if randomRange(1, 101) <= 50 then  //This randomizes the ore that you mine
      begin
        if tabBackPack.countDTM(oreCopperDTM) = 14 then  //Counts if you have 14 copper ores already
          exit  //If you do have 14 copper ores, this stops you from mining any more copper rocks
        else mineCopperRock();
      end else
      begin
       if tabBackPack.countDTM(oreTinDTM) = 14 then  //Counts if you have 14 tin ores already
          exit  //If you do have 14 tin ores, this stops you from mining any more tin rocks
       else mineTinRock();
      end;
    until (tabBackPack.isFull()) or (mineTimer.getTime() > 300000);
    This is more or less what I had in mind, except here you shouldn't use exit because you will end up outside the procedure (and thus reset the timer etc.). It would work like this:

    Simba Code:
    repeat
      if randomRange(1, 101) <= 50 then  
      begin
        if tabBackPack.countDTM(oreCopperDTM) < 14 then  
          mineCopperRock();
      end else
      begin
       if tabBackPack.countDTM(oreTinDTM) < 14 then  
         mineTinRock();
      end;
    until (tabBackPack.isFull()) or (mineTimer.getTime() > 300000);

  7. #7
    Join Date
    Feb 2015
    Location
    Taguig, Philippines
    Posts
    342
    Mentioned
    15 Post(s)
    Quoted
    137 Post(s)

    Default

    Quote Originally Posted by Laquisha View Post
    This is more or less what I had in mind, except here you shouldn't use exit because you will end up outside the procedure (and thus reset the timer etc.). It would work like this:

    Simba Code:
    repeat
      if randomRange(1, 101) <= 50 then  
      begin
        if tabBackPack.countDTM(oreCopperDTM) < 14 then  
          mineCopperRock();
      end else
      begin
       if tabBackPack.countDTM(oreTinDTM) < 14 then  
         mineTinRock();
      end;
    until (tabBackPack.isFull()) or (mineTimer.getTime() > 300000);
    Ohh, that's right. I should have read what you wrote above.

  8. #8
    Join Date
    May 2016
    Posts
    15
    Mentioned
    1 Post(s)
    Quoted
    5 Post(s)

    Default

    Well, I read all these too late and got it to work. However, that makes me scared to change anything at this point.

    The code I'm sitting on now (though it probably didnt change much from the original) is:
    Code:
    procedure mineTinCopperRock();
    var
    x, y, i: integer;
    TPA: TPointArray;
    ATPA: T2DPointArray;
    mineTimer: TTimeMarker;
    
    begin
      mouseSpeed := gaussRangeInt(18, 25);
      if not isLoggedIn() then
        exit;
    
      mineTimer.start();
    
      oreCopperDTM := DTMFromString('mggAAAHicY2NgYFjKxMAwH4inAvEKIN4MxOuB+AsjAwMTkP4EpJ8D8Vsg/gXEe7ItgbqYkDAjmOZnwA4YcWAIAADphQox');
    
      oreTinDTM := DTMFromString('mggAAAHicY2NgYNjKwsCwHoj3A/ERIN4BxEuAeBkjA8MWIF4NxIuAeCYjRCwrNRWoiwmKGeFsfgbsgBEHhgAAyVIJoA==');
      repeat
        if (tabBackPack.countDTM(oreCopperDTM) >= 14) and ((tabBackPack.countDTM(oreCopperDTM) + tabBackPack.countDTM(oreTinDTM)) < 28 )then
          mineTinRock();
        if (tabBackPack.countDTM(oreTinDTM) >= 14) and ((tabBackPack.countDTM(oreCopperDTM) + tabBackPack.countDTM(oreTinDTM)) < 28 )then
          mineCopperRock();
    
        if not tabBackpack.isFull() then
        case random(49) of
        0..24:
          begin
            findColorsSpiralTolerance(x, y, TPA, 12181496, mainScreen.getBounds(), 6, colorSetting(2, 0.58, 1.55));
    
            if (Length(TPA) < 1) then
              exit;
    
            ATPA := TPA.toATPA(25, 25);
    
            ATPA.sortFromMidPoint(mainscreen.playerPoint);
            smartImage.debugATPA(ATPA);
    
            for i := 0 to high(ATPA) do
            begin
              mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
              if isMouseOverText(['Copper', 'oppe'], 1000) then
              begin
                fastClick(MOUSE_LEFT);
                smartImage.clear();
                  break;
              end;
            end;
    
            tabBackpack.waitForShift(8000);
    
            dontBanMe();
          end;
        25..49:
          begin
            findColorsSpiralTolerance(x, y, TPA, 13352137, mainScreen.getBounds(), 13, colorSetting(2, 0.48, 1.12));
    
            if (Length(TPA) < 1) then
              exit;
    
            ATPA := TPA.toATPA(25, 25);
    
            ATPA.sortFromMidPoint(mainscreen.playerPoint);
            smartImage.debugATPA(ATPA);
    
            for i := 0 to high(ATPA) do
            begin
              mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
              if isMouseOverText(['Tin', 'in'], 1000) then
              begin
                fastClick(MOUSE_LEFT);
                smartImage.clear();
                  break;
              end;
            end;
    
            tabBackpack.waitForShift(8000);
    
            dontBanMe();
          end;
        end;
      until tabBackpack.isFull() or (mineTimer.getTime() > 300000);
    end;
    I have sections to mine just copper or just tin, but they use the "until backpackfull" part to end loop and I dont really want to change all that. Its working perfectly though, it gathers 14 copper and 14 tin at random then banks.

  9. #9
    Join Date
    Mar 2016
    Posts
    192
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    @Kemosisss please use [SIMBA][/SIMBA] tags, it will be easier to read

    If it works- just leave it

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
  •