Results 1 to 4 of 4

Thread: Invalid Number Of Parameters

  1. #1
    Join Date
    Dec 2007
    Posts
    44
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Invalid Number Of Parameters

    Hey guys i'm trying to incorporate Wizzup?'s FindFishingSpot/s; in my script and am testing out bits and pieces of it. What I don't understand is why I'm getting an invalid number of parameters error when I put the variables up top, like everyone else does.

    SCAR Code:
    Function FindFishingSpot(Var x, y: Integer): Boolean;

    But when I move it down, it works...

    SCAR Code:
    Function FindFishingSpot: Boolean;
    var x, y: Integer;

    Storing the variables IN the function is causing some things later in the script not to work. Any Ideas? I've included the piece of code I'm testing out below. Thanks, -decide

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


    Function FindFishingSpots: TPointArray;

    Var
       Fish: TPointArray;
       Fishes: T2DPointArray;
       I, cts: Integer;

    Begin
      If Not LoggedIn Then Exit;
      SetLength(Result, 0);
      cts := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      FindColorsSpiralTolerance(MSCX, MSCY, Fish, 15257001, MSX1, MSY1, MSX2, MSY2, 40);
      Fishes := TPAToATPA(Fish, 25);
      SetLength(Fish, 0);
      SetLength(Result, Length(Fishes));
      For I := 0 To High(Fishes) Do
      Begin
        If Length(Fishes[I]) < 5 Then
          Continue;
        Result[I] := MiddleTPA(Fishes[I]);
      End;
      SetLength(Fishes, 0);
      ColorToleranceSpeed(cts);
    End;

    ///////////////////////////////////////////////////////

    Function FindFishingSpot(Var x, y: Integer): Boolean;

    Var
       Fish: TPointArray;
       I: Integer;

    Begin
      If Not LoggedIn Then Exit;
      Result := False;
      Fish := FindFishingSpots;
      For I := 0 To Length(Fish) - 1 Do
      Begin
        MMouse(Fish[I].X, Fish[I].Y, 0, 0);
        Wait(150 + Random(50));
        If IsUpText('Lure') Then
        Begin
          Result := True;
          x := Fish[I].X;
          y := Fish[I].Y;
          Exit;
        End;
      End;
    End;

    begin
      FindFishingSpots;
      FindFishingSpot;
    end.

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

    Default

    If you put "var x, y: Integer" in the procedure declaration, you have to pass them as parameters when you call that procedure. So if you wanted to use it, you'd have to make an x and y variable, and call the function like this:
    FindFishingSpot(x, y);

  3. #3
    Join Date
    Dec 2007
    Posts
    44
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    thank you.

  4. #4
    Join Date
    Jul 2008
    Location
    California
    Posts
    255
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Also, when using it like:

    FindFishingSpot(var x, y : integer): boolean;

    You have more options with the x, y values.

    When creating the function, you can either have the function set variables located in the parameters to a specific value, OR you can have the function read the parameters as specific values for the function.
    IE:

    SCAR Code:
    //In this example, I'm having the function read the two variables.

    function FindFishingSpot(var x, y : integer) : boolean;
    begin
      if GetColor(x, y) = FishingSpotColor then begin
        Result := true;
        Exit;
        end
        else begin
          WriteLn('Fishing spot not found at specified coordinates.');
          end;
    end;
    //////////////////////////////////////////////////////////////////////////
    var
    FSx, FSy : integer;
    begin
    SetupSRL;
    FSx := 213;
    FSy := 417;
    if FindFishingSpot(FSx, FSy) then begin
      WriteLn('Fishing Spot Found');
      Mouse(FSx, FSy, 5, 5, True);
      wait(100 + random(250));
      end;
    end.

    SCAR Code:
    //In this example I will have the function set the variable parameters.
    function FindFishingSpot(var x, y : integer) : boolean;
    begin
      if FindColorTolerance(x, y, FSColor, SCRx1, SCRy1, SCRx2, SCRy2, 5) then Begin
        WriteLn('Fishing Spot Found.');
        Result := true;
        end
        else Result := false;
    end;

    //////////////////////////////////////////////////////////////////////////
    var
    FSx, FSy : integer;
    Begin
    SetupSRL;
    If FindFishingSpot(FSx, FSy) then begin
      Mouse(FSx, FSy, 3, 3, true);
      WriteLn('Fishing Spot Clicked.');
      end;
    end.

    Definitely not the best example, but this should give you an idea of how these parameters work.
    Unfortunately, no active scripts atm.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. invalid number of parameters
    By Griff in forum OSR Help
    Replies: 4
    Last Post: 09-27-2008, 04:16 AM
  2. Invalid number of parameters
    By kristahlyn in forum OSR Help
    Replies: 2
    Last Post: 06-16-2007, 02:39 PM
  3. Invalid Number of Parameters
    By richyyrich09 in forum OSR Help
    Replies: 6
    Last Post: 06-12-2007, 10:48 PM
  4. invalid number of parameters
    By stuckman in forum OSR Help
    Replies: 4
    Last Post: 05-27-2007, 01:32 PM
  5. Invalid Number Of Parameters
    By Any-key in forum OSR Help
    Replies: 12
    Last Post: 04-21-2007, 12:11 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
  •