Page 1 of 2 12 LastLast
Results 1 to 25 of 27

Thread: Static Arrays!!!!

  1. #1
    Join Date
    Mar 2007
    Posts
    4,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Static Arrays!!!!

    All About Static Arrays!!!



    Welcome to NaumanAkhlaQ's tutorial for using and implementing arrays in your script.


    What are arrays used for?


    Arrays take two forms -

    --> One of them are static arrays which run within the script, basically they stay the same.

    --> The second are ones which take info from the client at specific points, a prime example being DDTM's.


    In this tutorial we will cover Statics Arrays


    So How'd You Declare Them?


    Here is an example:

    SCAR Code:
    Procedure CutTree;
    Var
    YewColor : Array [0..5] of Integer;
    i :Integer;
    Begin
      YewColor[0]:=2182984;
      YewColor[1]:=1855560;
      YewColor[2]:=4426622;
      YewColor[3]:=1914933;
      YewColor[4]:=3239519;
      YewColor[5]:=3116158;
       Begin
     If (not (Loggedin)) then
      Exit;
    else   
      For i:= 0 to 5 do
        If FindObjCustom(x,y,['ew'],[YewColor[i]],5) then
          Begin
            If IsUpText('ew') then
               Begin
                 CutDown;
               end;
          end;
      end;

    Firstly there are two things you should know, There are two different ways of declaring them. Declaring meaning the line under
    SCAR Code:
    var
    <-- Our variables. They must be declared at the beginning of the procedure (Local Declaration) or the script (Global declaration)

    One way:
    SCAR Code:
    SetArrayLength(YewColor, 5)

    That says that there are 5 different arrays which are in the Integer , so in this case 4 different colors (0..4 )

    Second Way:
    SCAR Code:
    YewColor : Array [0..5] of Integer;

    ^ I prefer this way as I am a ' . ' maniac! ^



    So How'd You Set Them up?



    Refering to our first example:

    SCAR Code:
    YewColor[0]:=2182984;
      YewColor[1]:=1855560;
      YewColor[2]:=4426622;
      YewColor[3]:=1914933;
      YewColor[4]:=3239519;
      YewColor[5]:=3116158;

    SCAR Code:
    YewColor
    is the color of the yew, pretty self explanatory.

    SCAR Code:
    YewColor[0] := ......

    When you use them you put the number in this case [0..5] on the end in square brackets because if you don’t you get a 'Duplicate
    Identifier' error!


    How to Use 'em In Your Script?


    For how many numbers you entered in the
    SCAR Code:
    YewColor : Array [ --> 0..5 <-- ] of Integer;
    bit you have to use the line

    SCAR Code:
    for 0 to 5 do
    see where we got that from?
    When we declared the array we made out how many colours we could store (6).

    Now what:

    SCAR Code:
    for i:=0 to 5 do

    does is it looks at all the colors and incorporates it in the next line so in the next line we have to have:

    SCAR Code:
    For i:= 0 to 5 do
      If FindObj(x,y,'ree',YewColor[i],6) then....

    the integer ' i ' searches all the arrays for 0 to 5 so instead of using a
    Function like this:

    SCAR Code:
    If FindObj(x,y,'ree',4354,5) or
      FindObj(x,t,'Tre',976897,5) or
    {so on}

    You can use an array instead

    Confucious say:

    " Arrays, great for saving time and effort


    Hopefully you understood that short tut.
    Might add another section soon.

    Peace Out



    If you liked this TUT don't froget I always like a bit of reppage <--!!!

  2. #2
    Join Date
    Jul 2007
    Posts
    1,440
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hmm, maybe make font more readable? Really it dont have to big and colorful, it makes it only harder to read...

    else, very useful...nice.
    [CENTER][SIZE="4"]Inactive[/SIZE]I forgot my password[/CENTER]

  3. #3
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,803
    Mentioned
    1 Post(s)
    Quoted
    23 Post(s)

    Default

    Ehm... Nauman... The purpose of something doesn't change what it is, an array of TDTMPointDef, aka DDTM, is just like any other array with more variables.

    DDTMs are just as dynamic as TPointArrays or any other array.

  4. #4
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,887
    Mentioned
    6 Post(s)
    Quoted
    121 Post(s)

    Default

    Nice tut, though these aren't truly static arrays, since they can be changed from within the running script.

  5. #5
    Join Date
    Mar 2007
    Posts
    4,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  6. #6
    Join Date
    Feb 2006
    Location
    Belgium
    Posts
    3,141
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by senrath View Post
    Nice tut, though these aren't truly static arrays, since they can be changed from within the running script.
    They are static arrays, just not constant static arrays...
    Btw, decent tutorial, but the font hurts my eyes...

  7. #7
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,887
    Mentioned
    6 Post(s)
    Quoted
    121 Post(s)

    Default

    My bad, I keep mixing those two up. Yeah, I guess they are static since they don't ever change in length. Whoops :P

  8. #8
    Join Date
    Jun 2006
    Posts
    3,864
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by NaumanAkhlaQ View Post
    One way:
    SCAR Code:
    SetArrayLength(YewColor, 5)

    That says that there are 5 different arrays which are in the Integer , so in this case 6 different colors (Including [0] remember )
    Incorrect, the array would only have 0..4. Other than that, the tutorial's good

  9. #9
    Join Date
    Mar 2007
    Posts
    4,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  10. #10
    Join Date
    Apr 2007
    Posts
    997
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Great! Now I can find aggie without tones of ORs.

    That green is painful, but thanks for the tut
    [QUOTE]<GoF`> oh no its Raymooond
    <Raymooond> Heya
    <GoF`> is it ray or some other ray?
    <LeeLokHin> No idea
    <LeeLokHin> Raymond, what's the game you like the most?
    <Raymooond> Runescape
    <-- LeeLokHin has kicked Raymooond from #srl (Faker.)[/QUOTE]

  11. #11
    Join Date
    Mar 2007
    Posts
    4,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  12. #12
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,813
    Mentioned
    1 Post(s)
    Quoted
    1 Post(s)

    Default

    Repped!!!! Thanks, I think this should solve my fishing problem. I just need to test it now.

    Nava2
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

  13. #13
    Join Date
    Mar 2007
    Posts
    4,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  14. #14
    Join Date
    Apr 2008
    Posts
    67
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    really nice tut.
    Now i know more about arrays.
    Maybe i should use them too. oO

  15. #15
    Join Date
    Mar 2007
    Posts
    4,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  16. #16
    Join Date
    Sep 2008
    Posts
    1
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yoz

  17. #17
    Join Date
    Dec 2006
    Location
    Banville
    Posts
    3,685
    Mentioned
    2 Post(s)
    Quoted
    1 Post(s)

    Default

    They aren't static/constant arrays you give examples of (even if you argue that by 'static', you mean a fixed length, this thread is a repeat). This:

    SCAR Code:
    const MyArray := ('Hello',
                      'Goodbye.')

    is.
    The jealous temper of mankind, ever more disposed to censure than
    to praise the work of others, has constantly made the pursuit of new
    methods and systems no less perilous than the search after unknown
    lands and seas.

  18. #18
    Join Date
    Jun 2006
    Posts
    3,864
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    R0b0t, you fail at delphi
    SCAR Code:
    const MyArray = ['Hello', 'Goodbye'];

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

    Default

    great tut, but it gave me a headache. not the content, just the font/color lol.
    make font a bit smaller and black please

    rep++
    NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN NYAN

  20. #20
    Join Date
    Jan 2009
    Location
    Belgium
    Posts
    124
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Very nice tutorial, i learned how to use the arrays abit better now, thank you

    rep+

  21. #21
    Join Date
    Oct 2010
    Location
    Under a bridge
    Posts
    649
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice tut did not know you could be For To Do on arrays i just used them to do it like a repeat 10 times, so its great thanks
    Quote Originally Posted by DD on IRC
    wanted to troll the troll

  22. #22
    Join Date
    Mar 2007
    Posts
    4,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

  23. #23
    Join Date
    Mar 2006
    Location
    Louisiana, USA
    Posts
    3,071
    Mentioned
    31 Post(s)
    Quoted
    15 Post(s)

    Default

    Quote Originally Posted by Naum View Post
    I made this about 3 years ago.. lol
    If it still applies it always good to have around I mean look at your Sig. Most of those are still good and I recommend people to them all the Time.

    ~BraK

    "Sometimes User's don't need the Answer spelled out with Code. Sometimes all they need is guidance and explanation of the logic to get where they are going."

  24. #24
    Join Date
    Dec 2006
    Location
    Georgia
    Posts
    84
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thank you!!!!!
    Future SRL Member.

  25. #25
    Join Date
    Oct 2011
    Location
    UK
    Posts
    1,329
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    there are 5 different arrays which are in the Integer
    Shouldn't that be:
    there are 5 different integers which are in the array

    Good tut tho

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. TPAs For Dummies
    By Dusk412 in forum Advanced Tutorials
    Replies: 42
    Last Post: 03-09-2013, 04:55 PM
  2. static errors?
    By lardmaster in forum Java Help and Tutorials
    Replies: 10
    Last Post: 01-12-2007, 10:27 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
  •