Results 1 to 13 of 13

Thread: Need function to do something, but i don't know if Possible

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

    Default Need function to do something, but i don't know if Possible

    Here is my function

    SCAR Code:
    Function FindColorPriority(x:longint; y: longint; NumberOfColors: Integer; Tolerance: Integer; xs, ys, xe, ye: LongInt): Integer;

      var
        Color: array of LongInt;

        Counter: Integer;
      const
        Color[0]:=00000; //Set these, and add more "colors" if need 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;

    Right now i have the colors set as constants, which i cant do. I want that array of colors to be put in the function thing, but the amount of colors i am using is going to vary. Is there any way, i can have the script alter the format of the function based off of NumberOfColors?

    Thanks on Advance

  2. #2
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Put this at the beginning of your mainloop:

    SCAR Code:
    SetArrayLength(Color, NumberOfColors);

    And then in that function, replace

    SCAR Code:
    SetArrayLength(Color, NumberOfColors);

    With:

    SCAR Code:
    SetArrayLength(Color, Color + 1);

    I think that's what you meant? It adds 1 to the array each time.
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

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

    Default

    no, not really, i want to chance the format of the function,

    SCAR Code:
    Function FindColorPriority(x:longint; y: longint; NumberOfColors: Integer; Color[0], Color[1], Color[2]: longint; Tolerance: Integer; xs, ys, xe, ye: LongInt): Integer;

    see how the color things are in there

    that is how it would be if NumberOfColors was 3, but if the user enters 5 in numberofcolors, the format of the function would change to

    SCAR Code:
    Function FindColorPriority(x:longint; y: longint; NumberOfColors: Integer; Color[0], Color[1], Color[2], Color[3], Color[4]: longint; Tolerance: Integer; xs, ys, xe, ye: LongInt): Integer;

    is that clearer?

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

    Default

    PHP Code:
    Function FindColorPriority(var xyIntegerColorsTIntegerArrayToleranceIntegerxsysxeyeLongInt): Integer;

    FundColorPriority(xy, [000011112222333344445555], 5MMX1MMY1MMX2MMY2); 
    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!


  5. #5
    Join Date
    Nov 2006
    Location
    NSW, Australia
    Posts
    3,487
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    He wants to change it during runtime Starblaster...
    [CENTER][img]http://signatures.mylivesignature.com/54486/113/4539C8FAAF3EAB109A3CC1811EF0941B.png[/img][/CENTER]
    [CENTER][BANANA]TSN ~ Vacation! ~ says :I Love Santy[/BANANA][/CENTER]

    [CENTER][BANANA]Raymond - Oh rilie? says :Your smart[/BANANA][/CENTER]

  6. #6
    Join Date
    Jun 2007
    Location
    I'm not sure...
    Posts
    581
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Damn you starblaster!!!! Beating me to the TArrays!!!!
    I just learned 'em and I wanted to share my knowledge

    @Santa
    I don't see why he couldn't. Star's works fine, just gotta mess w/the code a 'lil to make the TIntegerArray fit.
    ---------------------------------------------------------


    Pm me if you need any math functions made. Me = l0ving t3h mathz

    ---------------------------------------------------------

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

    Default

    no, Starblaster's solution might work, just a little explaination please, cuz im in it to learn

    rotflm, its your time to shine, teach me oh great one

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

    Default

    No, I think thats what he is looking for. A flexible parameter

    EDIT: TIntegerArray (Also known as Array of Integer) is an open ended array, meaning you can set as many colors in there as you want.

    I'll take that little section of th script:

    [0000, 1111, 2222, 3333, 4444, 5555]

    This means:

    PHP Code:
    Colors[0] := 0000;
    Colors[1] := 1111;
    Colors[2] := 2222;
    Colors[3] := 3333;
    Colors[4] := 4444;
    Colors[0] := 5555
    [12345, 7878554]

    means

    PHP Code:
    Colors[0] := 12345;
    Colors[1] := 7878554
    Nothing more to it really, tell me if you need more of an explination
    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!


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

    Default

    lol, thanks, you beat rotflmf to it... again

    so pretty much tarrayinteger, is an array of ints that can be any length, cool!

    sorry if this is anoying, but, do you know were i could find the code for tarrayinteger, I must learn lol. if you think it is too complicated for me, you would be suprised, i understand alot about programing because of my experience with c++

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

    Default

    There isn't any code for TArrayInteger. TArrayInteger is a type, like Integer, String, Boolean etc.

    What i have shown you above is all there is to it
    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!


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

    Default

    oh, i know its a type, i thought it as some srl, user created type or something

  12. #12
    Join Date
    Jun 2007
    Location
    I'm not sure...
    Posts
    581
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    AGAIN! THWARTED AGAIN! *plans to kill SB*

    Oh well, if you (Macrosoft) have trouble, pm me.
    ---------------------------------------------------------


    Pm me if you need any math functions made. Me = l0ving t3h mathz

    ---------------------------------------------------------

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

    Default

    im good, thanks SB for your help and Rotflm for trying to help lol

    ill pm you, rotflm if i have any trouble.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 02-27-2008, 05:20 PM
  2. Replies: 2
    Last Post: 02-26-2008, 08:26 PM
  3. Any function that does this?
    By shadowpwner in forum OSR Help
    Replies: 2
    Last Post: 08-14-2007, 03:15 AM
  4. [FUNCTION] FindDoorColour: integer; By ZephyrsFury [FUNCTION]
    By ZephyrsFury in forum Research & Development Lounge
    Replies: 10
    Last Post: 07-27-2007, 08:45 AM

Posting Permissions

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