SRL Archive - OSR Help

Error in Function


SamSatanas

2012-03-24 14:59:51

I am trying to learn how to script, I had this simple script working before my pc crashed and I can't seeme to find the problem. Not using SMART, using browser rs


program PowerChoper;
//{$DEFINE SMART}
{$i SRL\SRL.simba}

Const
BreakEvery= 120; // How many minutes to break after.
BreakFor= '5'; // How long to break for.

Function Woodcutter;
Var
x, y:Integer;
Begin
//FindObjCustom(x, y, ['att', 'ack'], [123456, 345678], 5;
If FindObjCustom(x, y, ['Chop', 'down', 'p d'], [725522, 988951, 2043700, 1384222], 30) Then
WriteLn('Found Tree');
End;
begin
SetupSRL:
Smart_Members := False;
Smart_Server := 0;
Smart_Signed := True;
Smart_SuperDetail := False;
Woodcutter;
end.

Ashaman88

2012-03-24 15:01:07

take out the other smart junk as well

NKN

2012-03-24 15:08:30

Take out SMART stuff, drag the crosshairs over your runescape browser.
And here.
Function Woodcutter;
Var
x, y:Integer;
Begin
//FindObjCustom(x, y, ['att', 'ack'], [123456, 345678], 5;
If FindObjCustom(x, y, ['Chop', 'down', 'p d'], [725522, 988951, 2043700, 1384222], 30) Then
WriteLn('Found Tree');
End;

You have it set to a function, so you need to assign it a type of variable.
For you, you want it like this.
Procedure Woodcutter;
Var
x, y:Integer;
Begin
//FindObjCustom(x, y, ['att', 'ack'], [123456, 345678], 5;
If FindObjCustom(x, y, ['Chop', 'down', 'p d'], [725522, 988951, 2043700, 1384222], 30) Then
WriteLn('Found Tree');
End;

That way, as a procedure, you don't have to set it to something like: Function Woodcutter: Boolean;.

SamSatanas

2012-03-24 15:11:38

wow, thanks. It works. Am I getting Function and Procedure mixed up then?

NKN

2012-03-24 15:22:01

Yeah.
A function should be like this:

function Namehere:TypeOfVariable;
The variable can be: Integer,String,Boolean, and others.
A procedure is like this:

Procedure Namehere;

Sex

2012-03-24 15:36:00

Instead of making it a procedure, you should make it a function that returns a boolean. You should do this whenever you can so that you can check if it was successful finding the tree.

Your procedure in function form:
 
function Woodcutter : boolean;
begin
result := FindObjCustom(x, y, ['Chop', 'down', 'p d'], [725522, 988951, 2043700, 1384222], 30);
if result then
WriteLn('Found Tree');
end;
Etc.