SRL Archive - OSR Help

Identifier expected


Syntax

2013-08-08 08:04:28

program Herb_Identifier;
{$i SRL-OSR/SRL.Simba}
{$i SPS/SPS-OSR.simba}
Var
X,Y,DTM_House,DTM_Bank,DTM_Cookingpot, DTM_Herb, DTM_Pot:Integer;
IsInbank:Boolean;
IsInIdentifier:Boolean;
Status:String;

Const
//SRL Stats
SRLStats_Username = '';
SRLStats_Password = '';

Procedure declarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := ''; //username
Pass := ''; //password
Nick := ''; //display name
Pin := ''; //bank pin
LampSkill := Skill_Agility;
WorldInfo := [];
Member := True;
Active := True;
end;
end;

Procedure WriteStatus;
begin
Wait(400);
ClearDebug;
Writeln('Status:' + status);
end;

Procedure FreetheDTMs;
Begin
FreeDTM(DTM_Bank);
FreeDTM(DTM_Cookingpot);
FreeDTM(DTM_Herb);
FreeDTM(DTM_Pot);
end;

Procedure LoadDTM;
Begin
DTM_Bank := DTMFromString('mWAAAAHicY2FgYLjPxMDwGIjvAvFzIL4IFDsNxSD2lSO2DIyMjHCMDhjRMAgAAD4/CK0=');
DTM_Cookingpot := DTMFromString('mWAAAAHicY2FgYOBkZmDgA2JhIBYA4qNAsb1AfJABwq71F2JgZGQE465JExjQASMaBgEAQdwF5w==');
DTM_Herb := DTMFromString('mWAAAAHicY2FgYJjCxMAwC4j7mCBsM6CYERTrA7FhCSMDIyMCowNGNAwCAAx8A9k=');
DTM_Pot := DTMFromString('mbQAAAHicY2VgYIhgguB4II4C4jggdgKKWzNAaE8gdgXiBb6CDIyMjCgYG2DEgsEAAFlRBDM=');
end;

function IsInBank(): boolean;
var
Dist_To_Bank,c,b,t,u,Dist_To_Cookingpot:Integer;
begin
Status := 'Outside of the bank'
Result := false;
FindDTM(DTM_Bank, x, y, 524, 3, 762, 168)
FindDTM(DTM_Cookingpot, t, u, 524, 3, 762, 168)
Dist_To_Bank := Distance(c, b, 643, 83);
Dist_To_Cookingpot := Distance (t, u, 643, 83);
Writeln('Current Distance from Bank symbol:' + ToStr(Dist_To_Bank))
Writeln('Current Distance from Cookingpot symbol:' + ToStr(Dist_To_Cookingpot))
If (Dist_To_Bank <= 20) And
(Dist_To_Cookingpot <= 42) then
Begin
Status := 'Inside of the Bank'
Result := true;
end;
end;

function IsInIdentifer(): boolean;
var
c,b,o,p, Dist_To_Pot,Dist_To_Herb:Integer;
begin
Status := 'Outside of the identifier'
Result := false;
FindDTM(DTM_Herb, o, p, 524, 3, 762, 168)
FindDTM(DTM_Pot, c, b, 524, 3, 762, 168)
Dist_To_Herb := Distance(X, Y, 643, 83);
Dist_To_Pot := Distance (c, b, 643, 83);
Writeln('Current Distance from Pot symbol:' + ToStr(Dist_To_Pot))
Writeln('Current Distance from Herb symbol:' + ToStr(Dist_To_Herb))
If (Dist_To_Herb <= 12) And
(Dist_To_Pot <= 36) then
Begin
Status := 'Inside of the identifier'
Result := true;
end;
end;

