Results 1 to 11 of 11

Thread: TIntegerArray Question

  1. #1
    Join Date
    Aug 2009
    Location
    Inside the Matrix...yes it has me, and it has you too.
    Posts
    1,896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default TIntegerArray Question

    Ok. I have a TIntegerArray, is there any way I can have it in a For..To..Do loop from the first integer to the last in order? I did a quick look through the WizzyPlugin, nothing caught my eye...help?
    NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN

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

    Default

    Quote Originally Posted by bionicle1800 View Post
    Ok. I have a TIntegerArray, is there any way I can have it in a For..To..Do loop from the first integer to the last in order? I did a quick look through the WizzyPlugin, nothing caught my eye...help?
    You mean, the normal first order?

    SCAR Code:
    for I := to High(IntArr) do
    //stuff

    or do you mean by size?

    QuickSort is the best... it will do [0] big, last small... so you could just InvertTPA or do [High(Arr)]

    Not sure what you want though based on that question

  3. #3
    Join Date
    Aug 2009
    Location
    Inside the Matrix...yes it has me, and it has you too.
    Posts
    1,896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    k ill explain what i'm trying to do.
    im making a dropping procedure for my script.
    i have a few TIntegerArrays:
    SCAR Code:
    WayDrop1 := [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];

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

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

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

      WayDrop5 := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
                   27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
    Each integer representing an InvBox. I tryed this:
    SCAR Code:
    Case Random(5) Of
        0: Begin
             L := Low(WayDrop1);
             H := High(WayDrop1);
           End;
        1: Begin
             L := Low(WayDrop2);
             H := High(WayDrop2);
           End;
        2: Begin
             L := Low(WayDrop3);
             H := High(WayDrop3);
           End;
        3: Begin
             L := Low(WayDrop4);
             H := High(WayDrop4);
           End;
        4: Begin
             L := Low(WayDrop5);
             H := High(WayDrop5);
           End;
      End;
    and
    SCAR Code:
    For I := L To H Do
    but it does it in order from the first to the last (eg, if the array starts with 4 and ends with 8, it does 4, 5, 6, 7, 8 instead of 4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22, 27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8)

    (these have a distinct pattern when dropped on a side note)
    Last edited by Bionicle; 01-30-2010 at 12:37 AM.
    NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN

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

    Default

    SCAR Code:
    case Random(5) of
      0: WayDrop := [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];
      1: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
                   19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
      2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
                   19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
      3: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
                   18, 23, 28, 17, 22, 27, 21, 26, 25];
      4: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
                   27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
    end;

    Much easier IMO, even better ways to do it than that even... this one is pretty suited for your use though. I think SRL has drop patterns though you could use... not entirely sure about that one...

  5. #5
    Join Date
    Aug 2009
    Location
    Inside the Matrix...yes it has me, and it has you too.
    Posts
    1,896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by IceFire908 View Post
    SCAR Code:
    case Random(5) of
      0: WayDrop := [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];
      1: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
                   19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
      2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
                   19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
      3: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
                   18, 23, 28, 17, 22, 27, 21, 26, 25];
      4: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
                   27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
    end;

    Much easier IMO, even better ways to do it than that even... this one is pretty suited for your use though. I think SRL has drop patterns though you could use... not entirely sure about that one...
    Yes it does, but i ask you this. if everyone uses these drop patterns in their script, it would seem kind of suspicious, don't you think?
    Anyway, thanks, I got it working(well compiled, testing it now)
    I'd rep you, but it says i need to spread some around first :/
    E: Yep, all five patterns work flawlessly, Thanks
    Last edited by Bionicle; 01-30-2010 at 01:03 AM.
    NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN

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

    Default

    Quote Originally Posted by bionicle1800 View Post
    Yes it does, but i ask you this. if everyone uses these drop patterns in their script, it would seem kind of suspicious, don't you think?
    Anyway, thanks, I got it working(well compiled, testing it now)
    I'd rep you, but it says i need to spread some around first :/
    True, in-case you feel like being OCD:

    SCAR Code:
    var
      WayDrop: array [0..4] of TIntegerArray;
      Index, I: Byte;
    begin
      WayDrop[0] := [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];
      WayDrop[1] := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
                   19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
      WayDrop[2] := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
                   19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
      WayDrop[3] := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
                   18, 23, 28, 17, 22, 27, 21, 26, 25];
      WayDrop[4] := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
                   27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
      Index := Random(5);
      for I := 0 to High(WayDrop[Index]) do
        WriteLn(WayDrop[Index][I]);
    end.

    Or just plain stupid like me:

    SCAR Code:
    function IArr(IA: TIntegerArray): TIntegerArray;
    begin
      Result := IA;
    end;

    var
      WayDrop: T2DIntegerArray;
      Index, I: Byte;
    begin
      WayDrop := [IArr([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]), IArr([1, 5, 9, 13, 17, 21, 25, 2,
                   6, 10, 14, 18, 22, 26, 3, 7, 11, 15, 19, 23, 27, 4, 8, 12, 16, 20, 24,
                   28]), IArr([1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11,
                   15, 19, 23, 27, 28, 24, 20, 16, 12, 8, 4]), IArr([4, 3, 8, 2, 7, 12, 1,
                   6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13, 18, 23, 28, 17, 22, 27, 21,
                   26, 25]), IArr([4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25,
                   17, 22, 27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8])];
      Index := Random(Length(WayDrop));
      for I := 0 to High(WayDrop[Index]) do
        WriteLn(WayDrop[Index][I]);
    end.

    Maybe some math rhythm?... but I'm too lazy :-P
    Last edited by Wanted; 01-30-2010 at 01:11 AM.

  7. #7
    Join Date
    Aug 2009
    Location
    Inside the Matrix...yes it has me, and it has you too.
    Posts
    1,896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Actually i simply did:
    SCAR Code:
    Begin
      If Not LoggedIn Then
        Exit;
       
      If Not GameTab(Tab_Inv) Then
        GameTab(Tab_Inv);
       
      Case Random(5) Of
        0: WayDrop := [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];
        1: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
                     19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
        2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
                     19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
        3: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
                     18, 23, 28, 17, 22, 27, 21, 26, 25];
        4: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
                     27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
      End;

      For I := 0 To 27 Do
      Begin
        LogInv := InvBox(WayDrop[I]);
        If FindDTM(Log, X, Y, LogInv.X1, LogInv.Y1, LogInV.X2, LogInv.Y2) Then
        Begin
          //all the dropping stuff

    The overall procedure works really well...in fact i think it is better then the SRL drop, as it detects whether it was dropped or not, and if that fails, drops any excess items after the rest have been dropped.

    E: I accidentally had Case 4 Of instead of Case Random(5) Of, as I was testing the fourth dropping algorithm
    Last edited by Bionicle; 01-30-2010 at 01:48 AM.
    NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN

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

    Default

    Quote Originally Posted by IceFire908 View Post
    True, in-case you feel like being OCD:

    Code:
    var
    WayDrop: array [0..4] of TIntegerArray;
    Index, I: Byte;
    begin
    WayDrop[0] := [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];
    WayDrop[1] := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
    19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
    WayDrop[2] := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
    19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
    WayDrop[3] := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
    18, 23, 28, 17, 22, 27, 21, 26, 25];
    WayDrop[4] := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
    27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
    Index := Random(5);
    for I := 0 to High(WayDrop[Index]) do
    WriteLn(WayDrop[Index][I]);
    end.


    Or just plain stupid like me:

    Code:
    function IArr(IA: TIntegerArray): TIntegerArray;
    begin
    Result := IA;
    end;

    var
    WayDrop: T2DIntegerArray;
    Index, I: Byte;
    begin
    WayDrop := [IArr([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]), IArr([1, 5, 9, 13, 17, 21, 25, 2,
    6, 10, 14, 18, 22, 26, 3, 7, 11, 15, 19, 23, 27, 4, 8, 12, 16, 20, 24,
    28]), IArr([1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11,
    15, 19, 23, 27, 28, 24, 20, 16, 12, 8, 4]), IArr([4, 3, 8, 2, 7, 12, 1,
    6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13, 18, 23, 28, 17, 22, 27, 21,
    26, 25]), IArr([4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25,
    17, 22, 27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8])];
    Index := Random(Length(WayDrop));
    for I := 0 to High(WayDrop[Index]) do
    WriteLn(WayDrop[Index][I]);
    end.


    Maybe some math rhythm?... but I'm too lazy :-P
    You do not need the IArr function..you can just use:
    SCAR Code:
    var
      WayDrop: T2DIntegerArray;
      Index, I: Byte;
    begin
      WayDrop := [TIntegerArray([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]), TIntegerArray([1, 5, 9, 13, 17, 21, 25, 2,
                   6, 10, 14, 18, 22, 26, 3, 7, 11, 15, 19, 23, 27, 4, 8, 12, 16, 20, 24,
                   28]), TIntegerArray([1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11,
                   15, 19, 23, 27, 28, 24, 20, 16, 12, 8, 4]), TIntegerArray([4, 3, 8, 2, 7, 12, 1,
                   6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13, 18, 23, 28, 17, 22, 27, 21,
                   26, 25]), TIntegerArray([4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25,
                   17, 22, 27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8])];
      Index := Random(Length(WayDrop));
      for I := 0 to High(WayDrop[Index]) do
        WriteLn(WayDrop[Index][I]);
    end.
    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"

  9. #9
    Join Date
    Dec 2006
    Location
    Sydney, New South Wales, Australia
    Posts
    4,603
    Mentioned
    15 Post(s)
    Quoted
    42 Post(s)

    Default

    Quote Originally Posted by bionicle1800 View Post
    Actually i simply did:
    SCAR Code:
    Begin
      If Not LoggedIn Then
        Exit;
       
      If Not GameTab(Tab_Inv) Then
        GameTab(Tab_Inv);
       
      Case Random(5) Of
        0: WayDrop := [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];
        1: WayDrop := [1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15,
                     19, 23, 27, 4, 8, 12, 16, 20, 24, 28];
        2: WayDrop := [1, 5, 9, 13, 17, 21, 25, 26, 22, 18, 14, 10, 6, 2, 3, 7, 11, 15,
                     19, 23, 27, 28, 24, 20, 16, 12, 8, 4];
        3: WayDrop := [4, 3, 8, 2, 7, 12, 1, 6, 11, 16, 5, 10, 15, 20, 9, 14, 19, 24, 13,
                     18, 23, 28, 17, 22, 27, 21, 26, 25];
        4: WayDrop := [4, 2, 7, 12, 5, 10, 15, 20, 13, 18, 23, 28, 21, 26, 25, 17, 22,
                     27, 9, 14, 19, 24, 1, 6, 11, 16, 3, 8];
      End;

      For I := 0 To 27 Do
      Begin
        LogInv := InvBox(WayDrop[I]);
        If FindDTM(Log, X, Y, LogInv.X1, LogInv.Y1, LogInV.X2, LogInv.Y2) Then
        Begin
          //all the dropping stuff
    I never knew the inventory started at 0. :S
    You may contact me with any concerns you have.
    Are you a victim of harassment? Please notify me or any other staff member.

    | SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |

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

    Default

    Quote Originally Posted by Dan's The Man View Post
    I never knew the inventory started at 0. :S
    It doesn't, but the array does

  11. #11
    Join Date
    Aug 2009
    Location
    Inside the Matrix...yes it has me, and it has you too.
    Posts
    1,896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Dan's The Man View Post
    I never knew the inventory started at 0. :S
    Lets say the random WayDrop was 0, if I := 0 for the first time around, it would use the very first integer in the integer array 'WayDrop', which would be 1.
    NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN

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
  •