SRL Archive - OSR Help

Stuck on my first script - Invalid number of parameters, line 153


03storic

2013-05-06 09:43:24

I am attempting to make my first script and have hit a wall consisting of a "Invalid number of parameters" error when compiling. Posting the script & error below for someone with experience to look it over and point out what I have missed.

I appreciate the assistance and am looking forward to learning more about coding SRL scripts.

[Error] C:\Simba\Scripts\MineCopper.simba(154:15): Invalid number of parameters at line 153
Compiling failed.

program StoicCopperPower07;
{$DEFINE SMART8}
{$I SRL-OSR/SRL.simba}
{$I SRL/SRL/Misc/Debug.Simba}
{$I SRL-OSR/SRL/Misc/SmartGraphics.Simba}

// Begin User Setup

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

with Players[0] do
begin
Name := ''; // Username
Pass := ''; // Password
Nick := ''; // Three Letter Nick
BoxRewards := ['Xp'];
Active:=True;
end;
end;

// End User Setup
// Begin AntiBan

procedure AntiBan;
begin
if(not(LoggedIn))then Exit;
begin
case Random(100) of
10: RandomRClick;
25: HoverSkill('Mining', false);
30: PickUpMouse;
50: RandomMovement;
70: BoredHuman;
89: ExamineInv;
92: HoverSkill('Mining', false);
end;
end;
end;

// End AntiBan
// Begin Finding Copper

function FindCopper(var x, y : Integer) : Boolean;
var
a : Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS :Integer;
Box : TBox;
begin
if(not(LoggedIn))then Exit;
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.02, 0.83)

FindColorsSpiralTolerance(MSCX, MSCY, TPA,
3502798, MSX1, MSY1, MSX2, MSY2, 4);
SortTPAFrom(TPA, Point(MSCX, MSCY));
ATPA := TPAtoATPAEx(TPA, 15, 15);

for a := 0 to High(ATPA) do
begin
MP := MiddleTPA(ATPA[a]);
Box := IntToBox((MP.X - 20), (MP.Y - 20), (MP.X + 20), (MP.Y + 20));
{$IFDEF SMART8}
SMART_DrawBoxEx(True, True, Box, clYellow);
{$ENDIF}
MMouse(MP.X, MP.Y, 4, 4);
if(WaitUpText('Mine', 750))then
begin
x := MP.x; y := MP.y;
Result := True;
{$IFDEF SMART8}
SMART_ClearCanvas;
{$ENDIF}
Break;
end;
end;

ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;

// End Finding Copper
// Begin Mining Copper

procedure MineCopper;
var
x, y: Integer;
Box : TBox;
begin
if(not(LoggedIn))then Exit;
MakeCompass('N');
Box := IntToBox(MSCX - 10, MSCY - 25, MSCX + 15, MSCY + 15);
repeat
if(not(FindNormalRandoms))then
begin
if(FindCopper(x, y))then
begin
Wait(RandomRange(100, 450));
Mouse(x, y, 12, 12, mouse_Left)
Wait(RandomRange(100, 550));
while(Animating(Box, 750, 30))do
begin
AntiBan;
Wait(RandomRange(100,300));
end;
end else
Exit;
end;
until(InvFull or (not FindCopper(x, y)));
end;

// End Mining Copper
// Begin Find & Drop Copper

procedure FindAndDrop();
var
DTM, x, y : Integer;
TP : TPoint;
begin
DTM := DTMFromString('mPwEAAHic42dgYLAEYg0g1gdiIyA2B2I7IHYGYjcgdgViJyC2B2ILqBpDINYCYmsgtgViU6iYAZI5IDErqD4XIPYAYk8oG4Sv15gBSUYyMfmAXBux2AoACj0Iew==');
if(FindDTM(DTM, x, y, MIX1, MIY1, MIX2, MIY2))then
begin
Mouse(x, y, 7, 7, mouse_Right);
Wait(RandomRange(750, 900));
if(FindTextTPAEx(4231423, 0, MIX1, MIY1, MIX2, MIY2, TP.X, TP.Y,
'rop', StatChars, ClickLeft))then
Wait(RandomRange(750, 900));
begin
while(InvCount > 1)do
begin
AntiBan;
Wait(RandomRange(250, 500));
end;
end;
end;
FreeDTM(DTM);
end;

// End Find & Drop Copper
// Begin Main Loop Procedure

procedure MainLoop;
begin
SetAngle(SRL_ANGLE_HIGH);
repeat
FindCopper();
MineCopper();
FindAndDrop();
until(AllPlayersInactive);
end;

begin
{$IFDEF SMART8}
Smart_Server := 0;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ENDIF}
SetupSRL();
ClearDebug();
DeclarePlayers();
LoginPlayer();
MainLoop();
end.

jelknab

2013-05-06 09:51:17

The function you try to call is

function FindCopper(var x, y : Integer) : Boolean;

As you can see, the FindCopper function requires a X and Y parameter.

you could try:


procedure MainLoop;
var
X, Y : integer;
begin
SetAngle(SRL_ANGLE_HIGH);
repeat
FindCopper(X, Y);
MineCopper();
FindAndDrop();
until(AllPlayersInactive);
end;

Sk1nyNerd

2013-05-06 16:20:11

impressive syntax use for a first script! nice work

03storic

2013-05-08 05:19:42

Ok thanks that got it working but now it won't click the damn rocks, also the impressive syntax is taken from a beginner guide so it's not really mine.

t4q

2013-05-08 05:55:32

If you declare
x := MP.x; y := MP.y;
and use x and y in other procedure/function then x and y need to be global variables. May be I'am wrong but try adding this before //Begin User Setup:
var
x, y:integer;

And for middleTPA I use something like this:
if MiddleTPAEx(ATPA[a], x, y) then
begin
mmouse(x, y, 3, 3);
......