SRL Archive - OSR Help

Duplicate identifier error - not sure why


maky369

2013-04-09 05:37:01

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.

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.

[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.

dzpliu

2013-04-09 05:40:10

From: maky369
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.

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.

[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

Sjoe

2013-04-09 05:46:19

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

maky369

2013-04-09 05:53:11

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

Script now looks like this.
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.

[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?

dzpliu

2013-04-09 05:53:23

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
(*
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

*)

maky369

2013-04-09 06:01:30

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?

dzpliu

2013-04-09 06:08:24

From: maky369
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:
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

maky369

2013-04-09 06:09:57

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

dzpliu

2013-04-09 06:12:01

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


look carefully. mine is different. hint: the ';'

maky369

2013-04-09 06:21:22

From: dzpliu
look carefully. mine is different. hint: the ';'


AH, I see it. Thanks, this applies to all uses of else?

dzpliu

2013-04-09 06:22:50

From: maky369
AH, I see it. Thanks, this applies to all uses of else?


basically it should work.