Results 1 to 3 of 3

Thread: RS script minor problem

  1. #1
    Join Date
    Jul 2009
    Posts
    47
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default RS script minor problem

    Heya,

    In my first autofighter, the attacking loop i built is as follows:

    SCAR Code:
    repeat
      if not InFight then begin

        FindNormalRandoms;

        if(FightNPC(FoeColors, 5, 1000)) then begin
          if InFight then begin
            writeln('Foe attacked!');
            wait(200+random(800));
          end
        end
      end;
      wait(300 +random(700));
    until false;

    // FoeColors is an array.
    // First "IF" makes sure the attacking only occurs if not in fight.
    // Second "IF" attacks the foe.
    // Third "IF" checks whether the attacking has been successful. If not, the first
    // IF will be "True" and in 2 seconds max, the script will try again.

    (I put some comments under it for readability). Ok, the loop was a bit more than this, but I removed irrelevant pieces of code.

    I thougt: "This is rather ugly in the main loop, I want to have a function/procedure doing this...". So i wrote:

    SCAR Code:
    function FightFoe(FoeColors: array[1..6] of Integer; Foe : Integer) : Boolean;

    begin
      if(FightNPC(FoeColors, 5, 1000)) then begin
        if InFight then begin
          writeln('Foe attacked!');
          wait(200+random(800));
          Result:=InFight;
        end
        else Result:=Infight;
      end
      else Result:=False;
    end;

    This function doesn't seem to work, SCAR even doesnt recognize it in the function list to the right (where it does recognize other functions). What is wrong with my code?

    PS The Integer FOE is used to count attacked Foe's. it is used in the whole code; irrelevant.

    Thank you!

  2. #2
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    function FightFoe(FoeColors: TIntegerArray; Foe : Integer) : Boolean;

    begin
      if(FightNPC(FoeColors, 5, 1000)) then begin
        if InFight then begin
          writeln('Foe attacked!');
          wait(200+random(800));
          Result:=InFight;
        end
        else Result:=Infight;
      end
      else Result:=False;
    end;

  3. #3
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Check your thread in the "First Script" section.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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