Results 1 to 20 of 20

Thread: Fix up this function please :)

  1. #1
    Join Date
    Oct 2007
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Fix up this function please :)

    SCAR Code:
    function DropByDTM(TheDTM, RandomnessX, RandomnessY : Integer) : Boolean;
    var
    DTMCoords : TPointArray;
    I : Integer;
    begin
    DTMCoords := ItemCoordinates('inv', 'dtm', [TheDTM], [0]);
    if High(DTMCoords)<1 then begin Result:=False; Exit; end;
     for I := 0 to 28 do
     begin
      Mouse(DTMCoords[I].X, DTMCoords[I].Y, RandomnessX, RandomnessY, False);
      Wait(200+random(100));
      ChooseOption('rop');
      Wait(50+random(150));
     end;
     Result := True;
    end;
    I get an error when i call this function up, ItemCoordinates is based on Amount.scar.

    EDIT: What i want this function to do is to find every available dtm in the inventory and then drop each item without searching for the dtm each time, the point of this is that it will save a lot of time and will look like much more human dropping.
    Woot woot.

  2. #2
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    There's already a function that does this in SRL, although it's broken:
    SCAR Code:
    {*******************************************************************************
    procedure DropItemsByIdentifier;
    By: EvilChicken!
    Description: See description of ClickAllItemsExcept.
    *******************************************************************************}

    procedure DropItemsByIdentifier(ItemType: string; Identifier: Integer; Tol: TIntegerArray);
    begin
      ClickAllItems(ItemType, Identifier, 'rop', 250, [Tol]);
    end;
    The fixed version is:
    SCAR Code:
    {*******************************************************************************
    procedure DropItemsByIdentifier;
    By: EvilChicken!
    Description: See description of ClickAllItemsExcept.
    *******************************************************************************}

    procedure DropItemsByIdentifier(ItemType: string; Identifier: Integer; Tol: TIntegerArray);
    begin
      ClickAllItems(ItemType, Identifier, 'rop', 250, Tol);
    end;
    But that doesn't really answer your question. What exactly is not working?

  3. #3
    Join Date
    Oct 2009
    Location
    Stockton, CA
    Posts
    2,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Where is the ItemCoordinates function located?
    I can not find it in my Inventory.scar.
    I've also tried updating the repository, still nothing.
    Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
    Quote Originally Posted by #srl
    10:45 < Toter> daphil when can get sex anyday I want
    10:45 < Toter> he is always on #SRL
    "A programmer is just a tool which converts caffeine into code"

  4. #4
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    There's
    MouseItem(slot,click) , would that help you?

    Anyways, hers a shortened down/edited/example version of my dropper in my miner:

    SCAR Code:
    For I:=1 to 28 Do
      Begin
        SlotBox:=InvBox(I);
        If FindDTm(OreMid,x,y,SlotBox.X1,SlotBox.Y1, SlotBox.X2, SlotBox.Y2) Then
        Begin
          MouseItem([I],False);
          ChooseOptionEx(['drop']);

    That should help you out!

  5. #5
    Join Date
    Oct 2007
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    YoHoJo: I edited the topic, it now says what i want the function to do.

    Sex: Edited topic, read it.

    Everyone else: Read topic again lol.
    Woot woot.

  6. #6
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Ultra View Post
    EDIT: What i want this function to do is to find every available dtm in the inventory and then drop each item without searching for the dtm each time, the point of this is that it will save a lot of time and will look like much more human dropping.
    DropItemByIdentifier does exactly what you want. I used the same method in my PowerChopper. What doesn't work in your function?

  7. #7
    Join Date
    Oct 2007
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    DropItemByIdentifier does exactly what you want. I used the same method in my PowerChopper. What doesn't work in your function?
    SCAR Code:
    program New;
    {.Include SRL/SRL.Scar}

    var
    Z : Integer;

    function DropByDTM(TheDTM, RandomnessX, RandomnessY : Integer) : Boolean;
    var
    DTMCoords : TPointArray;
    I : Integer;
    begin
    DTMCoords := ItemCoordinates('inv', 'dtm', [TheDTM], [0]);
    if High(DTMCoords)<1 then begin Result:=False; Exit; end;
     for I := 0 to 28 do
     begin
      Mouse(DTMCoords[I].X, DTMCoords[I].Y, RandomnessX, RandomnessY, False);
      Wait(200+random(100));
      ChooseOption('rop');
      Wait(50+random(150));
     end;
     Result := True;
    end;

    begin
    SetUpSRL;
    if DropByDTM(Z, 1, 1) then WriteLn('Awsome...');
    end.
    Get this error: Line 12: [Error] (20592:58): Type mismatch in script
    Woot woot.

  8. #8
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    That means that you entered the parameters of ItemCoordinates wrong. Either that or ItemCoordinates doesn't return a TPA. Is that function in SRL? Because I can't find it. Or did you make it yourself? If the latter, could you please post it?

  9. #9
    Join Date
    Oct 2007
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    {*******************************************************************************
    function ItemCoordinates(Area, ItemType: string; Item, Tol: TIntegerArray): TPointArray;
    By: masquerader modified by ZephyrsFury
    Description: Returns a TPA with the positions of all occurances of Item.
    Parameters:
      Area - 'inv', 'shop', 'bank', 'trade', 'your trade'.
      ItemType - DTM, Color, BitmapMask, Bitmap
      Item - name/value of your dtm/bmp/color/bmpmask.
      Tol - 'dtm' - [] (dtm's can't have tolerance).
            'bmp' - [BMPTol].
            'color' - [COLOUR Tol, Minimum Colour Count].
            'bmpmask' - [BMPTol, ContourTol].
    *******************************************************************************}


    function ItemCoordinates(Area, ItemType: string; Item: Integer; Tol: TIntegerArray): TPointArray;
    var
      startx, starty, rowsize, colsize, colnumber, rownumber, col, row: Integer;
      x1, y1, x2, y2: Integer;
      itemx, itemy, L: Integer;
    begin
      if (CheckArea(area)) then
      begin
        AreaInfo(area, startx, starty, rowsize, colsize, colnumber, rownumber);
        SetLength(Result, RowNumber * ColNumber);
        for row := 0 to rownumber - 1 do
          for col := 0 to colnumber - 1 do
          begin
            x1 := startx + col * colsize;
            y1 := starty + row * rowsize;
            x2 := x1 + colsize;
            y2 := y1 + rowsize;
            if FindItem(Itemx, Itemy, ItemType, Item, x1, y1, x2, y2, Tol) then
            begin
              Result[L].x := ItemX;
              Result[L].y := ItemY;
              Inc(L);
            end;
          end;
      end;
      SetLength(Result, L);
    end;
    It is an SRL function, i did not make it.
    Woot woot.

  10. #10
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    You have the tolerance set to 0, and DTMs don't have a tolerance, so just have the square brackets without the '0' in them.
    SCAR Code:
    DTMCoords := ItemCoordinates('inv', 'dtm', [TheDTM], []);

  11. #11
    Join Date
    Oct 2007
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It was the [TheDTM] !
    Thanks for the help.
    I'm gonna test if my function works, if it doesn't then i will use the proc you gave me.
    Woot woot.

  12. #12
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Ah, found it. Lol, the description parameters of ItemCoordinates are different from the real function. The 'Item' parameter is an Integer, not a TIntegerArray.

    SCAR Code:
    program New;
    {.Include SRL/SRL.Scar}

    var
    Z : Integer;

    function DropByDTM(TheDTM, RandomnessX, RandomnessY : Integer) : Boolean;
    var
    DTMCoords : TPointArray;
    I : Integer;
    begin
    DTMCoords := ItemCoordinates('inv', 'dtm', TheDTM, []);
    if High(DTMCoords)<1 then begin Result:=False; Exit; end;
     for I := 0 to 28 do
     begin
      Mouse(DTMCoords[I].X, DTMCoords[I].Y, RandomnessX, RandomnessY, False);
      Wait(200+random(100));
      ChooseOption('rop');
      Wait(50+random(150));
     end;
     Result := True;
    end;

    begin
    SetUpSRL;
    if DropByDTM(Z, 1, 1) then WriteLn('Awsome...');
    end.

    EDIT: You ninja'd me with your edit.

  13. #13
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    This works too?
    SCAR Code:
    program New;
    {.Include SRL/SRL.Scar}

    var
    Z : Integer;

    function DropByDTM(TheDTM, RandomnessX, RandomnessY : Integer) : Boolean;
    var
    I,x,y : Integer;
    SlotBox:TBox;

    begin
      for I := 0 to 28 do
      begin
      SlotBox:=InvBox(I);
      If FindDTm(TheDTM,x,y,SlotBox.X1,SlotBox.Y1, SlotBox.X2, SlotBox.Y2) Then
      Mouse(X, Y, RandomnessX, RandomnessY, False);
      Wait(200+random(100));
      ChooseOption('rop');
      Wait(50+random(150));
     end;
     Result := True;
    end;

    begin
    SetUpSRL;
    if DropByDTM(Z, 1, 1) then WriteLn('Awsome...');
    end.

    Yours does too .

  14. #14
    Join Date
    Oct 2007
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    But yours keeps on searching for the dtm each time , mine just searches for all of them once!
    Woot woot.

  15. #15
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    why not just use colors? Its simple and faster than searching for a DTM no?

    (Index = the color you wish to use for each fish ex. 0 = salmon col, 1 = trout)
    SCAR Code:
    for i := 1 to 28 do
    begin
      box := InvBox(i);
      if FindColorTolerance(x, y, Col[Index], Box.x1, Box.y1, box.x2, box.y2, 3) then
        dropitem(i);
    end;

    you can make it more complex if you like but it can be as simple as that.

  16. #16
    Join Date
    Feb 2006
    Location
    Tracy/Davis, California
    Posts
    12,631
    Mentioned
    135 Post(s)
    Quoted
    418 Post(s)

    Default

    Quote Originally Posted by Blumblebee View Post
    why not just use colors? Its simple and faster than searching for a DTM no?

    (Index = the color you wish to use for each fish ex. 0 = salmon col, 1 = trout)
    SCAR Code:
    for i := 1 to 28 do
    begin
      box := InvBox(i);
      if FindColorTolerance(x, y, Col[Index], Box.x1, Box.y1, box.x2, box.y2, 3) then
        dropitem(i);
    end;

    you can make it more complex if you like but it can be as simple as that.
    Colors always change/need tol, dtms don't (Unless Jagex changes item shape).

  17. #17
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by YoHoJo View Post
    Colors always change/need tol, dtms don't (Unless Jagex changes item shape).
    inventory colors are constant. (or near constant). 3 tolerance has never failed for me, nor picked up a wrong object.

  18. #18
    Join Date
    Apr 2007
    Location
    Melbourne, Aus
    Posts
    202
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    or you could search for the dtm once, then find the color of the dtm which it finds. Then search for the color the rest of the time.

  19. #19
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Guys, you didn't see this?
    for I := 0 to 28 do
    can give out of range error!
    Should be
    for I := 0 to High(DTMCoords)

  20. #20
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by marpis View Post
    Guys, you didn't see this?
    for I := 0 to 28 do
    can give out of range error!
    Should be
    for I := 0 to High(DTMCoords)
    I thought the same.. YoHoJo knows better..

    And why don't you use DropItemsByIdentifier?

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
  •