Results 1 to 7 of 7

Thread: Strange count colour error

  1. #1
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default Strange count colour error

    can someone tell me why

    Simba Code:
    program new;
      {$i SRL/SRL.scar}
      {$i SRL/SRL/Misc/Stats.scar}
      {$i SRL/SRL/Misc/Users.scar}
      {$i SRL/SRL/Misc/Reports.scar}
      {$i SRL/SRL/Misc/Debug.scar}

    function Get_Black_Count(Slot, Color: Integer; Bank: Boolean): Integer;
    var
      b: TBox;
    begin
      Result := 0;
      if Bank then
        b := BankIndexToMSBox(Slot)
      else
        b := InvBox(Slot);
      Result := CountColor(Color, b.X1, b.Y1 + 15, b.X2, b.Y2);
    end;

    function Count_Items(Count, Start_Slot, Finish_Slot: Integer; out Slots: array of Integer): Integer;
    var
      i: Integer;
    begin
      SetLength(Slots, 50);
      Result := 0;

      for i := Start_Slot to Finish_Slot do
        if(Get_Black_Count(i, SRL_OUTLINE_BLACK, true) = Count) then
        begin
          Inc(Result);
          Slots[Result - 1] := i;
        end;

      SetLength(Slots, Result);
    end;

    procedure OutputArray(const Arr: TIntegerArray; Write: string);
    var
      I, ArrLength: Integer;
      S: string;
    begin
      ArrLength := High(Arr);
      S := '  ' + Write + ' := [';

      for I := 0 to ArrLength do
        S := S + IntToStr(Arr[I]) + ', ';

      Delete(S, Length(S) - 1, Length(S));
      S := S + '];';
      Writeln(S);
    end;

    var
      i, Item_Amount, ColourCount :integer;
      SlotsIn: array of Integer;

    begin
      setupSRL;
      ActivateClient;
      wait(1000);
      ColourCount := Get_Black_Count(1, srl_outline_black, False); // tried with SRL's constant. and 131072  all are 35
      writeln('Colour Count is '+inttostr(ColourCount));
      for i := 1 to 12 do
      begin
       writeln(inttostr(Get_Black_Count(i, srl_outline_black, false)));
      end;
      Item_Amount := Count_Items(35,1,12,SLOTSIN);
      OutputArray(SlotsIn, 'COUNT ITEMS:')
      writeln('Item Amount is '+inttostr(Item_Amount));
    end.

    outputs
    Code:
    Compiled succesfully in 1825 ms.
    SRL Compiled in 16 msec
    Colour Count is 35
    35
    39
    35
    39
    35
    35
    35
    39
    35
    35
    35
    39
      COUNT ITEMS: :=];
    Item Amount is 0
    Successfully executed.
    when the inventory is


    when item amount should equal 8 and slots in should be 1, 3, 5, 6, 7, 9, 10, 11

    i really have no idea why, its already in safe mode and i have tried with SMART



  2. #2
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    if(Get_Black_Count(i, SRL_OUTLINE_BLACK, true) = Count) then
    try false?

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

    Default

    Also, Simba is capable of outputting whole arrays.. Just do WriteLn(Array);
    Oh, and types too... WriteLn(TMufasaBitmap); would work and so on...

    Simba Code:
    function Count_Items(Count, Start_Slot, Finish_Slot: Integer; Bank : Boolean; out Slots: array of Integer): Integer;
    var
      i: Integer;
    begin
      SetLength(Slots, 50);
      Result := 0;

      for i := Start_Slot to Finish_Slot do
        if(Get_Black_Count(i, SRL_OUTLINE_BLACK, Bank) = Count) then
        begin
          Inc(Result);
          Slots[Result - 1] := i;
        end;

      SetLength(Slots, Result);
    end;
    Would work

  4. #4
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Boreas View Post
    if(Get_Black_Count(i, SRL_OUTLINE_BLACK, true) = Count) then
    try false?
    I'm pretty sure thats all I need to change, I have noidea when I changed that function because at the moment it always make a TBox of the bank boxes instead of inventory like I thought it was doing, I can not check it right now I will have to wait till this arvo
    Quote Originally Posted by Zyt3x View Post
    Also, Simba is capable of outputting whole arrays.. Just do WriteLn(Array);
    Oh, and types too... WriteLn(TMufasaBitmap); would work and so on...

    Simba Code:
    function Count_Items(Count, Start_Slot, Finish_Slot: Integer; Bank : Boolean; out Slots: array of Integer): Integer;
    var
      i: Integer;
    begin
      SetLength(Slots, 50);
      Result := 0;

      for i := Start_Slot to Finish_Slot do
        if(Get_Black_Count(i, SRL_OUTLINE_BLACK, Bank) = Count) then
        begin
          Inc(Result);
          Slots[Result - 1] := i;
        end;

      SetLength(Slots, Result);
    end;
    Would work
    I'm positive that's how I originally wrote that function, thankyou

    I didn't know about writeln(Array) or writeln(TMufasaBitmap) I will look at them later today

    Thankyou for looking at this, I will post back here if that fixed it but I'm certian that's the error



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

    Default

    I think WriteLn(TMufasaBitmap); Would either return a runtime error or print out "nil" though :P so it would be better to test with your own types
    Like this:
    Simba Code:
    type
      Stuff = record
        Blah : Integer;
        Foo, Bar : String;
      end;

  6. #6
    Join Date
    Oct 2006
    Posts
    1,190
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    adding the InBank boolean fixed it, i had wrked on my script for a while and i was certian there was nothing wrong with any of my functons, and it was such a simple frustrating error

    thanks for telling me about that, how long has writeln(Array) be functonal in simba?

    im sure i will ue writeln(TMufasaBitmap) somewhere it will be useful for debugging



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

    Default

    Yes, this is very helpful for debugging
    I'm not sure for how long it's been in Simba, but it's been for a while..
    Glad you worked it out

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
  •