Function MyOpenBank:Boolean;
var
TPA : TPointArray;
ATPA : T2DPointArray;
x, y, i, ii:Integer;
begin
Result:= False;
if BankScreen then
begin
Result:= True;
Writeln('Bank Found');
Exit;
end;
MakeCompass('W');
Wait(300); //screen settel
FindColorsTolerance(TPA, 2445165, MSX1, MSY1, MSX2, MSY2, 5);
//DebugTPA(TPA, '');
//Wait(3000);
ATPA := SplitTPAEx(TPA, 10, 10);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
//DebugATPABounds(ATPA);
ii := High(ATPA); //get higherst entry in array
for i := 0 to ii do //from 0 first entry in array to ii highest entry
begin
MiddleTPAEx(ATPA[i], x, y);//find middle of array entry
MMouse(x, y, 3, 3);
if WaitUpTextMulti(['ooth', 'ank booth'], 300) then
begin
Mouse(x, y, 0, 0, False);
Wait(200); //ERROR HERE
//ChooseOption('uickly'); //Dont work
//WaitOptionMultiEx(['se-quickly', 'uickly'], 'all', ClickLeft, 200);//Dont work
//WaitOption('uickly', 500); //Dont work
ChooseOptionMultiEx(['uickl'], 'all', ClickLeft) //Dont work
Flag;
Wait(2000 + Random(800));
if BankScreen then
begin
Result:= True;
Writeln('Bank Found');
Exit;
end;
end;
end;
end;
procedure WalkToBank;
var
MyPath:TPointArray;
begin
if not IsInBank then
SPS_Setup(runescape_surface, ['13_12']);
myPath := [Point(329, 275), Point(329, 258), Point(346, 259), Point(353, 265),
Point(358, 277), Point(360, 289), Point(358, 304), Point(358, 318),
Point(357, 333), Point(342, 341)];
SPS_WalkPath (myPath);
end;
Procedure get_herbs;
begin
if not IsInBank then
WalkToBank
else
writeln('test');
end;

procedure walk_to_identifier;
begin
if not IsInIdentifier then
WalkToIdentifer
else

end;


procedure identify_herbs;
begin
if not IsInIdentifer then;
WalkToIdentifer;

check for coins

find him and click on him (TPAs)?

identify herbs (click through dialogue)
end;

begin
SetupSRL;
DeclarePlayers;
LoginPlayer;

end.

[Error] C:\Simba\Scripts\Herb.simba(156:1): Identifier expected at line 155
Compiling failed.
Ignore the notes I have made in the script, as far as the compiler goes it hasn't got up to there yet.
Also not showing up will all procedures I have made:
http://i.imgur.com/FteA1jy.png

riwu

2013-08-08 08:09:08

You have a 'withdraw method here' at line 156 which caused the error.
Also you dont need a semicolon after 'else'

Syntax

2013-08-08 08:11:22

From: riwu
You have a 'withdraw method here' at line 156 which caused the error.
Also you dont need a semicolon after 'else'


Changed it on OP and tried to run it in simba, doesn't work throws same error :/
Thanks for responding.

riwu

2013-08-08 08:13:36

From: Blakebn2011
Changed it on OP and tried to run it in simba, doesn't work throws same error :/
Thanks for responding.

Remove all your semicolons after 'else' and 'then'.
Semicolon indicates the end of a statement, hence adding it to 'else' and 'then' is inappropriate.

Syntax

2013-08-08 08:15:39

From: riwu
Remove all your semicolons after 'else' and 'then'.
Semicolon indicates the end of a statement, hence adding it to 'else' and 'then' is inappropriate.

Removed semicolons, still getting same error. My bad about those, has been a bit of a habit.
Also, what do you think the issue is not showing all the procedures of the script?

riwu

2013-08-08 08:17:19

From: Blakebn2011
Removed semicolons, still getting same error. My bad about those, has been a bit of a habit.
Also, what do you think the issue is not showing all the procedures of the script?

Remove the one after WalkToIdentifer() as well, don't end statements with semicolons if they are followed by 'else'

Syntax

2013-08-08 08:32:07

From: riwu
Remove the one after WalkToIdentifer() as well, don't end statements with semicolons if they are followed by 'else'

Ok all fixed up, still throwing same error. I think its something else :p
Thank you again riwu.

riwu

