Results 1 to 21 of 21

Thread: Array in an array...

  1. #1
    Join Date
    Feb 2006
    Posts
    920
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Array in an array...

    Ever wanted to make those neat arrays that no one, but yourself understand?
    Well I like to make them often and very advanced..
    Here I will suggest that you have read Kanes tutorial on arrays before starting, because I will not teach you arrays from the start

    PHP Code:
    var
      
    myArray: Array of Array of Array of Integer
    That's the kind of arrays I will teach you to use today..

    You might ask yourself, what could I use those arrays for? They just seem to be a lot of work..

    I found use of them several times, let me give you my latest example:

    PHP Code:
    var
      
    aPoints: Array[0..2]of TPointArray;

    begin
      
    for aCount := 0 to 2 do
      
    begin
        FindColorsTolerance
    (aPoints[aCount], color,1151533610);
        
    Wait(50);
      
    end;
      for 
    aCount := 0 to 2 do
        for 
    bCount := 0 to GetArrayLength(aPoint[aCount]) - do 
    This script will find all the colors 3 times, and then loop through them all, perhaps you could make a gas solver out of this..

    I know that StarBlaster also uses multidimensional arrays in his Essense miner...

    Simple as it sounds, when you want to make a multidimensional you just define an array of an array..

    and when you want to get info from it you make two boxes:

    PHP Code:
    var
      
    myArray: Array of Array of String;
      
    myStringString;

    begin
      myString 
    := 'IOWN';
      
    SetArrayLength(myArray1);
      for 
    aCount := 0 to Length(myString) - do
      
    begin
        SetArrayLength
    (myArray[0], aCount 1);
        Array[
    0][aCount] := myString.aCount;
      
    end;

    and 
    so on and so on.. 
    Can someone say autoresponder?

    I see the use of multi dimensional arrays everywhere, but don't overdo it... you need to understand it yourself

    I hope you found it usefull, if you didn't then you aren't ready to learn the secrets of multi dimensional arrays..

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

    Default

    Nice. We need more tuts like this, the weird crap that no one ever talks about.

  3. #3
    Join Date
    Feb 2006
    Location
    New Zealand
    Posts
    1,330
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ooooo thanks. I always had a problem with setting multidimension arrays. now i see. So you call set the first bit then when you set the second you call it as (array[whatever],length) yip yip gotcha.

    Thanks heaps.

  4. #4
    Join Date
    Apr 2007
    Posts
    581
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    Aha yes just what I was looking for. Thanks.

    I did the same thing except in C++ format :P

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

    Default

    I've made an autoresponder with 2 dimensional arrays a long time ago.. but I got lazy on the part filling every word in and thinking of sentences..



    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)

  6. #6
    Join Date
    Feb 2006
    Location
    London, England
    Posts
    2,045
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    nice tut.

    Directly from my ess miner:
    PHP Code:
    MoveCount: Array[1..6of Array[1..12of Integer
    SRL Wiki | SRL Rules | SRL Stats
    Ultimate SCAR Scripting Tutorial | Starblaster100's Auth System | Join the official SRL IRC now!


    Help Keep SRL Alive! Please disable Advert Blockers on SRL! Help Keep SRL Alive!


  7. #7
    Join Date
    Jan 2007
    Location
    Not here
    Posts
    1,604
    Mentioned
    2 Post(s)
    Quoted
    19 Post(s)

    Default

    0.o this was in the beginners section? now I feel really nubular :s
    Sleeping...

  8. #8
    Join Date
    Jul 2008
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by rkroxpunk View Post
    0.o this was in the beginners section? now I feel really nubular :s
    Agreed, I didn't understand much in this tutorial.

  9. #9
    Join Date
    Oct 2007
    Location
    If (Online) then Loc := ('On comp') else Loc := ('Somewhere else!');
    Posts
    2,020
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    try reading more tuts and getting more knowledge befor trying tu sus what these are from

  10. #10
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    Quote Originally Posted by TehElite View Post
    Agreed, I didn't understand much in this tutorial.
    EPIC FAIL.
    12-18-2006, 04:31 AM


    Good tut anyways Lorax.


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  11. #11
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Hy71194 View Post
    EPIC FAIL.
    12-18-2006, 04:31 AM


    Good tut anyways Lorax.
    It is a good tutorial, it is supposed to teach people stuff, and I don't think the author wrote this tutorial for the purpose of it being hid away and ignored. I see absolutely nothing wrong with "gravedigging tutorials", as long as they are useful to the community. If old, useful tutorials are gravegug, "newer" members of this community might read them because they found then unintentionally.

    To comment the tutorial: An easier way to declare 2/3D arrays would be T3D(int/point/ect)Array. Otherwise nice tutorial, should maybe be in the intermediate section? Newer scripters may be intimidated/scared away by this..

  12. #12
    Join Date
    Aug 2008
    Posts
    12
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    O, i thought it was harder =/.

    Lucky i found this straight away, Was just thinking about it.

  13. #13
    Join Date
    Jan 2007
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thx for tut

  14. #14
    Join Date
    Jan 2007
    Location
    Nomming bits in your RAM
    Posts
    385
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Helpful and easy. Nice tutorial.

    Rep++.
    Current Project: Catching up. XD. Potentially back for the summer, depending on how things go.

  15. #15
    Join Date
    Nov 2008
    Location
    Melbourne, Australia
    Posts
    2,240
    Mentioned
    3 Post(s)
    Quoted
    11 Post(s)

    Default

    nice 10 month gravedig
    Click here to find out how to get full screen without members! | Click here to check out my Ultimate Bitmap Tutorial! Edited to work with Simba! |

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

    Default

    AFAIK tutorials can't be gravedigged. It's even worth to bump some old, forgotten but good tutorials. And this one doesn't seem outdated but helpfull.

  17. #17
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    Thanks this will help me alot

    Edit: Damn I don't understand...
    I have:
    SCAR Code:
    var
      arr123: Array of TStringArray;
    begin
      arr123 := [[''],['']];
    end;
    How should it be like?


    Edit2: Figured out that I can do it this way:
    SCAR Code:
    var
      arr123: Array[0..2]of TStringArray;
    begin
      arr123[0] := [''];
      arr123[1] := [''];
    end;
    But is there a way to do that in 1 line?

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

    Default

    Quote Originally Posted by antti mies View Post
    Thanks this will help me alot

    Edit: Damn I don't understand...
    I have:
    SCAR Code:
    var
      arr123: Array of TStringArray;
    begin
      arr123 := [[''],['']];
    end;
    How should it be like?
    SCAR Code:
    var
      sArr array of array of string; // same as array of TStringArray; or T2DStringArray;
      H, I : Integer;

    begin
      SetArrayLength(sArr, 2);
      H := High(sArr); // We already know the high is 1 but this is good for learning
      for I := 0 to H do
        SetArrayLength(sArr[I], 2);
      sArr[0][0] := 'Hello';
      sArr[0][1] := 'Hi';
      sArr[1][0] := 'Bye';
      sArr[1][1] := 'cya';
    end.

    Remember arrays starts counting at 0, so an array with the length of 3 would be 0-2
    Last edited by Zyt3x; 01-16-2010 at 08:48 PM.

  19. #19
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    Thanks Zyt3x but is there a way to do these:
    SCAR Code:
    sArr[0][0] := 'Hello';
      sArr[0][1] := 'Hi';
      sArr[1][0] := 'Bye';
      sArr[1][1] := 'cya';
    in 1 line?

  20. #20
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by antti mies View Post
    Thanks Zyt3x but is there a way to do these:
    SCAR Code:
    sArr[0][0] := 'Hello';
      sArr[0][1] := 'Hi';
      sArr[1][0] := 'Bye';
      sArr[1][1] := 'cya';
    in 1 line?
    SCAR Code:
    SArr := [TStringArray(['Hello', 'Hi']), TStringArray(['Bye', 'Cya'])];

  21. #21
    Join Date
    Nov 2006
    Posts
    2,369
    Mentioned
    4 Post(s)
    Quoted
    78 Post(s)

    Default

    Tyvm!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need some array help..
    By Floor66 in forum OSR Help
    Replies: 2
    Last Post: 02-29-2008, 01:10 PM
  2. ItemColors: Array of Array of Integer
    By n3ss3s in forum Research & Development Lounge
    Replies: 5
    Last Post: 10-30-2007, 06:04 PM
  3. Array Help. ... . . .. !
    By kooldude in forum OSR Help
    Replies: 2
    Last Post: 06-19-2007, 06:16 PM
  4. Array of Tbox - And TPoint array helps.
    By R0b0t1 in forum OSR Help
    Replies: 4
    Last Post: 06-10-2007, 06:43 PM
  5. array help please
    By omgh4x0rz in forum OSR Help
    Replies: 4
    Last Post: 02-18-2007, 05:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •