Results 1 to 7 of 7

Thread: Stupid out of range error... -.-

  1. #1
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Stupid out of range error... -.-

    Well, here is yet another thread in the help section from me (seriously, I think you could write a script on this...
    SCAR Code:
    if ThreadsInHelpSection(Pure, 3) >= 4 then //the 3 symbolises the days
      Pure1993 := writingscript
    ...)

    well anyway, back on topic: here is my error:

    [Runtime Error] : Out Of Range in line 435 in script C:\Program Files\SCAR 3.15\Scripts\Tutorial Island Runner\Remake.scar

    And here is my function:
    SCAR Code:
    procedure ColorHair( Colors: TIntegerArray);
    var
      DS: TPointArray;
      G, L, D, W :Integer;
    begin
      l:= GetArrayLength(Colors);
      for i:=0 to l-1 do
      begin
        W := Colors[i];
        repeat
          W := W mod 6;
          if W = 0 then W := 1;
        until W <= 5;
        DS[i].x := (W  * 60) + 326; //This is the lines
      end;
      for i:=0 to l-1 do
      begin
        D := Colors[i];
        DS[i].y := ((D mod 5) * 27) + 148; //I guess it will occure here, too
      end;
      G := Random(l-1);
      Mouse(DS[G].x, DS[G].y, 3, 3, true);
      G := Random( GetArrayLength(colors)-1);
    end;


    As you can probably guess, the release will have to be postponed again, because the quality of my first good release is more important than keeping any self set deadlines.

    Thanks a lot,
    -Pure1993
    There is nothing right in my left brain and there is nothing left in my right brain.

  2. #2
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ahh never mind, figured the problem out. The first repeat loops was suppossed to be enclosed in an if statement, and also some major math parts weren't thought trough all the way. (These functions always get a bit to complicated when using 2 arrays, lots of math functions, all while using a TIntegerArray with which I have never worked with before). So yeah, problem solved.

    ~~Pseudo closed~~

    -Pure1993
    There is nothing right in my left brain and there is nothing left in my right brain.

  3. #3
    Join Date
    Jul 2007
    Location
    Ottawa, Canada
    Posts
    930
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You need to set the length of DS
    ~ Metagen

  4. #4
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yeah, I figured that after looking into Object.scar (it's quite usefull to be able to see how the functions are created ). Now it looks like this and works like a charm:
    SCAR Code:
    ////////////////////////////////////////////////////////////////////////////////
    // procedure ColorHair( Colors: TIntegerArray);                               //
    // By: Pure1993                                                               //
    // Description: It randomly chooses one of your selected colors as hair color.//
    //              The Array is set up like this:                                //
    //                                                  1,  2,  3,  4,  5,        //
    //                                                  6,  7,  8,  9, 10,        //
    //                                                 11, 12, 13, 14, 15,        //
    //                                                 etc.                       //
    ////////////////////////////////////////////////////////////////////////////////

    procedure ColorHair( Colors: TIntegerArray);
    var
      DS: TPointArray;
      C, L, G, W, D :Integer;
    begin
      l := Length(Colors)-1;
      SetArrayLength( DS, l+1);
      for i:=0 to l do
      begin
        C := Colors[i];
        W := C mod 5;
        W := W - 1;
        if (W = -1) then W := 4;
        DS[i].x := (W  * 30) + 325;
      end;
      for i:=0 to l do
      begin
        C := Colors[i];
        W := C / 5;
        if (C mod 5 = 0) then
          W := W - 1;
        DS[i].y := ((W * 28) + 145 - (D * 2));
      end;
      G := Random(l);
      Mouse(DS[G].x, DS[G].y, 3, 3, true);
    end;
    I still can't believe I created a function like that, and that it actually works!

    Up to this day I fought against the TPA's to try to force them to do what I wanted, but from this moment hence forth, we work as one! (oooooh, fancy words and personification, I think something is really wrong with me... xD)
    There is nothing right in my left brain and there is nothing left in my right brain.

  5. #5
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    why 1-1 and 1+1? or is it an I
    ~Hermen

  6. #6
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    it is a 1, the thing is i decided it wouldn't look as bad there as if i did an "l - 1" in the for.. to... do... statement. So this is just personal prefference nothing to do with usefullness or any official rule. ^^
    There is nothing right in my left brain and there is nothing left in my right brain.

  7. #7
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Newb get on msn
    ~Hermen

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. STUPID error...
    By Drakan in forum OSR Help
    Replies: 11
    Last Post: 05-20-2008, 07:32 PM
  2. Stupid error
    By yanix in forum OSR Help
    Replies: 6
    Last Post: 09-08-2007, 09:19 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
  •