2013-08-08 08:49:40

From: Blakebn2011
Ok all fixed up, still throwing same error. I think its something else :p
Thank you again riwu.

Srry missed the error, it's the semicolon after WalkToBank()

Syntax

2013-08-08 08:59:28

From: riwu
Srry missed the error, it's the semicolon after WalkToBank()

After removing the semi-colon gives me new error,
'[Error] C:\Simba\Scripts\Herb.simba(58:12): Duplicate identifier 'ISINBANK' at line 57
Compiling failed.'
Also how do I address the procedures not showing in the Functionlist under 'Script'

Turpinator

2013-08-08 09:05:09

 IsInbank:Boolean;
function IsInBank(): boolean;
well theres your problem. You might be used to declaring your functions as their types, but… thats a var you declared it as.

Delete the first one as you just want the function call.

Syntax

2013-08-08 09:21:12

From: Turpinator
 IsInbank:Boolean;
function IsInBank(): boolean;
well theres your problem. You might be used to declaring your functions as their types, but… thats a var you declared it as.

Delete the first one as you just want the function call.

Fixed thank you Turp, also that email function looks handy going to implement it into this script.
Still not sure what is up with my function list though.

Turpinator

2013-08-08 09:28:23

Function list… Hmm. Are you using lape? As i recall dgby saying (i think), the func list doesnt work in lape yet. (at least the current version of simba)

Syntax

2013-08-08 09:49:04

Nope, here is an image: http://i.imgur.com/kCdX7Fa.png

riwu

2013-08-08 09:57:21

From: Blakebn2011
Nope, here is an image: http://i.imgur.com/kCdX7Fa.png

Adding the necessary semicolons in your IsInBank() and IsInIdentifer() functions will fix the problem.
Also read up on coding/naming conventions ;)

function IsInBank(): boolean;
var
Dist_To_Bank,c,b,t,u,Dist_To_Cookingpot:Integer;
begin
Status := 'Outside of the bank';
Result := false;
FindDTM(DTM_Bank, x, y, 524, 3, 762, 168);
FindDTM(DTM_Cookingpot, t, u, 524, 3, 762, 168);
Dist_To_Bank := Distance(c, b, 643, 83);
Dist_To_Cookingpot := Distance (t, u, 643, 83);
Writeln('Current Distance from Bank symbol:' + ToStr(Dist_To_Bank));
Writeln('Current Distance from Cookingpot symbol:' + ToStr(Dist_To_Cookingpot));
If (Dist_To_Bank <= 20) And
(Dist_To_Cookingpot <= 42) then
Begin
Status := 'Inside of the Bank';
Result := true;
end;
end;

function IsInIdentifer(): boolean;
var
c,b,o,p, Dist_To_Pot,Dist_To_Herb:Integer;
begin
Status := 'Outside of the identifier';
Result := false;
FindDTM(DTM_Herb, o, p, 524, 3, 762, 168);
FindDTM(DTM_Pot, c, b, 524, 3, 762, 168);
Dist_To_Herb := Distance(X, Y, 643, 83);
Dist_To_Pot := Distance (c, b, 643, 83);
Writeln('Current Distance from Pot symbol:' + ToStr(Dist_To_Pot));
Writeln('Current Distance from Herb symbol:' + ToStr(Dist_To_Herb));
If (Dist_To_Herb <= 12) And
(Dist_To_Pot <= 36) then
Begin
Status := 'Inside of the identifier';
Result := true;
end;
end;

Syntax

2013-08-08 10:05:29

From: riwu
Adding the necessary semicolons in your IsInBank() and IsInIdentifer() functions will fix the problem.
Also read up on coding/naming conventions ;)

