SRL Archive - OSR Help

1st time scripting help


Ann_arbor

2012-12-09 03:30:23

I just got done following the tutorial on how to make a simple woodcutter script. I am now attempting to add walking and banking to the procedure but every time I add the walking function, it either gets ignored, or walking is the only thing the script will do. I used the path creator program to get my walking coordinates.

Any help is greatly appreciated!

program new;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}

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

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
Players[0].Pin :=''
end;


procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
case Random(8) of
0:
begin
HoverSkill('woodcutting', false);
wait(2453+Random(432));
end;
1: PickUpMouse;
2:
begin
MakeCompass('N');
wait(100+random(133));
MakeCompass('S');
wait(50+random(133));
MakeCompass('N');
end;
end;
end;


Procedure ChopTree;
var x, y: integer;
begin
repeat
if FindObj(x,y,'hop',1384479, 05) then
begin
Mouse(x, y, 2, 2, false);
ChooseOption('hop');
end;
repeat
Wait(400+random(250));
AntiBan;
Until not IsUpText('ew') or (InvFull);
until(invFull);
end;

Procedure Walk;
Var
myPath:TPointArray;
begin
SetupSRL;
SPS_Setup(RUNESCAPE_SURFACE,['11_7']);
myPath :=[Point(4497, 3032), Point(4500, 3029), Point(4503, 3026), Point(4509, 3008), Point(4509, 3008), Point(4509, 3003), Point(4509, 2998), Point(4510, 2992), Point(4512, 2981), Point(4516, 2970), Point(4516, 2964), Point(4522, 2949), Point(4522, 2949), Point(4525, 2948), Point(4528, 2945), Point(4531, 2943), Point(4535, 2942), Point(4542, 2939), Point(4548, 2939), Point(4553, 2938), Point(4560, 2935), Point(4564, 2933), Point(4571, 2929), Point(4576, 2923), Point(4581, 2915), Point(4582, 2911), Point(4588, 2908), Point(4593, 2908)];//Path
SPS_WalkPath(myPath);
end;


begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
ChopTree;
end.

Justin

2012-12-09 03:43:35

Add

Walk;

after the


ChopTree;

EG:


begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
ChopTree;
Walk;
end.

Ian

2012-12-09 03:44:20

I noticed that your walk procedure is never actually called in the MainLoop, put it after ChopTree;

