Results 1 to 11 of 11

Thread: Duplicate identifier error - not sure why

  1. #1
    Join Date
    Apr 2013
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default Duplicate identifier error - not sure why

    Hey everyone, thanks for all the help you've already given me. Hopefully, this will be the last thread I make here concerning this script.

    Firstly, I've sort of got a basic script set up for my CutAndBurner, right here.

    Code:
    program CutAndLight;
    
    {$DEFINE SMART}
    {$i srl/srl.simba}
    
    Var
    PBox: TBox;
    
    Procedure Setup;
    begin
      SetAngle (SRL_ANGLE_HIGH);
      MakeCompass ('N');
    end;
    
    Procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
    
      Players[0].Name :='';
      Players[0].Pass :='';
      Players[0].Nick :='';
      Players[0].Active:=True;
    end;
    
    Function InvEmpty: Boolean;
        begin
          Result:= FindColor (dx, dy, 2770782, 20, MIX1, MIY1, MIX2, MIY2);
        end;
    
    Function DetectCutting: Boolean; //Detects if you're cutting trees.
      begin
        PBox:= IntToBox(245, 130, 285, 195);
        Result:= (AveragePixelShift (PBox, 250, 300) > 190);
      end;
    
    Function FireOnFloor: Boolean; //Checks if theres a fire under you.
      var (FBox: TBox; fx, fy: integer);
        begin
         FBox:= IntToBox (250, 173, 272, 187);
         Result:= FindObj (fx, fy, 2258409, 87, FBox);
        end;
    
    Function DetectBurning: Boolean; //Detects if you're burning logs.
      begin
        PBox:= IntToBox(245, 130, 285, 195);
        Result:= (AveragePixelShift (PBox, 250, 300) > BurningPShift);
      end;
    
    Procedure CutAndBurnLogs;
    var x, y: integer;
    begin
    Setup;
    repeat
      begin
        repeat
          if FindObj (x, y, ree, 1795912, 35, MSX1, MSY1, MSX2, MSY2) then
            Mouse (x, y, 2, 2, true);
          if DetectCutting then
           Wait (300 + random(100));
        until (InvFull);
      end;
    
      begin
        repeat
          if not DetectBurning and if not FireOnFloor then
            begin
              TypeByte (49);
              if FindObj (x, y, 6316644, 1, MSX1, MSY1, MSX2, MSY2) then
              Mouse (x, y, 2, 2, true);
            end;
          else
          if DetectBurning and if not FireOnFloor then
            Wait (200 + random (100));
          else
          if not DetectBurning and if FireOnFloor then
            begin
            If (FindColor (x, y, 2379333, 10, MMX1, MMY1, MMX2, MMY2)) then
            Mouse (x, y, 0, 0, true;)
            end;
        until not (InvEmpty);
      end;
    until (false);
    end;
    
    begin
      SetupSRL;
      DeclarePlayers;
      ActivateClient;
        Repeat
        if not LoggedIn then LoginPlayer;
        CutAndBurnLogs;
        until (false);
    end.
    Unfortunately, I'm getting the following error.

    Code:
    [Error] C:\Users\Matt\Desktop\Cut and Light.simba(28:10): Duplicate identifier 'INVEMPTY' at line 27
    Compiling failed.
    Anyone can enlighten me? Also, if you have anything to say about the actual script, that would be helpful too - keep in mind i'm still very new to this. I am aware that one of my PixelShift commands isn't set up properly - I haven't found that yet.

    Yes, I know there's not antiban, failsafes, 6 hour fix, random solver, but I'm going to add those later.
    Last edited by maky369; 04-09-2013 at 09:51 AM.

  2. #2
    Join Date
    Jan 2013
    Posts
    294
    Mentioned
    1 Post(s)
    Quoted
    121 Post(s)

    Default

    Quote Originally Posted by maky369 View Post
    Hey everyone, thanks for all the help you've already given me. Hopefully, this will be the last thread I make here concerning this script.

    Firstly, I've sort of got a basic script set up for my CutAndBurner, right here.

    Code:
    program CutAndLight;
    
    {$DEFINE SMART}
    {$i srl/srl.simba}
    
    Var
    PBox: TBox;
    
    Procedure Setup;
    begin
      SetAngle (SRL_ANGLE_HIGH);
      MakeCompass ('N');
    end;
    
    Procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
    
      Players[0].Name :='';
      Players[0].Pass :='';
      Players[0].Nick :='';
      Players[0].Active:=True;
    end;
    
    Function InvEmpty: Boolean;
        begin
          Result:= FindColor (dx, dy, 2770782, 20, MIX1, MIY1, MIX2, MIY2);
        end;
    
    Function DetectCutting: Boolean; //Detects if you're cutting trees.
      begin
        PBox:= IntToBox(245, 130, 285, 195);
        Result:= (AveragePixelShift (PBox, 250, 300) > 190);
      end;
    
    Function FireOnFloor: Boolean; //Checks if theres a fire under you.
      var (FBox: TBox; fx, fy: integer);
        begin
         FBox:= IntToBox (250, 173, 272, 187);
         Result:= FindObj (fx, fy, 2258409, 87, FBox);
        end;
    
    Function DetectBurning: Boolean; //Detects if you're burning logs.
      begin
        PBox:= IntToBox(245, 130, 285, 195);
        Result:= (AveragePixelShift (PBox, 250, 300) > BurningPShift);
      end;
    
    Procedure CutAndBurnLogs;
    var x, y: integer;
    begin
    Setup;
    repeat
      begin
        repeat
          if FindObj (x, y, ree, 1795912, 35, MSX1, MSY1, MSX2, MSY2) then
            Mouse (x, y, 2, 2, true);
          if DetectCutting then
           Wait (300 + random(100));
        until (InvFull);
      end;
    
      begin
        repeat
          if not DetectBurning and if not FireOnFloor then
            begin
              TypeByte (49);
              if FindObj (x, y, 6316644, 1, MSX1, MSY1, MSX2, MSY2) then
              Mouse (x, y, 2, 2, true);
            end;
          else
          if DetectBurning and if not FireOnFloor then
            Wait (200 + random (100));
          else
          if not DetectBurning and if FireOnFloor then
            begin
            If (FindColor (x, y, 2379333, 10, MMX1, MMY1, MMX2, MMY2)) then
            Mouse (x, y, 0, 0, true;)
            end;
        until not (InvEmpty);
      end;
    until (false);
    end;
    
    begin
      SetupSRL;
      DeclarePlayers;
      ActivateClient;
        Repeat
        if not LoggedIn then LoginPlayer;
        CutAndBurnLogs;
        until (false);
    end.
    Unfortunately, I'm getting the following error.

    Code:
    [Error] C:\Users\Matt\Desktop\Cut and Light.simba(28:10): Duplicate identifier 'INVEMPTY' at line 27
    Compiling failed.
    Anyone can enlighten me? Also, if you have anything to say about the actual script, that would be helpful too - keep in mind i'm still very new to this. I am aware that one of my PixelShift commands isn't set up properly - I haven't found that yet.

    Yes, I know there's not antiban, failsafes, 6 hour fix, random solver, but I'm going to add those later.
    change the INVEMPTY name to something else. like MYINVEMPTY

  3. #3
    Join Date
    Mar 2006
    Location
    Belgium
    Posts
    3,564
    Mentioned
    111 Post(s)
    Quoted
    1475 Post(s)

    Default

    It's cause InvEmpty is already a function within SRL. So either rename or use that one

    Creds to DannyRS for this wonderful sig!

  4. #4
    Join Date
    Apr 2013
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Alright guys, fixed up a lot of it by debugging my way down.

    Script now looks like this.
    Code:
    program CutAndLight;
    
    {$DEFINE SMART}
    {$i srl/srl.simba}
    
    Var
    PBox: TBox;
    
    Procedure Setup;
    begin
      SetAngle (SRL_ANGLE_HIGH);
      MakeCompass ('N');
    end;
    
    Procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
    
      Players[0].Name :='';
      Players[0].Pass :='';
      Players[0].Nick :='';
      Players[0].Active:=True;
    end;
    
    Function MyInvEmpty: Boolean;
    var dx, dy: Integer;
        begin
          Result:= FindColor (dx, dy, 2770782, MIX1, MIY1, MIX2, MIY2);
        end;
    
    Function DetectCutting: Boolean; //Detects if you're cutting trees.
      begin
        PBox:= IntToBox(245, 130, 285, 195);
        Result:= (AveragePixelShift (PBox, 250, 300) > 190);
      end;
    
    Function FireOnFloor: Boolean; //Checks if theres a fire under you.
      var
      fx, fy: integer;
        begin
         Result:= FindColor (fx, fy, 2258409, 250, 173, 272, 187);
        end;
    
    Function DetectBurning: Boolean; //Detects if you're burning logs.
      begin
        PBox:= IntToBox(245, 130, 285, 195);
        Result:= (AveragePixelShift (PBox, 250, 300) > 150);
      end;
    
    Procedure CutAndBurnLogs;
    var x, y: integer;
    begin
    Setup;
    repeat
      begin
        repeat
          if FindObj (x, y,'', 1795912, 10) then
            Mouse (x, y, 2, 2, true);
          if DetectCutting then
           Wait (300 + random(100));
        until (InvFull);
      end;
    
      begin
        repeat
          if not (DetectBurning) and if not (FireOnFloor) then
            begin
              TypeByte (49);
              if FindObj (x, y, 6316644, 1, MSX1, MSY1, MSX2, MSY2) then
              Mouse (x, y, 2, 2, true);
            end;
          else
          if DetectBurning and if not FireOnFloor then
            Wait (200 + random (100));
          else
          if not DetectBurning and if FireOnFloor then
            begin
            If (FindColor (x, y, 2379333, 10, MMX1, MMY1, MMX2, MMY2)) then
            Mouse (x, y, 0, 0, true;)
            end;
        until not (MyInvEmpty);
      end;
    until (false);
    end;
    
    begin
      SetupSRL;
      DeclarePlayers;
      ActivateClient;
        Repeat
        if not LoggedIn then LoginPlayer;
        CutAndBurnLogs;
        until (false);
    end.
    But I got an error like this.

    Code:
    [Error] C:\Users\Matt\Desktop\Cut and Light.simba(69:34): Syntax error at line 68
    Compiling failed.
    That's this line: if not (DetectBurning) and if not (FireOnFloor) then

    Any takers?

  5. #5
    Join Date
    Jan 2013
    Posts
    294
    Mentioned
    1 Post(s)
    Quoted
    121 Post(s)

    Default

    if not (DetectBurning) and if not (FireOnFloor) then
    change to if if not (DetectBurning) and not (FireOnFloor) then

    your findobj function is not declared correctly. the official function is as
    Simba Code:
    (*
    FindObj
    ~~~~~~~

    .. code-block:: pascal


        function FindObj(var cx, cy: Integer; Text: string; Color, Tol: Integer): Boolean;

    Finds Object

    .. note::

        by Starblaster100

    Example:

    .. code-block:: pascal

    *)
    Last edited by dzpliu; 04-09-2013 at 10:03 AM.

  6. #6
    Join Date
    Apr 2013
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Alright, thanks! Managed to trip my way to debugging. However along the way, I continuously got "Identifier expected" errors on my "else" lines when I was using if..then..else.. issues, which I solved by moving it to the line before, such that it then read "end else". However, this meant that I previously had a statement "If...then...(one line of code) else..." which I had to change to "If...then...begin(one line of code) end else..."

    Can anyone explain this to me?

  7. #7
    Join Date
    Jan 2013
    Posts
    294
    Mentioned
    1 Post(s)
    Quoted
    121 Post(s)

    Default

    Quote Originally Posted by maky369 View Post
    Alright, thanks! Managed to trip my way to debugging. However along the way, I continuously got "Identifier expected" errors on my "else" lines when I was using if..then..else.. issues, which I solved by moving it to the line before, such that it then read "end else". However, this meant that I previously had a statement "If...then...(one line of code) else..." which I had to change to "If...then...begin(one line of code) end else..."
    Can anyone explain this to me?
    i looked at your script. i give one example on how to solve your if.else error.
    example:
    Simba Code:
    if DetectBurning and not FireOnFloor then
            Wait (200 + random (100))
          else
         blah blah
    or

    if DetectBurning and not FireOnFloor then
            begin
    Wait (200 + random (100))
         end else
         blah blah

  8. #8
    Join Date
    Apr 2013
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Yes, I was using that format, it was still shooting an "Identifier expected" error at me.

  9. #9
    Join Date
    Jan 2013
    Posts
    294
    Mentioned
    1 Post(s)
    Quoted
    121 Post(s)

    Default

    Quote Originally Posted by maky369 View Post
    Yes, I was using that format, it was still shooting an "Identifier expected" error at me.
    look carefully. mine is different. hint: the ';'

  10. #10
    Join Date
    Apr 2013
    Posts
    14
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    Quote Originally Posted by dzpliu View Post
    look carefully. mine is different. hint: the ';'
    AH, I see it. Thanks, this applies to all uses of else?

  11. #11
    Join Date
    Jan 2013
    Posts
    294
    Mentioned
    1 Post(s)
    Quoted
    121 Post(s)

    Default

    Quote Originally Posted by maky369 View Post
    AH, I see it. Thanks, this applies to all uses of else?
    basically it should work.

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
  •