function IsInBank(): boolean;
var
Dist_To_Bank,c,b,t,u,Dist_To_Cookingpot:Integer;
begin
Status := 'Outside of the bank';
Result := false;
FindDTM(DTM_Bank, x, y, 524, 3, 762, 168);
FindDTM(DTM_Cookingpot, t, u, 524, 3, 762, 168);
Dist_To_Bank := Distance(c, b, 643, 83);
Dist_To_Cookingpot := Distance (t, u, 643, 83);
Writeln('Current Distance from Bank symbol:' + ToStr(Dist_To_Bank));
Writeln('Current Distance from Cookingpot symbol:' + ToStr(Dist_To_Cookingpot));
If (Dist_To_Bank <= 20) And
(Dist_To_Cookingpot <= 42) then
Begin
Status := 'Inside of the Bank';
Result := true;
end;
end;

function IsInIdentifer(): boolean;
var
c,b,o,p, Dist_To_Pot,Dist_To_Herb:Integer;
begin
Status := 'Outside of the identifier';
Result := false;
FindDTM(DTM_Herb, o, p, 524, 3, 762, 168);
FindDTM(DTM_Pot, c, b, 524, 3, 762, 168);
Dist_To_Herb := Distance(X, Y, 643, 83);
Dist_To_Pot := Distance (c, b, 643, 83);
Writeln('Current Distance from Pot symbol:' + ToStr(Dist_To_Pot));
Writeln('Current Distance from Herb symbol:' + ToStr(Dist_To_Herb));
If (Dist_To_Herb <= 12) And
(Dist_To_Pot <= 36) then
Begin
Status := 'Inside of the identifier';
Result := true;
end;
end;


Thanks Riwu and Turpinator really appreciate the help all solved. By the naming conventions, do you mean that the way in which someone usually names a variable is not the way I name it?

Turpinator

2013-08-08 10:12:56

From: Blakebn2011
Nope, here is an image: http://i.imgur.com/kCdX7Fa.png

program Herb_Identifier;
{$i SRL/SRL.Simba}
{$i SPS/SPS.simba}
Var
X,Y,DTM_House,DTM_Bank,DTM_Cookingpot, DTM_Herb, DTM_Pot:Integer;
IsInIdentifier:Boolean;
Status:String;

Const
//SRL Stats
SRLStats_Username = '';
SRLStats_Password = '';

Procedure declarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := ''; //username
Pass := ''; //password
Nick := ''; //display name
Pin := ''; //bank pin
LampSkill := Skill_Agility;
WorldInfo := [];
Member := True;
Active := True;
end;
end;

Procedure WriteStatus;
begin
Wait(400);
ClearDebug;
Writeln('Status:' + status);
end;

Procedure FreetheDTMs;
Begin
FreeDTM(DTM_Bank);
FreeDTM(DTM_Cookingpot);
FreeDTM(DTM_Herb);
FreeDTM(DTM_Pot);
end;

Procedure LoadDTM;
Begin
DTM_Bank := DTMFromString('mWAAAAHicY2FgYLjPxMDwGIjvAvFzIL4IFDsNxSD2lSO2DIyMjHCMDhjRMAgAAD4/CK0=');
DTM_Cookingpot := DTMFromString('mWAAAAHicY2FgYOBkZmDgA2JhIBYA4qNAsb1AfJABwq71F2JgZGQE465JExjQASMaBgEAQdwF5w==');
DTM_Herb := DTMFromString('mWAAAAHicY2FgYJjCxMAwC4j7mCBsM6CYERTrA7FhCSMDIyMCowNGNAwCAAx8A9k=');
DTM_Pot := DTMFromString('mbQAAAHicY2VgYIhgguB4II4C4jggdgKKWzNAaE8gdgXiBb6CDIyMjCgYG2DEgsEAAFlRBDM=');
end;

function IsInBank: boolean;
var
Dist_To_Bank,c,b,t,u,Dist_To_Cookingpot:Integer;
begin
Status := 'Outside of the bank';
Result := false;
FindDTM(DTM_Bank, x, y, 524, 3, 762, 168);
FindDTM(DTM_Cookingpot, t, u, 524, 3, 762, 168);
Dist_To_Bank := Distance(c, b, 643, 83);
Dist_To_Cookingpot := Distance (t, u, 643, 83);
Writeln('Current Distance from Bank symbol:' + ToStr(Dist_To_Bank));
Writeln('Current Distance from Cookingpot symbol:' + ToStr(Dist_To_Cookingpot));
If ((Dist_To_Bank <= 20) And (Dist_To_Cookingpot <= 42)) then
Begin
Status := 'Inside of the Bank';
Result := true;
end;
end;

