Results 1 to 4 of 4

Thread: SlotsWithItemDtm

  1. #1
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default SlotsWithItemDtm

    SCAR Code:
    Function SlotsWithItemDtm(Dtm:Integer):Array of boolean;
    var
      box:TBox;
      I, x, y:Integer;
    begin
      SetArrayLength(Result, 27)
      for I:=1 to 28 do
      begin
        Box:=InvBox(I)
        If FindDTM(dtm, x, y, Box.x1, Box.y1, Box.x2, Box.y2)then Result[I-1]:=True;
      end;
    end;
    Note: slot one is really result[0] and solt two is result[1] and so on

  2. #2
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    If you want 1 to 28 you could do
    SCAR Code:
    Function SlotsWithItemDtm(Dtm:Integer):Array [1..28] of boolean;
    var
      box:TBox;
      I, x, y:Integer;
    begin
      for I:=1 to 28 do
      begin
        Box:=InvBox(I)
         Result[I] := FindDTM(dtm, x, y, Box.x1, Box.y1, Box.x2, Box.y2);
      end;
    end;

    The Result := FindDTM is shorter but also more accurate, otherwhise you'll have to set every slot's boolean which has no dtm to false, pascal and delphi have these annyoing variable initialisation bugs.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  3. #3
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    IMO a TIntegerArray returned would be more useful so you could then just run a for loop through them all and do whatever, but it's a simple little function that does what it should, so that makes it good
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  4. #4
    Join Date
    Mar 2007
    Posts
    3,116
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    If you want 1 to 28 you could do
    SCAR Code:
    Function SlotsWithItemDtm(Dtm:Integer):Array [1..28] of boolean;
    var
      box:TBox;
      I, x, y:Integer;
    begin
      for I:=1 to 28 do
      begin
        Box:=InvBox(I)
         Result[I] := FindDTM(dtm, x, y, Box.x1, Box.y1, Box.x2, Box.y2);
      end;
    end;

    The Result := FindDTM is shorter but also more accurate, otherwhise you'll have to set every slot's boolean which has no dtm to false, pascal and delphi have these annyoing variable initialisation bugs.
    I tried doing the 1-28 thing and it wouldn't compile, now it does

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
  •