Functions can return something. Let's take a common function for an example: Random(). Random generates a number between 0 and whatever integer you feed into it. the number it generates is the result of the function random.
In runescape script, functions that return booleans are commonly used to tell if something worked or not. At the end of the function, some other function of some sort is called to tell if the function carried out properly.
Let's look at the OpenTheBank function from my cooker as an example:
Simba Code:
function OpenTheBank: Boolean;
var
CTS, H, x, y, i: Integer;
TPA: TPointArray;
ATPA: Array of TpointArray;
begin
Result := False;
R_FindRandoms;
if not(LoggedIn) then
Exit;
if BankScreen then
begin
Result := True;
Exit;
end;
CTS := GetColorToleranceSpeed;
SetColorToleranceSpeed(2);
SetColorspeed2Modifiers(0.027, 0.031);
FindColorsTolerance(TPA, 3817283, MSX1, MSY1, MSX2, MSY2, 14);
SetColorToleranceSpeed(CTS);
if (Length(TPA) < 1) then
begin
Logout;
Exit;
end;
ATPA := TPAtoATPAEx(TPA, 35, 35);
SortATPAFromFirstPoint(ATPA, IntToPoint(MSCX, MSCY));
if ShowDebugging then
DebugATPABounds(ATPA);
H := Length(ATPA);
for i := 0 to H do
begin
MiddleTPAEx(ATPA[i], x, y);
MMouse(x, y, 4, 4);
if WaitUptext('ank booth', 800) then
begin
ClickMouse2(False);
Result := WaitOption('quickly', 800);
end;
if (Result or BankScreen) then
Break;
end;
FFlag(0);
Result := WaitFunc(@BankScreen, 20 + Random(25), 5000);
Wait(600 + Random(60));
end;
See how on the second to last line, i call "Result := "SOMETHING""? WaitFunc is a function in SRL that calls the function (Defined like @Function) ever x number of seconds (the 2nd parameter) over and over until it either returns true or the total time is longer than the 3rd parameter (in ms). If it finds the Bank screen to be open, then the result is true.
If the result is true, i know i can continue on with my script. However, if it returns false, i know that something went wrong, so the player needs to be logged out.
Catch my drift?