Results 1 to 7 of 7

Thread: anyway to give a const multiple colors

  1. #1
    Join Date
    Oct 2006
    Posts
    87
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default anyway to give a const multiple colors

    kk, say i wanted to make a SandColor constant

    is there anyway to make it hold multiple colors, so if i call it in the script, if it doesnt find the first it will look for the 2nd, and if it doesnt find the 2nd it will look for the 3rd, until it goes through all the colors, and if none are found it exits

    like

    const
    SandColor= 123123, 321321, 213213;

    thats prob not right at all but like is there anyway to do that. without having to have lots of code, since i have to call it like 20 times in my script


    would i just make SandColor, a variable?

  2. #2
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Unfortunately, constants can't be arrays.

    You could make a variable (a TIntegerArray) and set the values of that to sand colors.

  3. #3
    Join Date
    Oct 2006
    Posts
    87
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    how would i do that?

    SCAR Code:
    program test;
    {.include SRL/SRL.scar}
    var
    SandColor: Integer; // so this is wrong, and i got no colors set to sandcolor

    procedure walk;

    begin
    RadialWalk(SandColor, 230, 140, 65, -1, 0); //idk about this
    end;

    begin
    setupSRL;
    walk;
    end.

    so how would i do it? would u be able to turn this into what ur saying so i can see what ur saying more clearly

  4. #4
    Join Date
    Dec 2006
    Location
    Program TEXAS home of AUTOERS
    Posts
    7,934
    Mentioned
    26 Post(s)
    Quoted
    237 Post(s)

    Default

    just do this since your a beginner

    SCAR Code:
    const
    example1   =0000;
    example2   =0121;
    example3   =2325;


    SCAR Code:
    if findobj(x, y,'ree', example1, 10)or
           findObj(x, y, 'ree', example2,10)or
             findObj(x, y, 'ree', example3,10)then

    hope that works for you

    GOODLUCK

  5. #5
    Join Date
    Mar 2007
    Posts
    103
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    you could just make multiple constants. something like this.

    SCAR Code:
    program test;
    {.include SRL/SRL.scar}
    constant
    SandColor1= 1235;
    SandColor2= 9561;
    SandColor3= 1395;
     
    procedure walk;
    begin
      if not
      RadialWalk(SandColor1, 230, 140, 65, -1, 0) or
      RadialWalk(SandColor2, 230, 140, 65, -1, 0) or
      RadialWalk(SandColor3, 230, 140, 65, -1, 0) then
        writeinln('sand colors dont work') and logout;
    end;
     
    begin
    setupSRL;
    walk;
    end.

    i know that does not work into itself, but thats the idea. Because Radial walk returns a true of false, you can make it try each different sand color in the form of a consistent before failing and logging out.
    These are my principles. If you don't like them, well... I have others.

    Since brevity is the soul of wit, I will be brief. Auto Correctly.

  6. #6
    Join Date
    Feb 2007
    Location
    EST (US East Coast)
    Posts
    250
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    As an array it would look like this:

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}

    var
      SandColors : Array[0..2] of Integer;

    procedure DeclareColors;
    begin
      SandColors[0] := 12345;
      SandColors[1] := 12345;
      SandColors[2] := 12345;
    end;

    procedure Whatever;
    var
      i : Integer;
    begin
      for i := 0 to High(SandColors) do //high = highest in the array(in this case 2)
      begin
        if RadialWalk(SandColors[i], 230, 140, 65, -1, 0) then Break; //if it works then break the loop
        wait(100);
      end;
    end;

    begin
      SetupSRL;
      DeclareColors;
      Whatever;
    end.
    Temporarily inactive.

  7. #7
    Join Date
    Jun 2006
    Posts
    3,861
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    Taking Ducels's example, you could also do it like this
    SCAR Code:
    program New;
    {.include SRL/SRL.scar}
     
    var
      SandColors : TIntegerArray;
     
    procedure DeclareColors;
    begin
      SandColors:= [12345, 54321, 2431, 241234, 24123];
    end;
     
    procedure Whatever;
    var
      i : Integer;
    begin
      for i := 0 to High(SandColors) do //high = highest in the array(in this case 4)
      begin
        if RadialWalk(SandColors[i], 230, 140, 65, -1, 0) then Break; //if it works then break the loop
        wait(100);
      end;
    end;
     
    begin
      SetupSRL;
      DeclareColors;
      Whatever;
    end.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Finding Multiple Tree Colors
    By tigerskall in forum OSR Help
    Replies: 11
    Last Post: 11-18-2007, 07:04 AM
  2. Replies: 2
    Last Post: 09-04-2007, 09:49 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
  •