E::ninja:`d

Roflme

2012-12-09 10:55:18

Also, I don't know if it'll make a difference, but you may want to add more areas of the runescape surface to load. Just a single one (you're using 11_7) may not be enough. Make sure the map covers the entire path, AND some space around it. I don't know what map 11_7 is but I don't know if it'll cover your trees, path, AND bank all in the single map.

Use a path creator, make your path, and copy that. THEN click on points circling the path and copy the area.

DannyRS

2012-12-09 11:00:12

Try never to call SPS_SetUp(x) more than once in the code too, that can cause problems, so move it to its own procedure before the main loop and out of Walk;

Ann_arbor

2012-12-09 18:37:26

From: DannyRS
Try never to call SPS_SetUp(x) more than once in the code too, that can cause problems, so move it to its own procedure before the main loop and out of Walk;


I do not know what you mean by this?

I am having a real hard time deciphering exactly how to script. I've been staring at tutorials for two days now.

I have given up on the walking part for now and I am working on adding banking instead.

I am having trouble with using functions.

When I copy and paste the OpenBankNPC function into my script I just get a duplicate identifier error at line 69.

program new;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}

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

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
Players[0].Pin :=''
end;


procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
case Random(8) of
0:
begin
HoverSkill('woodcutting', false);
wait(2453+Random(432));
end;
1: PickUpMouse;
2:
begin
MakeCompass('N');
wait(100+random(133));
MakeCompass('S');
wait(50+random(133));
MakeCompass('N');
end;
end;
end;


Procedure ChopTree;
var x, y: integer;
begin
repeat
if FindObj(x,y,'hop',1384479, 05) then
begin
Mouse(x, y, 2, 2, false);
ChooseOption('hop');
end;
repeat
Wait(400+random(250));
AntiBan;
Until not IsUpText('ew') or (InvFull);
until(invFull);
end;

Procedure Walk;
Var
myPath:TPointArray;
begin
SetupSRL;
SPS_Setup(RUNESCAPE_SURFACE,['11_7']);
myPath :=[Point(4497, 3032), Point(4500, 3029), Point(4503, 3026), Point(4509, 3008), Point(4509, 3008), Point(4509, 3003), Point(4509, 2998), Point(4510, 2992), Point(4512, 2981), Point(4516, 2970), Point(4516, 2964), Point(4522, 2949), Point(4522, 2949), Point(4525, 2948), Point(4528, 2945), Point(4531, 2943), Point(4535, 2942), Point(4542, 2939), Point(4548, 2939), Point(4553, 2938), Point(4560, 2935), Point(4564, 2933), Point(4571, 2929), Point(4576, 2923), Point(4581, 2915), Point(4582, 2911), Point(4588, 2908), Point(4593, 2908)];//Path
SPS_WalkPath(myPath);
end;

[COLOR="red"]function OpenBankNPC: Boolean;[/COLOR]
var
NPCBox :TBox;
Colors, NPCArray :TPointArray;
ATPA: T2DPointArray;
MSNPC, NPCPoint :TPoint;
CTS, C, II, I :Integer;
begin
Result := False;
Result := (BankScreen) or (PinScreen);
If Result then
Exit;
NPCArray := GetMinimapDots('NPC');
If Length(NPCArray) < 1 then
Exit;
SortTPAFrom(NPCArray, Point(MMCX, MMCY));
for I := 0 to High(NPCArray) do
begin
NPCPoint := MMToMS(NPCArray[I])
If (NPCPoint.x = -1) and (NPCPoint.y = -1) then
Continue;
with NPCPoint do
NPCBox := IntToBox(Max(X - 40, MSX1), Max(Y - 40, MSY1), Min(X + 40, MSX2), Min(Y + 40, MSY2));
If PixelShift(NPCBox, 200) > 500 then
Continue;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 1.52);
FindColorsTolerance(Colors, 6067652, NPCBox.X1, NPCBox.Y1, NPCBox.X2, NPCBox.Y2, 13);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(Colors, 15, 20);
SortATPASize(ATPA, True);

for II := 0 to High(ATPA) do
begin
MSNPC := MiddleTPA(ATPA[II]);
MMouse(MSNPC.X, MSNPC.Y, 3, 3);
If WaitUpTextMulti(['ooth', 'anker'], 200) then
begin
ClickMouse2(False);
If WaitOptionMulti(['Bank B', 'nk B'], 600) then
MarkTime(c);
Repeat
Wait(RandomRange(50, 100));
Until (BankScreen) or (PinScreen) or (TimeFromMark(C) > 4500);
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := (BankScreen) or (PinScreen);
If Result then
Exit;
end;
end;
end;
end;


begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
ChopTree;
Walk;
OpenBankNPC;
end.

I wrote line 69 in red.


The error
[Error] C:\Simba\Scripts\(2).simba(70:10): Duplicate identifier 'OPENBANKNPC' at line 69
Compiling failed.


I use the search tool to find solutions, it is just a matter of my brain understanding the logic.

This tells me the problems behind the duplicate identifier.
http://villavu.com/forum/showthread.php?t=85373&highlight=duplicate+identifier

This explains to me what procedures/ functions/ variables/ etc are. But I just can't grasp the meaning behind it all.
http://villavu.com/forum/showthread.php?t=58935

Justin

2012-12-09 19:13:22

From: Ann_arbor
I do not know what you mean by this?

I am having a real hard time deciphering exactly how to script. I've been staring at tutorials for two days now.

I have given up on the walking part for now and I am working on adding banking instead.

I am having trouble with using functions.

When I copy and paste the OpenBankNPC function into my script I just get a duplicate identifier error at line 69.

program new;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i sps/sps.simba}

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

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;
Players[0].Pin :=''
end;


procedure AntiBan;
begin
if(not(LoggedIn))then
Exit;
case Random(8) of
0:
begin
HoverSkill('woodcutting', false);
wait(2453+Random(432));
end;
1: PickUpMouse;
2:
begin
MakeCompass('N');
wait(100+random(133));
MakeCompass('S');
wait(50+random(133));
MakeCompass('N');
end;
end;
end;


Procedure ChopTree;
var x, y: integer;
begin
repeat
if FindObj(x,y,'hop',1384479, 05) then
begin
Mouse(x, y, 2, 2, false);
ChooseOption('hop');
end;
repeat
Wait(400+random(250));
AntiBan;
Until not IsUpText('ew') or (InvFull);
until(invFull);
end;

Procedure Walk;
Var
myPath:TPointArray;
begin
SetupSRL;
SPS_Setup(RUNESCAPE_SURFACE,['11_7']);
myPath :=[Point(4497, 3032), Point(4500, 3029), Point(4503, 3026), Point(4509, 3008), Point(4509, 3008), Point(4509, 3003), Point(4509, 2998), Point(4510, 2992), Point(4512, 2981), Point(4516, 2970), Point(4516, 2964), Point(4522, 2949), Point(4522, 2949), Point(4525, 2948), Point(4528, 2945), Point(4531, 2943), Point(4535, 2942), Point(4542, 2939), Point(4548, 2939), Point(4553, 2938), Point(4560, 2935), Point(4564, 2933), Point(4571, 2929), Point(4576, 2923), Point(4581, 2915), Point(4582, 2911), Point(4588, 2908), Point(4593, 2908)];//Path
SPS_WalkPath(myPath);
end;

[COLOR="red"]function OpenBankNPC: Boolean;[/COLOR]
var
NPCBox :TBox;
Colors, NPCArray :TPointArray;
ATPA: T2DPointArray;
MSNPC, NPCPoint :TPoint;
CTS, C, II, I :Integer;
begin
Result := False;
Result := (BankScreen) or (PinScreen);
If Result then
Exit;
NPCArray := GetMinimapDots('NPC');
If Length(NPCArray) < 1 then
Exit;
SortTPAFrom(NPCArray, Point(MMCX, MMCY));
for I := 0 to High(NPCArray) do
begin
NPCPoint := MMToMS(NPCArray[I])
If (NPCPoint.x = -1) and (NPCPoint.y = -1) then
Continue;
with NPCPoint do
NPCBox := IntToBox(Max(X - 40, MSX1), Max(Y - 40, MSY1), Min(X + 40, MSX2), Min(Y + 40, MSY2));
If PixelShift(NPCBox, 200) > 500 then
Continue;

CTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.13, 1.52);
FindColorsTolerance(Colors, 6067652, NPCBox.X1, NPCBox.Y1, NPCBox.X2, NPCBox.Y2, 13);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(CTS);
ATPA := TPAToATPAEx(Colors, 15, 20);
SortATPASize(ATPA, True);

for II := 0 to High(ATPA) do
begin
MSNPC := MiddleTPA(ATPA[II]);
MMouse(MSNPC.X, MSNPC.Y, 3, 3);
If WaitUpTextMulti(['ooth', 'anker'], 200) then
begin
ClickMouse2(False);
If WaitOptionMulti(['Bank B', 'nk B'], 600) then
MarkTime(c);
Repeat
Wait(RandomRange(50, 100));
Until (BankScreen) or (PinScreen) or (TimeFromMark(C) > 4500);
if (Players[CurrentPlayer].Pin <> '') then
InPin(Players[CurrentPlayer].Pin);
Result := (BankScreen) or (PinScreen);
If Result then
Exit;
end;
end;
end;
end;


begin
SetUpSRL;
ActivateClient;
DeclarePlayers;
LoginPlayer;
ChopTree;
Walk;
OpenBankNPC;
end.

I wrote line 69 in red.


The error
[Error] C:\Simba\Scripts\(2).simba(70:10): Duplicate identifier 'OPENBANKNPC' at line 69
Compiling failed.


I use the search tool to find solutions, it is just a matter of my brain understanding the logic.

This tells me the problems behind the duplicate identifier.
http://villavu.com/forum/showthread.php?t=85373&highlight=duplicate+identifier

This explains to me what procedures/ functions/ variables/ etc are. But I just can't grasp the meaning behind it all.
http://villavu.com/forum/showthread.php?t=58935



What the duplicate identifier for 'OpenBankNPC' means is that the procedure\function 'OpenBankNPC' has already been coded somewhere else (In the script\include\plugin), in this case, It's already been scripted into the SRL include so you wont need the full procedure\function in your script, you are able to just call 'OpenBankNPC' and it will do its procedure\function.

xtrapsp

2012-12-09 19:14:47

duplicate identifier:

Basically When you write a script the bit at the top $i Include is opening another simba file with a load of code other people have written… cool huh? So by copying and pasting
OpenBankNPC you have 2 copies of the same code :)

Try naming OpenBankNPC to OpenNPCBank