Results 1 to 5 of 5

Thread: Function problem

  1. #1
    Join Date
    Jan 2007
    Location
    Toronto.
    Posts
    150
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Function problem

    Well iv'e been working on a gas finder but i get this error when i try to compile my function:

    SCAR Code:
    Line 44: [Error] (18671:1): 'BEGIN' expected in script C:\SCAR\Scripts\Projects\AntiGas.scar

    And here's the function and all the things it uses:

    SCAR Code:
    {.include SRL/SRL.scar}
    {.include SRL/SRL/SkILL/Mining.scar}

    var
      DTMPick, i, tx, ty: Integer;
      GC: array [0..2] of Integer;

    procedure LoadDTMs;
      begin
        DTMPick := DTMFromString('78DA8DCE610A80200C86E18D32AC244A2A088' +
                 '3AEE141BAFF59DAA23F26F8E98F578487395E88C8507262BCDF9B' +
                 'BF370F929E7E8753D356189BFF95192F6980D9251698A3629F53E' +
                 '280099209985532023397E7E8AAACBB6CC06802309DE402C654CC' +
                 'D1F88A9D5DD93C48E10319');
      end;

    {<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>}
    {< AxeBroke;                                                                  >}
    {< Checks if pickaxe is broken.                                               >}
    {<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>}

    function AxeBroke: Boolean;

      begin
        if(not(LoggedIn))then Exit;
          case Players[CurrentPlayer].Boolean1 of
            False: GameTab(3);
            True : GameTab(4);
          end;
            begin
              if(FindDTM(DTMPick, tx, ty, 564, 212, 726, 454))then
                begin
                  MMouse(tx, ty, 1, 1);
                    if(IsUpText('Broken Pick Axe Text'))then   // Dunno what broken axe text is :S
                      begin
                        Result := True;
                      end else
                        begin
                          Result := False;
                        end;
                  end;
            end;
       end;

    {<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>}
    {< Gas;                                                                       >}
    {< Finds and handles gas.                                                     >}
    {<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>}

    function Gas: Boolean;

      begin
        GC[0] := 23454;
        GC[1] := 23454;
        GC[2] := 23454;
      end;

      begin
        if(not(LoggedIn))then Exit;
          for i := 0 to 2 do
            if(FindColorSpiralTolerance(tx, ty, GC[i], 3, 3, 515, 336, 10))then
              begin
                WriteLn('Gas found!!');
                  repeat
                    Wait(4000+Random(2000));
                    Mouse(450, 12, 0, 0, True);
                  until(AxeBroke)or(not(FindColorSpiralTolerance(tx, ty, GC[i], 3, 3, 515, 336, 10)))
              if(not(FindColorSpiralTolerance(tx, ty, GC[i], 3, 3, 515, 336, 10)))then
                begin
                  Result := False; // No gas found..
                end;
             if(AxeBroke)then
               begin
                 WriteLn('Axe has been broken!!');
                 Result := False;
               end else
                 begin
                   WriteLn('Gas found and handled. ;)');
                   Result := True;
                end;
           end;
      end;
               
    begin
      LoadDTMs;
    end.

    The error occurs in Gas; but i thought that a function automaticly generates the Result variable? I hope it's just some silly mistake.

  2. #2
    Join Date
    Feb 2006
    Location
    Belgium
    Posts
    3,137
    Mentioned
    3 Post(s)
    Quoted
    5 Post(s)

    Default

    Try like this:
    SCAR Code:
    {.include SRL/SRL.scar}
    {.include SRL/SRL/SkILL/Mining.scar}

    var
      DTMPick, i, tx, ty: Integer;
      GC: array[0..2] of Integer;

    procedure LoadDTMs;
    begin
      DTMPick := DTMFromString('78DA8DCE610A80200C86E18D32AC244A2A088' +
        '3AEE141BAFF59DAA23F26F8E98F578487395E88C8507262BCDF9B' +
        'BF370F929E7E8753D356189BFF95192F6980D9251698A3629F53E' +
        '280099209985532023397E7E8AAACBB6CC06802309DE402C654CC' +
        'D1F88A9D5DD93C48E10319');
    end;

    {<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>}
    {< AxeBroke;                                                                  >}
    {< Checks if pickaxe is broken.                                               >}
    {<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>}

    function AxeBroke: Boolean;
    begin
      if (not (LoggedIn)) then Exit;
      case Players[CurrentPlayer].Boolean1 of
        False: GameTab(3);
        True: GameTab(4);
      end;
      if (FindDTM(DTMPick, tx, ty, 564, 212, 726, 454)) then
      begin
        MMouse(tx, ty, 1, 1);
        Result := IsUpText('Broken Pick Axe Text');
      end;
    end;

    {<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>}
    {< Gas;                                                                       >}
    {< Finds and handles gas.                                                     >}
    {<~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~>}

    function Gas: Boolean;
    begin
      GC[0] := 23454;
      GC[1] := 23454;
      GC[2] := 23454;
      if (not (LoggedIn)) then Exit;
      for i := 0 to 2 do
        if (FindColorSpiralTolerance(tx, ty, GC[i], 3, 3, 515, 336, 10)) then
        begin
          WriteLn('Gas found!!');
          repeat
            Wait(4000 + Random(2000));
            Mouse(450, 12, 0, 0, True);
          until (AxeBroke) or (not (FindColorSpiralTolerance(tx, ty, GC[i], 3, 3, 515, 336, 10)))
            if (not (FindColorSpiralTolerance(tx, ty, GC[i], 3, 3, 515, 336, 10))) then
            Result := False; // No gas found..
          if (AxeBroke) then
          begin
            WriteLn('Axe has been broken!!');
            Result := False;
          end else
          begin
            WriteLn('Gas found and handled.');
            Result := True;
          end;
        end;
    end;

    begin
      LoadDTMs;
    end.

  3. #3
    Join Date
    Sep 2006
    Posts
    916
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok, wouldn't you want to click THEN wait? You have this:

    PHP Code:
    function GasBoolean;
    begin
      GC
    [0] := 23454;
      
    GC[1] := 23454;
      
    GC[2] := 23454;
      if (
    not (LoggedIn)) then Exit;
      for 
    := 0 to 2 do
        if (
    FindColorSpiralTolerance(txtyGC[i], 3351533610)) then
        begin
          WriteLn
    ('Gas found!!');
          
    repeat
            Wait
    (4000 Random(2000));
            
    Mouse(4501200True);
          
    until (AxeBroke) or (not (FindColorSpiralTolerance(txtyGC[i], 3351533610)))
            if (
    not (FindColorSpiralTolerance(txtyGC[i], 3351533610))) then
            Result 
    := False// No gas found..
          
    if (AxeBrokethen
          begin
            WriteLn
    ('Axe has been broken!!');
            
    Result := False;
          
    end else
          
    begin
            WriteLn
    ('Gas found and handled.');
            
    Result := True;
          
    end;
        
    end;
    end
    Don't you want this:

    PHP Code:
    function GasBoolean;
    begin
      GC
    [0] := 23454;
      
    GC[1] := 23454;
      
    GC[2] := 23454;
      if (
    not (LoggedIn)) then Exit;
      for 
    := 0 to 2 do
        if (
    FindColorSpiralTolerance(txtyGC[i], 3351533610)) then
        begin
          WriteLn
    ('Gas found!!');
          
    repeat
            Mouse
    (4501200True);
            
    Wait(4000 Random(2000));
          
    until (AxeBroke) or (not (FindColorSpiralTolerance(txtyGC[i], 3351533610)))
            if (
    not (FindColorSpiralTolerance(txtyGC[i], 3351533610))) then
            Result 
    := False// No gas found..
          
    if (AxeBrokethen
          begin
            WriteLn
    ('Axe has been broken!!');
            
    Result := False;
          
    end else
          
    begin
            WriteLn
    ('Gas found and handled.');
            
    Result := True;
          
    end;
        
    end;
    end

  4. #4
    Join Date
    Feb 2006
    Location
    Belgium
    Posts
    3,137
    Mentioned
    3 Post(s)
    Quoted
    5 Post(s)

    Default

    For the record, (so i don't look bad), I only made it compile, lol

  5. #5
    Join Date
    Jan 2007
    Location
    Toronto.
    Posts
    150
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks i think i know what caused the error:

    SCAR Code:
    function Gas: Boolean;
      begin
        GC[0] := 23454;
        GC[1] := 23454;
        GC[2] := 23454;
       // Had the end; here when it shouldn't have been

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 06-11-2008, 07:28 AM
  2. function problem
    By Richard in forum OSR Help
    Replies: 7
    Last Post: 02-01-2008, 05:53 PM
  3. problem with dropexcept function
    By orion pax in forum OSR Help
    Replies: 1
    Last Post: 10-15-2007, 11:46 PM
  4. Inchat Function Problem
    By Granti in forum OSR Help
    Replies: 21
    Last Post: 06-29-2007, 04:01 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
  •