Results 1 to 9 of 9

Thread: CountBitmapTolerance problem

  1. #1
    Join Date
    Jan 2012
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default CountBitmapTolerance problem

    I am getting an error compiling this :

    Simba Code:
    Procedure CountBarKnives;
    begin
    CBars:= CountBitmapTolerance(IronBar, MIX1, MIY1, MIX2, MIY2, 10);
    end;

    Yes my BitMap is declared before,
    Yes Cbars is an Int in my Var

    [Error] (40:9): Unknown identifier 'CountBitMapTolerance' at line 39
    Compiling failed.
    No idea whats wrong Anyone can help ?


    Edit : seems like CountBitmap doesn't exist but its something I found in this tutorial http://villavu.com/forum/showthread.php?t=47374 and here http://scar-divi.com/oldmanual/ Any idea what it has been replaced for or what I'm doing wrong ?
    Last edited by marc2333; 12-28-2012 at 11:26 AM.

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

    Default

    If you are counting inventory:
    Simba Code:
    CountItems('bmp', IronBar, [10]);

  3. #3
    Join Date
    Jan 2012
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    If you are counting inventory:
    Simba Code:
    CountItems('bmp', IronBar, [10]);
    would it work on a rsps (this means not logged in + no SetupSrl + no SMART) ?
    Last edited by marc2333; 12-28-2012 at 11:37 AM.

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

    Default

    Quote Originally Posted by marc2333 View Post
    would it work on a rsps (this means not logged in + no SetupSrl + no SMART) ?
    The inventory bounds for RSPS may not be the same. Use CountItemsIn() and specify the bounds.

  5. #5
    Join Date
    Jan 2012
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    The inventory bounds for RSPS may not be the same. Use CountItemsIn() and specify the bounds.
    Here is my script, it always returns me 0 bars found and I know my IronBar btm is fine because it finds it earlier and use it on anvil no problem.

    Simba Code:
    program Smithing;
    {$i srl/srl.simba}

    var
    Q: Array [0..15] of Integer;

    x,y,m,n,IronBar,BarWithAnvil,IronKnife,Make10sets,CBars:integer;
    aFound: Extended;


    procedure SetDTMs;
    begin
      Q[0]:= DTMFromString('mlwAAAHicY2dgYJjAzMAwBQlPQ8L7gfKTgLgLiJuAuAqIi4A4C4htDfkZ3r5lAOM/f5hQ2P+B8lw4MCMeDAUAnyQU+Q==');
      Q[1]:= DTMFromString('mrAAAAHic42BgYFBlYmDQAGIVIFYGYnUgVkLCH4BqHgHxKyC+A8RvgfgNED8H4k9A7GZvz6CqqMhgaWzMYGdhwWBjZgamzQ0NGTwcHRhYgWrwYUYCGAYADDsN5A==');
      IronBar:= BitmapFromString(10, 8, 'meJwzNDQ3xEAOjh4QhEcKiKSl5YE' +
            'IqxRcFo7oIwt0Bi5ZiCMBzJwvBQ==');
      BarWithAnvil:= BitmapFromString(88, 10, 'meJzlk+EOgCAIhH3/l7aa2QjOAz' +
            'eLtRw/KAjuPletxynZp4Zl7F0t1q1ukcDBLg3KuAgsRPE5Dsr7KhQ' +
            'vc5CL0jnIbyUHKAOWSH8xdnibJUMmC8G3gCXidzz23EssQMEDqRND' +
            'IBlYhUYgB+Kd50QevCMCQVatowgHviJ417AtwNCXOsvBBfgfDipP5' +
            'OC+kRyUZmUqzqH0PwLm9nEK9aMcNrQX6DQ=');
      IronKnife:= BitmapFromString(20, 28, 'meJy90tsKQUEYxXFvsUUIOeTQds' +
            'gxGxHa2OQsSd7/Kfxraq73mgvT3P5a3/pmEol/n3y+5Aar1YYbrNf' +
            '9YrHiAJvNDtBhYL/V45bLNRV2u6N2ewBUQw3kqluyUA0FGksiW8pm' +
            'CypkRSS6QUKxqVQmpu33JxaSCPS8pGT5DHwkCXLG4/nt/omiGzydz' +
            'knWwNVqrw5soekrJR6PzzA80Zey8aGxu91lsznwRipkWix7lkItHA' +
            '6nNJUgNbE0xVI2vj2dX8bysgwcH16ubywwCBaEStMaSy5Wmvbx+Bo' +
            '7m63Vd7EzL5Zbqak9WBX+AFRRU6I=');
      Make10sets:= BitmapFromString(85, 10, 'meJzFklEOgDAIQ73/pTF+uCyjdI' +
            'Vh5GshUPuKZk9dU5nr+FJmsuv2Vlm2xcnX+BBzdBoT0EHGmHiCskm' +
            'bCqo1/gMp/KXOlfX13/HhY/EDDSvDW2OzGrcd3ajWhFb9LaJ3RMER' +
            'yvhKn3sodGBQqdxEfGU3FTvUWRR0Coi/DaoXn5jksUQKJ/hkQDdPB' +
            'EWFaOUc/wqy5W8oCwfghxTD0PNW04/d3Z5T1w==');
    end;

    Procedure CountBarKnives;
    begin
      CBars:= CountItemsIn('inv', 'bmp', IronBar, [10]);
      writeln('We found ' + toStr(CBars) + ' iron bars');

    end;

    procedure FreeD;
    begin
      FreeDTM(Q[0]);
      FreeDTM(Q[1]);
      FreeBitMap(IronBar);
      FreeBitMap(BarWithAnvil);
      FreeBitMap(IronKnife);
      FreeBitMap(Make10sets);
    end;

    procedure BankToAnvil;
    begin
      if FindDTMRotated(Q[0], x, y, MMX1, MMY1, MMX2, MMY2, -Pi/4, Pi/4, Pi/60, aFound) then
      begin
        MoveMouse(x,y);
        wait(200);
        ClickMouse(x,y,1);
        repeat
          Wait(200);
        Until(FindDTMRotated(Q[1], x, y, MSX1, MSY1, MSX2, MSY2, -Pi/4, Pi/4, Pi/60, aFound))
      end;

    end;

    procedure Smith;
    begin
     if FindDTMRotated(Q[1], x, y, MSX1, MSY1, MSX2, MSY2, -Pi/4, Pi/4, Pi/60, aFound) and FindBitMapToleranceIn(IronBar,m,n,MIX1,MIY1,MIX2,MIY2,10) then
     begin
      MoveMouse(m,n);
      Wait(300);
      ClickMouse(m,n,1);
      Wait(300);
      MoveMouse(x,y);
      Wait(300);
      ClickMouse(x,y,0);
      Wait(500);
      if FindBitMapToleranceIn(BarWithAnvil,x,y,MSX1,MSY1,MSX2,MSY2,10)then
      begin
        MoveMouse(x,y);
        Wait(300);
        ClickMouse(x,y,1);
        Wait(500);
        repeat
          Wait(100);
        Until(FindColorTolerance(x,y,65535,159,31,206,49,3));
      end;
      if FindBitMapToleranceIn(IronKnife,x,y,MSX1,MSY1,MSX2,MSY2,10)then
      begin
        MoveMouse(x,y);
        Wait(300);
        Clickmouse(x,y,0);
        wait(400);
        if FindBitMapToleranceIn(Make10sets,x,y,MSX1,MSY1,MSX2,MSY2,10)then
        begin
          MoveMouse(x,y);
          Wait(300);
          Clickmouse(x,y,1);
          wait(400);
          end;
      end;
     end;

    end;

    procedure AnvilToBank;
    begin
    end;

    procedure Banking;
    begin
    end;


    begin
    SetDTMs
    BankToAnvil
    Smith
    CountBarKnives
    FreeD
    end.

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

    Default

    Ops didnt realize CountItemsIn's param is not area bound.

    Try this function then:
    Simba Code:
    function CountBitMapTolerance(bitmap, xs, ys, xe, ye, tolerance: Integer): Integer;
    var
      TPA: TPointArray;
    begin
      FindBitmapsSpiralTolerance(bitmap, 0, 0, TPA, xs, ys, xe, ye, tolerance);
      Result:= Length(TPA);
    end;

    Use it like how you've been using it in OP.
    Note that 'MIX1, MIY1, MIX2, MIY2' is only for the official RS. Change it accordingly.

  7. #7
    Join Date
    Jan 2012
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by riwu View Post
    ops didnt realize countitemsin's param is not area bound.

    Try this function then:
    Simba Code:
    function countbitmaptolerance(bitmap, xs, ys, xe, ye, tolerance: Integer): Integer;
    var
      tpa: Tpointarray;
    begin
      findbitmapsspiraltolerance(bitmap, 0, 0, tpa, xs, ys, xe, ye, tolerance);
      result:= length(tpa);
    end;

    use it like how you've been using it in op.
    Note that 'mix1, miy1, mix2, miy2' is only for the official rs. Change it accordingly.
    thanks !!!

    compiled successfully in 516 ms.
    We found 6 iron bars
    successfully executed.

  8. #8
    Join Date
    Dec 2012
    Posts
    87
    Mentioned
    0 Post(s)
    Quoted
    19 Post(s)

    Default

    Quote Originally Posted by marc2333 View Post
    would it work on a rsps (this means not logged in + no SetupSrl + no SMART) ?
    Why can you not setup SRL on ps? Out of interest what server is this for?

  9. #9
    Join Date
    Jan 2012
    Posts
    79
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by Pew View Post
    Why can you not setup SRL on ps? Out of interest what server is this for?
    Because of the -22 thing, makes me not able to set coords on top of the screen and many shits.. better not using 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
  •