function IsInIdentifer: boolean;
var
c,b,o,p, Dist_To_Pot,Dist_To_Herb:Integer;
begin
Status := 'Outside of the identifier';
Result := false;
FindDTM(DTM_Herb, o, p, 524, 3, 762, 168);
FindDTM(DTM_Pot, c, b, 524, 3, 762, 168);
Dist_To_Herb := Distance(X, Y, 643, 83);
Dist_To_Pot := Distance (c, b, 643, 83);
Writeln('Current Distance from Pot symbol:' + ToStr(Dist_To_Pot));
Writeln('Current Distance from Herb symbol:' + ToStr(Dist_To_Herb));
If ((Dist_To_Herb <= 12) And (Dist_To_Pot <= 36)) then
Begin
Status := 'Inside of the identifier';
Result := true;
end;
end;

Function MyOpenBank:Boolean;
var
TPA : TPointArray;
ATPA : T2DPointArray;
x, y, i, ii:Integer;
begin
Result:= False;
if BankScreen then
begin
Result:= True;
Writeln('Bank Found');
Exit;
end;
MakeCompass('W');
Wait(300); //screen settel
FindColorsTolerance(TPA, 2445165, MSX1, MSY1, MSX2, MSY2, 5);
//DebugTPA(TPA, '');
//Wait(3000);
ATPA := SplitTPAEx(TPA, 10, 10);
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
//DebugATPABounds(ATPA);
ii := High(ATPA); //get higherst entry in array
for i := 0 to ii do //from 0 first entry in array to ii highest entry
begin
MiddleTPAEx(ATPA[i], x, y);//find middle of array entry
MMouse(x, y, 3, 3);
if WaitUpTextMulti(['ooth', 'ank booth'], 300) then
begin
Mouse(x, y, 0, 0, False);
Wait(200); //ERROR HERE
//ChooseOption('uickly'); //Dont work
//WaitOptionMultiEx(['se-quickly', 'uickly'], 'all', ClickLeft, 200);//Dont work
//WaitOption('uickly', 500); //Dont work
ChooseOptionMultiEx(['uickl'], 'all', ClickLeft) //Dont work
Flag;
Wait(2000 + Random(800));
if BankScreen then
begin
Result:= True;
Writeln('Bank Found');
Exit;
end;
end;
end;
end;


procedure WalkToBank;
var
MyPath:TPointArray;
begin
if not IsInBank then
SPS_Setup(runescape_surface, ['13_12']);
myPath := [Point(329, 275), Point(329, 258), Point(346, 259), Point(353, 265),
Point(358, 277), Point(360, 289), Point(358, 304), Point(358, 318),
Point(357, 333), Point(342, 341)];
SPS_WalkPath (myPath);
end;
Procedure get_herbs;
begin
if not IsInBank then
WalkToBank
else
writeln('test');
end;

procedure walk_to_identifier;
begin
if not IsInIdentifier then
WalkToIdentifer;

end;


procedure identify_herbs;
begin
if not IsInIdentifer then
WalkToIdentifer;

//check for coins

//find him and click on him (TPAs)?

//identify herbs (click through dialogue)
end;

begin
SetupSRL;
DeclarePlayers;
LoginPlayer;

end.
Holy missing semicolons batman!


Edit: Oh. riwu got it. meh.

riwu

2013-08-08 10:18:48

From: Blakebn2011
Thanks Riwu and Turpinator really appreciate the help all solved. By the naming conventions, do you mean that the way in which someone usually names a variable is not the way I name it?

Yeah like distToBank (camelCase) instead of Dist_To_Bank.
Check out http://villavu.com/forum/showthread.php?t=60288