Results 1 to 24 of 24

Thread: Function for counting runes in inventory?

  1. #1
    Join Date
    Dec 2009
    Posts
    146
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Function for counting runes in inventory?

    Is there an easy way to determine how many runes are stack in each slot in my inventory?

    Obviously if I only have one rune in a slot, I don't want to "deposit all" as that looks silly. A real human would just click on the single rune to deposit it.

    Thanks in advance for your help!

    JIM

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

    Default

    SCAR Code:
    {*******************************************************************************
    function CountItems(ItemType: string; Identifier: Integer; tol: TIntegerArray): Integer;
    By: WT-Fakawi / Sumilion
    Description: Counts Items in the inventory.
      ItemType - 'dtm', 'bitmap', 'bitmap mask', 'color'
      Item - name/value of your dtm/bmp/color/bmpmask.
      Tol - 'dtm' - [] (dtm's can't have tolerance).
            'bmp' - [BMPTol].
            'color' - [COLOUR Tol, Colour Count].
            'bmpmask' - [BMPTol, ContourTol].
    *******************************************************************************}

    Located in Inventory.scar
    C'mon man just read around !

  3. #3
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    SRL has bitmaps for all the f2p runes that I would suggest using, or you can make your own. then just search for the bitmap in the Inventory, maybe loop through the slots if you would like, or just search the whole inventory. Then Mouse(x, y, 4, 4, False); (or whatever your params would be) and use ChooseOption to deposit them all.

    Quite simple. The SRL include provides alot of thing's for you if you take the time to look through it

    Edit: YoHoJo, I think you slightly misunderstood what he was asking, or perhaps I did?

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

    Default

    NCDS he wanted to use a function that COUNTED the number of X rune in the inventory, not just deposit.

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

    Default

    In Amount.scar:
    SCAR Code:
    {*******************************************************************************
    function RuneAmount(area, runetype: String): Integer;
    By: masquerader and modified by Ron and ZephyrsFury
    Description: Returns the amount of a certain rune in the specified area.
    *******************************************************************************}


    function RuneAmount(Area, RuneType: string): Integer;
    var
      RuneBmp, II: Integer;
      RuneNames: TStringArray;
    begin
      RuneNames := ['air', 'mind', 'water', 'fire', 'earth', 'law', 'nature', 'chaos', 'death', 'body', 'cosmic', 'soul', 'blood'];
      if (InStrArrEx(Lowercase(RuneType), RuneNames, II)) then
      begin
        RuneBmp := srl_GetBitmap(18 + II);
        Result := ItemAmount(Area, 'bmp', RuneBmp, [20]);
        FreeBitmap(RuneBmp);
      end else
        srl_Warn('RuneAmount', 'Invalid RuneType: ''' + RuneType + '''', warn_AllVersions);
    end;

    Use it like this
    SCAR Code:
    Var
      X, Y, ItemSlot: Integer;
      If Not FindBitmapToleranceIn(WaterRuneBMP, X, Y, MIX1, MIY1, MIX2, MIY2, 20) Then Exit;
      ItemSlot := CoordsToItem(X, Y);
      If RuneAmount('inv', 'water') = 1 Then
        MouseItem(ItemSlot, True)
      Else
      Begin
        MouseItem(ItemSlot, False);
        WaitOption('all', 1000);
      End;

  6. #6
    Join Date
    Dec 2009
    Posts
    146
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Maybe I wasn't clear. Let me try again.

    I know I have a rune in slot three, doesn't matter to me what type, it can be nature runes or airs, that is irrelevant. What I need to know is the quantity of items in that slot, whether there are a stack of 10 runes in that slot or just one.

    The point of this is when I deposit these runes in the bank it will look more humanlike if I left click on all slots that just have one rune in them, and right click and choose "Deposit 5 runes" or "deposit 10 runes" or "deposit all runes" depending on the quantity in that slot for all runestacks with a quantity more than one.

    Sorry if I was unclear.

  7. #7
    Join Date
    Nov 2007
    Location
    46696E6C616E64
    Posts
    3,069
    Mentioned
    44 Post(s)
    Quoted
    302 Post(s)

    Default

    Doesnt the RuneAmount(); return that value?
    There used to be something meaningful here.

  8. #8
    Join Date
    Nov 2007
    Location
    Nowhereville
    Posts
    1,155
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    Point := ItemCoords(3);
    GetAmount(Point.x, Point.y);

    I think this is what you are looking for.
    Formerly known as Cut em2 it

  9. #9
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by jimthesoundman View Post
    Maybe I wasn't clear. Let me try again.

    I know I have a rune in slot three, doesn't matter to me what type, it can be nature runes or airs, that is irrelevant. What I need to know is the quantity of items in that slot, whether there are a stack of 10 runes in that slot or just one.

    The point of this is when I deposit these runes in the bank it will look more humanlike if I left click on all slots that just have one rune in them, and right click and choose "Deposit 5 runes" or "deposit 10 runes" or "deposit all runes" depending on the quantity in that slot for all runestacks with a quantity more than one.

    Sorry if I was unclear.
    SCAR Code:
    function _Deposit: Boolean;
    var
       i, _amount: Integer;
       _option: string;
      _Point: TPoint;
    begin
      if (not BankScreen) then
        Exit;
      for i := 1 to 28 do
      begin
        if (not ExistsItem(i)) then
          Continue;
        _Point := ItemCoords(i);
        _amount := GetAmount(_Point.x, _Point.y);
        case (_amount) of
          1: MouseItem(i, True);
          2..10:
          begin
            MouseItem(i, False);
            if (InRange(_amount, 2, 5)) then _option := '5' else option := '10';
            if (WaitOption(_option, 500)) then
              Wait(RandomRange(50, 200));
          end;
          else
            Deposit(i, i, True);
        end;
      end;
      Result := True;
    end;
    Posted Final version of my function. So you don't have to read all of that.

  10. #10
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Took out the unnecessary stuff.

    SCAR Code:
    function _Deposit: Boolean;
    var
       i, _amount: Integer;
      _Point: TPoint;
    begin
      if (not BankScreen) then
        Exit;
      for i := 1 to 28 do
      begin
        if (not ExistsItem(i)) then
          Continue;
        _Point := ItemCoords(i);
        _amount := GetAmount(_Point.x, _Point.y);
        case (_amount) of
          0: Continue;
          1: MouseItem(i, True);
          5:
          begin
            MouseItem(i, False);
            if (WaitOption('5', 250)) then
              Wait(RandomRange(50, 200));
          end;
          10:
          begin
            MouseItem(i, False);
            if (WaitOption('10', 250)) then
              Wait(RandomRange(50, 200));
          end
         
          else
            Deposit(i, i, True);
        end;
      end;
      Result := True;
    end;

    I would do something different with case 5 and 10 too. Make the string in WaitOption a variable that changes according to the case and just have that block of code once, instead of repeating nearly the same thing twice.
    Last edited by NCDS; 01-15-2010 at 04:37 PM.

  11. #11
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    Took out the unnecessary stuff.

    SCAR Code:
    function _Deposit: Boolean;
    var
       i, _amount: Integer;
      _Point: TPoint;
    begin
      if (not BankScreen) then
        Exit;
      for i := 1 to 28 do
      begin
        if (not ExistsItem(i)) then
          Continue;
        _Point := ItemCoords(i);
        _amount := GetAmount(_Point.x, _Point.y);
        case (_amount) of
          0: Continue;
          1: MouseItem(i, True);
          5:
          begin
            MouseItem(i, False);
            if (WaitOption('5', 250)) then
              Wait(RandomRange(50, 200));
          end;
          10:
          begin
            MouseItem(i, False);
            if (WaitOption('10', 250)) then
              Wait(RandomRange(50, 200));
          end
         
          else
            Deposit(i, i, True);
        end;
      end;
      Result := True;
    end;

    I would do something different with case 5 and 10 too. Make the string in WaitOption a variable that changes according to the case and just have that block of code once, instead of repeating nearly the same thing twice.
    Haven't scripted in forever. Gimme a break.
    Edit: How could I make the WaitOption string a variable? Its not like there is a option for every number on the drop down list.

  12. #12
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    I know, I remember when you used to be active

    I didn't mean to sound so stern in that post.

    Take it as a bit of constructive criticism to get back into thing's?



    Plus, any friend of Blumblebee is fine by me!

  13. #13
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    I know, I remember when you used to be active

    I didn't mean to sound so stern in that post.

    Take it as a bit of constructive criticism to get back into thing's?



    Plus, any friend of Blumblebee is fine by me!
    xD, Uhh..
    I edited my post, but how would it be possible to change the string in WaitOption to the case? There's not a number for every option in the drop down.

  14. #14
    Join Date
    Feb 2009
    Location
    Hungary (GMT + 1)
    Posts
    1,774
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    2..10:
      begin
        MouseItem(i, False);
        if (WaitOption(IntToStr(_amount), 500)) then
        begin
           Wait(RandomRange(50, 200));
         end;
      end;
    Oh, wait. That's wrong. But you get something from it. Maybe .

    edit: Yes, that's totally wrong. Just came to my mind. I can't think of any better way than Timer's.
    Last edited by Sabzi; 01-15-2010 at 05:01 PM.

  15. #15
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function _Deposit: Boolean;
    var
       i, _amount: Integer;
       _option: string;
      _Point: TPoint;
    begin
      if (not BankScreen) then
        Exit;
      for i := 1 to 28 do
      begin
        if (not ExistsItem(i)) then
          Continue;
        _Point := ItemCoords(i);
        _amount := GetAmount(_Point.x, _Point.y);
        case (_amount) of
          0, 1: MouseItem(i, True);
          2..10:
          begin
            MouseItem(i, False);
            if (InRange(_amount, 2, 5)) then _option := '5' else option := '10';
            if (WaitOption(_option, 500)) then
              Wait(RandomRange(50, 200));
          end;

          else
            Deposit(i, i, True);
        end;
      end;
      Result := True;
    end;
    Best I got.

  16. #16
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    if you want to use more than 2 possibilities then you could use a case to decide the variable, like:
    SCAR Code:
    case Amt of
      5 : Num := '5';
      10: Num := '10';
      else
        Num := IntToStr(Amt); // I believe that would work incase you wanted to do "Deposit-X"
    end;
    Then you could do:
    SCAR Code:
    if Num > 1 then
    begin
       MouseItem(i, False);
       if (WaitOption(Num, 250)) then
         Wait(RandomRange(50, 200));
    end;
    Something along those lines.


    Edit: Looking at your latest post, I think you could change "0,1" to just 1, as I don't see why you would want to click the InvSlot if nothing exists there.
    Last edited by NCDS; 01-15-2010 at 05:00 PM.

  17. #17
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    if you want to use more than 2 possibilities then you could use a case to decide the variable, like:
    SCAR Code:
    case Amt of
      5 : Num := '5';
      10: Num := '10';
      else
        Num := IntToStr(Amt); // I believe that would work incase you wanted to do "Deposit-X"
    end;
    Then you could do:
    SCAR Code:
    if Num > 1 then
    begin
       MouseItem(i, False);
       if (WaitOption(Num, 250)) then
         Wait(RandomRange(50, 200));
    end;
    Something along those lines.
    He only wants Left click, 5, 10, or all. So look what I got, before you posted.

  18. #18
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Looking at your latest post, I think you could change "0,1" to just 1, as I don't see why you would want to click the InvSlot if nothing exists there.

    Other than that, it seems like ti would work as long as he didn't have over 10 runes of the same kind. I currently don't see an option to deposit all in your latest. Maybe add another InRange check?
    Last edited by NCDS; 01-15-2010 at 05:06 PM.

  19. #19
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    Looking at your latest post, I think you could change "0,1" to just 1, as I don't see why you would want to click the InvSlot if nothing exists there.

    Other than that, it seems like ti would work as long as he didn't have over 10 runes of the same kind.
    SCAR Code:
    {*******************************************************************************
    function GetAmount(ItemX, ItemY: Integer): Integer;
    By: Zeph, N1ke & Narcle
    Description: Returns the amount of an item at coordinates (ItemX, ItemY).
      Returns approximate values for 'K' and 'M'.
    *******************************************************************************}

    Function GetAmount(ItemX, ItemY: Integer): Integer;
    var
      Col: TIntegerArray;
      X, Y, I: Integer;
      B: TBox;
      TPA: TPointArray;
      S: String;
    begin
      Result := 0;
      If Not FindColor(X, Y, srl_outline_black, ItemX-30, ItemY-30, ItemX+30, ItemY+30)then
        Exit;
      Inc(Result);
      Col := [65535, 16777215, 8453888];
      For I:=0 to 2 do
       If FindColor(X, Y, Col[I], ItemX-22, ItemY-22, ItemX+22, ItemY+22)then
       begin
         FindColors(TPA, Col[i], ItemX-22, ItemY-22, ItemX+22, ItemY+22);
         B := GetTPABounds(TPA);
         S := Trim(GetTextAtEx(B.X1-1, B.Y1-1, 0, StatChars, False, False, 0, 1, Col[I], 5, True, tr_AllChars));
         Result := StrToIntDef(GetNumbers(S), 1);
         Case I of
           1: Result := Result * 1000;
           2: Result := Result * 1000000;
         end;
         Exit;
       end;
    end;
    I don't see a Result := 1; Only 0.. and some items when you have 'em in you Inventory show a 1, so i just put it there.
    And you can't have multiple stacks of the same runes. They auto stack. Unless we're dealing with millions of runes--if they even divide stacks then--but shouldn't the ExistItem fix that--Or am I completely not understanding what you said?

    EDIT:
    Quote Originally Posted by NCDS View Post
    I currently don't see an option to deposit all in your latest. Maybe add another InRange check?
    SCAR Code:
    else
            Deposit(i, i, True);

  20. #20
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    All I was saying is that if GetAmount returns 0, then nothing is there, so why click there?

  21. #21
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    All I was saying is that if GetAmount returns 0, then nothing is there, so why click there?
    I have a
    SCAR Code:
    if (not ExistsItem(i)) then
          Continue;
    look at the function. It auto returns a 0 (saying that is just one item, since one item doesnt show a number..?)--or does runes show 1? Even if there is only 1?

  22. #22
    Join Date
    Oct 2007
    Location
    #srl
    Posts
    6,102
    Mentioned
    39 Post(s)
    Quoted
    62 Post(s)

    Default

    Just checked, runes do show a value even if it is single.

    and form what I can see, GetAmount returns 0 if it doesn't find anything. Read the 2 lines following Result := 0. Might help exlain a little.
    Last edited by NCDS; 01-15-2010 at 05:15 PM.

  23. #23
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NCDS View Post
    Just checked, runes do show a value even if it is single.

    and form what I can see, GetAmount returns 0 if it doesn't find anything. Read the 2 lines following Result := 0. Might help exlain a little.
    Got ya.
    SCAR Code:
    Result := StrToIntDef(GetNumbers(S), 1);
    EDIT: Hurr..
    SCAR Code:
    function _Deposit: Boolean;
    var
       i, _amount: Integer;
       _option: string;
      _Point: TPoint;
    begin
      if (not BankScreen) then
        Exit;
      for i := 1 to 28 do
      begin
        if (not ExistsItem(i)) then
          Continue;
        _Point := ItemCoords(i);
        _amount := GetAmount(_Point.x, _Point.y);
        case (_amount) of
          1: MouseItem(i, True);
          2..10:
          begin
            MouseItem(i, False);
            if (InRange(_amount, 2, 5)) then _option := '5' else option := '10';
            if (WaitOption(_option, 500)) then
              Wait(RandomRange(50, 200));
          end;
          else
            Deposit(i, i, True);
        end;
      end;
      Result := True;
    end;

  24. #24
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Honestly, I've been runecrafting for a very long time and when I play legit I always use deposit all when running trips ingame and while scripting. There's also an algorithm for knowing how many runes you should at least have when you craft based on your essence and level.

    Minimum rune per essence

    SCAR Code:
    case Rune of
        'Air': RunesPerEss := (Players[CurrentPlayer].Level[7] div 11) + 1;
        'Mind': RunesPerEss := (Players[CurrentPlayer].Level[7] div 14) + 1;
        'Water': RunesPerEss := (Players[CurrentPlayer].Level[7] div 19) + 1;
        'Earth': RunesPerEss := (Players[CurrentPlayer].Level[7] div 26) + 1;
        'Fire': RunesPerEss := (Players[CurrentPlayer].Level[7] div 35) + 1;
        'Body': RunesPerEss := (Players[CurrentPlayer].Level[7] div 46) + 1;
        'Cosmic': RunesPerEss := (Players[CurrentPlayer].Level[7] div 59) + 1;
        'Choas': RunesPerEss := (Players[CurrentPlayer].Level[7] div 74) + 1;
        'Natrue': RunesPerEss := (Players[CurrentPlayer].Level[7] div 91) + 1;
      end;

    Recently shortened to

    SCAR Code:
    case Between('[', ']', Players[CurrentPlayer].Strings[1]) of
        'Air': RuneInfo := ['Air', 11, MMCX, MMCY];
        'Earth': RuneInfo := ['Earth', 26, 629, 47];
        'Fire': RuneInfo := ['Fire', 35, 657, 113];
      end;
      RunesPerEss := (Players[CurrentPlayer].Level[7] div RuneInfo[1]) + 1;

    For exp

    SCAR Code:
    RuneNames := ['Air', 'Mind', 'Water', 'Earth', 'Fire', 'Body', 'Cosmic', 'Choas', 'Nature', 'Law', 'Death', 'Blood'];
      InStrArrEx(RuneInfo[0] {Our rune}, RuneNames, I);;

    SCAR Code:
    Gl := 1; //RC gloves 2 when wearing
      E := Round(EssenceBeingCarried * Gl * (5 + (I * 0.5)));

    for getting exact amount crafted

    SCAR Code:
    Runes := ItemCoords(II + 1);
      Count := GetAmount(Runes.X, Runes.Y);
      if (Count < (EssenceBeingCarried * RunesPerEss)) then
        Count := (EssenceBeingCarried * RunesPerEss);

    II would be like how many options you are using that take up extra inventory spots... like if Talisman is true thats II is at 1 so runes will be in 2nd slot because II + 1, if all four pouches than II = 4 so then 5 spot ect.. get the cords of that spot then get amount and check to see if it returns a valid amount... if you don't want to do that then just use ItemCoords(1); also a good way to know what level you are is check EXP and Level after each player logs in then add to EXP everytime you craft and use a convert XPToLevel to increase the skill level so you don't have to change tabs every second... or you could just make something that detects if the 'Congrats' chat comes up.

    Yea, any of the above functions posted by everyone should work. Just thought I'd tell you how I do it.

    If you are going to use anything that finds the rune, it's best to use a DTM that won't have any points that could possibly be covered up by the numbers... one proper DTM (255 main point tol, and black borderline points) would work for all runes and essence. All the bitmaps/dtms/ and runeamount in SRL don't work.
    Last edited by Wanted; 01-15-2010 at 06:04 PM.

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
  •