Results 1 to 12 of 12

Thread: Need Help With an Unusual Array

  1. #1
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Need Help With an Unusual Array

    Hi, i was wondering how i would declare an array of colors. The number of parts or watever in the array needs to be NumberOfColors. i know how this would be done with C++ because i...love C++! lol, so if you know c++ this will help you help me...

    Code:
    int Color[NumberOfColors --];
    yeah, simple in C++, yet so complicated in Scar (to me)

  2. #2
    Join Date
    Jan 2007
    Location
    Illinois.. >.<
    Posts
    1,158
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well, since Colors are integers you do:
    SCAR Code:
    Color: Array[0..5] Of Integer;

    the 5 can be any other number..

    and then to declare the colors do something like this:

    SCAR Code:
    Color[0] := 605272;
    Color[1] := 604242;
    Color[2] := 605015;
    Color[3] := 602440;
    Color[4] := 603213;

  3. #3
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    but NumberOfColors can be anything so... it cant just be five...

  4. #4
    Join Date
    Jan 2007
    Location
    Illinois.. >.<
    Posts
    1,158
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    That's why i said 5 can be any other number..

  5. #5
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    yes, but NumberOfCOlors is input by the user, its being used in a function

  6. #6
    Join Date
    Sep 2006
    Location
    New Jersey, USA
    Posts
    5,347
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    SCAR Code:
    Color: Array of Integer;

    ...

    SetLength(Color, NumberOfColors);
    Interested in C# and Electrical Engineering? This might interest you.

  7. #7
    Join Date
    Jun 2007
    Posts
    5
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thnx

  8. #8
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thanx smartz, but what does the 'color' do in setLength(color,NumberOfColors)

    i basicly whant an array of colors based on number of colors, i guess sort of like the players array

  9. #9
    Join Date
    Jan 2007
    Location
    Illinois.. >.<
    Posts
    1,158
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    color is the name of the variable.

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

    Default

    procedure SetArrayLength(var Arr; Count: LongInt);
    Sets the length of the specified array.
    SetArrayLength(Noobs, 5);
    Will set the array spicified in "noob" to 5 ([0]-[4])
    [QUOTE=Santa_Clause;277761]I love you too TSN :p[/QUOTE]
    [CENTER][URL="http://www.stats.srl-forums.com/sigs"][IMG]http://www.stats.srl-forums.com/sigs/1324.png[/IMG][/URL][/CENTER]

  11. #11
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ok thanks

  12. #12
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    this is my function

    SCAR Code:
    Function FindColorPriority(x:longint; y: longint; NumberOfColors: Integer; Tolerance: Integer; xs, ys, xe, ye: LongInt): Integer;
    {.include SRL/SRL.scar}
     
      var
        Color: array of LongInteger;
        x, y: Integer;
        Counter: Integer;
      const
        Color[0]:=00000; {I want to add this into the Function thing, but i dont know how many there are going to be????????}
        Color[1]:=00000;
        Color[2]:=00000;
      begin
        Counter:=0
        SetArrayLength(Color, NumberOfColors)
        repeat
          begin
            if(FindColorTolerance(x, y, Color[Counter], xs, ys, xe, ye, Tolerance) then
              Result:= Counter + 1;
              Exit;
            end else
              Counter:=Counter +1;
          end;
        until(Counter=NumberOfColors);
        begin
          if(Counter=NumberOfColors) then
           Result:=0
        end;
      end;

    it gives me an error with the srl globals thing

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Array in an array...
    By Lorax in forum OSR Advanced Scripting Tutorials
    Replies: 20
    Last Post: 01-16-2010, 09:10 PM
  2. Unknown\unusual things in SCAR!
    By mastaraymond in forum OSR Advanced Scripting Tutorials
    Replies: 16
    Last Post: 11-01-2008, 09:18 PM
  3. ItemColors: Array of Array of Integer
    By n3ss3s in forum Research & Development Lounge
    Replies: 5
    Last Post: 10-30-2007, 06:04 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. How do i Add Another Var to SRL Array
    By pwnaz0r in forum OSR Help
    Replies: 2
    Last Post: 02-11-2007, 08:29 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
  •