Results 1 to 11 of 11

Thread: Array Inv Color Boolean?

  1. #1
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default Array Inv Color Boolean?

    I'm having trouble (because I lack spunk/knowledge on Arrays) with coming up with a function where I check my Invent for an array of colors.

    Ex. = Let's say I have a Inventory full of logs, like so:


    What I can think of so far, nowhere near perfect, nor claiming I thought of it all, nor does it even work, nor does it have the color looking for it too.. :/

    Simba Code:
    Function CountInvArryColorsArea: Boolean;
    Var
      I: Byte;
    Begin
      Result:= False;
      SetArrayLength(Result, 28);
      For I:= 2 To 27 Do // I only need to look over invent spots 3-27
        Result[I] := GetInven(i + 1);
    End;

    Again, my overall idea I'm trying to accomplish is this:
    Simba Code:
    // CountInvArrayColorArea(color, InvSpotStart, InvSpotEnd): Boolean;
    If (CountInvArryColorsArea(2, 27)) Then

    so it we have the approypiate colors in each of our designated spots, they we can continue.. I'm half drunk, might be able to find somebody's script to see an example / similar ex, but help would be appreciated!

  2. #2
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    I think I'm following you're saying here. You want to check inventory slot # 3-27 and make sure a specific color is found in each slot? Is that right?

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  3. #3
    Join Date
    Feb 2012
    Location
    Somewhere, over the rainbow...
    Posts
    2,272
    Mentioned
    3 Post(s)
    Quoted
    45 Post(s)

    Default

    You could always grab a TBox around co-ordinates 5 to 28....

  4. #4
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    I haven't tested this or anything, but see if this works:

    Simba Code:
    function CheckInvColor(Color, Tol, StartSlot, EndSlot: Integer): TBooleanArray;
    var
      i: Integer;
      x, y: Integer;
      Slot: TBox;
    begin
      if not LoggedIn then Exit;
      SetArrayLength(Result, 28);
      for i := StartSlot to EndSlot do
      begin
        Result[i] := False;
        Slot := GetInven(i);
        if ExistsItem(i) then
          Result[i] := FindColorTolerance(x, y, Color, Slot.x1, Slot.y1, Slot.x2, Slot.y2, Tol);
      end;
    end;
    Last edited by Runaway; 05-11-2012 at 05:52 PM.

  5. #5
    Join Date
    Dec 2010
    Posts
    89
    Mentioned
    4 Post(s)
    Quoted
    8 Post(s)

    Default

    Hey Le Jingle! I hope this helps! I've also tested the function in Runescape, and it works.
    I haven't been able to figure out how to search an Array of Colors...
    but if I can find out how to... I'll update this post.

    Cheers!

    Edit: StartInvBox and EndInvBox work on a scale from 0 to 27;
    Simba Code:
    function SearchInvColor(Color, Tol: Integer; Hue, Sat: Extended; StartInvBox, EndInvBox: Integer): Boolean;
    var
      I, x, y, tmpCTS: integer;
      invPattern: TIntegerArray;
      slotBox:TBox;

    begin
      tmpCTS:= GetColorToleranceSpeed;
      ColorToleranceSpeed(2);            //searches using CTS 2
      SetColorSpeed2Modifiers(Hue, Sat); //Hue and Sat modifiers

      invPattern := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
                    , 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28]; //the pattern it searches in

      Writeln('Checking for colors in your Inventory.');
      for I:= (StartInvBox) to (EndInvBox) do
        begin
          slotBox:= InvBox(invPattern[I]);
          //Writeln('Checking item colors in InvBox['+IntToStr(invPattern[I])+']');
          if (not FindColorTolerance(x, y, Color, slotBox.x1, slotBox.y1, slotBox.x2, slotBox.y2, Tol)) then
            begin
              Writeln('Could not find the color in InvBox['+IntToStr(invPattern[I])+']!');
              Result:= false; // Could not find color
              Exit; //  Comment this line if you want
            end;
        end;

      SetColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);
      Result:= true;
    end;
    Last edited by Valithor; 05-11-2012 at 06:17 PM.

  6. #6
    Join Date
    May 2007
    Location
    England
    Posts
    4,141
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Quote Originally Posted by Runaway View Post
    I haven't tested this or anything, but see if this works:

    Simba Code:
    function CheckInvColor(Color, Tol, StartSlot, EndSlot: integer): boolean;
    var
      i: integer;
      x, y: integer;
      Slot: tbox;
    begin
      if not LoggedIn then Exit;
      SetArrayLength(Result, 28);
      for i := StartSlot to EndSlot do
      begin
        Result[i] := False;
        Slot := GetInven(i);
        if ExistsItem(i) then
          Result := FindColorTolerance(x, y, Color, Slot.x1, Slot.y1, Slot.x2, Slot.y2, Tol);
      end;
    end;
    Perhaps make the result an array of booleans, so we can see which slots don't have that colour?
    Simba Code:
    function CheckInvColor(Color, Tol, StartSlot, EndSlot: integer): TBooleanArray;
    var
      i: integer;
      x, y: integer;
      Slot: tbox;
    begin
      if not LoggedIn then Exit;
      SetArrayLength(Result, 28);
      for i := StartSlot to EndSlot do
      begin
        Result[i] := False;
        Slot := GetInven(i);
        if ExistsItem(i) then
          if FindColorTolerance(x, y, Color, Slot.x1, Slot.y1, Slot.x2, Slot.y2, Tol) then
            Result[I]:= True;
      end;
    end;
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  7. #7
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Rich View Post
    Perhaps make the result an array of booleans, so we can see which slots don't have that colour?
    Whoops, meant to do that :P

  8. #8
    Join Date
    May 2007
    Location
    England
    Posts
    4,141
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Quote Originally Posted by Runaway View Post
    Whoops, meant to do that :P
    You still haven't changed the function type to TBooleanArray
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

  9. #9
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Rich View Post
    You still haven't changed the function type to TBooleanArray
    oy, there we go >.<

  10. #10
    Join Date
    Feb 2012
    Location
    Wonderland
    Posts
    1,988
    Mentioned
    41 Post(s)
    Quoted
    272 Post(s)

    Default

    Type mismatch @ Slot:= GetInven(i);

    I'll try to fix it myself, and nonetheless, thanks x1000 for the help. I'm thinking I should go to the library this week and try to find a couple of pascal books to check out to reference. :>

    Edit : going to try this out

    Simba Code:
    Function CheckInvColor(Color, Tol, StartSlot, EndSlot: Integer): TBooleanArray;
    Var
      i: Integer;
      x, y: Integer;
      Slot: TInvenItem;
      Slota: Tbox;
    Begin
      If Not LoggedIn Then
        Exit;
      SetArrayLength(Result, 28);
      For i:= StartSlot To EndSlot Do
      Begin
        Result[i]:= False;
        Slot:= GetInven(i);
        If ExistsItem(i) Then
        Result[i]:= FindColorTolerance(x, y, Color, Slota.x1, Slota.y1, Slota.x2, Slota.y2, Tol);
      End;
    End;
    Last edited by Le Jingle; 05-13-2012 at 06:40 AM.

  11. #11
    Join Date
    Jan 2008
    Location
    C:\
    Posts
    1,483
    Mentioned
    2 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Le Jingle View Post
    Type mismatch @ Slot:= GetInven(i);

    I'll try to fix it myself, and nonetheless, thanks x1000 for the help. I'm thinking I should go to the library this week and try to find a couple of pascal books to check out to reference. :>

    Edit : going to try this out

    Simba Code:
    Function CheckInvColor(Color, Tol, StartSlot, EndSlot: Integer): TBooleanArray;
    Var
      i: Integer;
      x, y: Integer;
      Slot: TInvenItem;
      Slota: Tbox;
    Begin
      If Not LoggedIn Then
        Exit;
      SetArrayLength(Result, 28);
      For i:= StartSlot To EndSlot Do
      Begin
        Result[i]:= False;
        Slot:= GetInven(i);
        If ExistsItem(i) Then
        Result[i]:= FindColorTolerance(x, y, Color, Slota.x1, Slota.y1, Slota.x2, Slota.y2, Tol);
      End;
    End;
    It might be easier to just use InvBox() as that will skip the need to convert a TInvenItem -> TBox. I don't know why I suggested GetInven() in the first place >.<

    Simba Code:
    Function CheckInvColor(Color, Tol, StartSlot, EndSlot: Integer): TBooleanArray;
    Var
      i: Integer;
      x, y: Integer;
      Slot: Tbox;
    Begin
      If Not LoggedIn Then
        Exit;
      SetArrayLength(Result, 28);
      For i:= StartSlot To EndSlot Do
      Begin
        Result[i]:= False;
        Slot:= InvBox(i);
        If ExistsItem(i) Then
          Result[i]:= FindColorTolerance(x, y, Color, Slot.x1, Slot.y1, Slot.x2, Slot.y2, Tol);
      End;
    End;

    That one should work fine, and it'll be a tiiiiny bit faster
    Last edited by Runaway; 05-13-2012 at 11:43 AM.

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
  •