SRL Archive - OSR Help

whats wrong with me 'if' statements?


Paradoxium

2012-01-30 21:12:32

What is wrong with my if statements?


begin
repeat
if (not(MinethatOtherjoint)); and
(not(Minethatjoint)); then
Writeln('Couldnt find that purp lls');
until InvFull;
end.

Brandon

2012-01-30 21:17:25

Your semi-colons..

Paradoxium

2012-01-30 21:28:08

i put them inside and now it gives me a parenthesis error… btw if hows ur itemfinding function coming along? i want to do a waterfiends bot but with cockroach soldiers lol

NickMystre

2012-01-30 21:28:28

From: lordofballss
What is wrong with my if statements?


Change this …

begin
repeat
if (not(MinethatOtherjoint)); and
(not(Minethatjoint)); then
Writeln('Couldnt find that purp lls');
until InvFull;
end.

… to this

begin
repeat
if (not MinethatOtherjoint) and (not Minethatjoint) then
Writeln('Couldnt find that purp lls');
until InvFull
end.

Paradoxium

2012-01-30 21:31:12

thanks! im getting a type mismatch error though..Imma see if i can figure it out myself :D

PatDuffy

2012-01-30 21:35:48

your probably trying to use a procedure as a function

NickMystre

2012-01-30 21:39:15

Post your code

Rezozo

2012-01-30 21:52:14

http://www.aspisfun.com/errors/typemismatch.html

Probably this, check it out.

Paradoxium

2012-01-31 07:30:28

here it is….

program Script;
{$DEFINE SMART}
{$i SRL\SRL.simba}
{$i ObjectDTM\ObjDTMInclude.simba}

procedure DeclarePlayers;
begin

HowManyPlayers := 1;
CurrentPlayer := 0;
SetLength(Players, HowManyPlayers);

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



procedure Minethatjoint; //Mines right rock
var
MyTPA : TPointArray;
MyPoint : TPoint;
x, y, i : Integer;

begin
FindColorsTolerance(MyTPA, 9209708, 388, 142, 424, 175, 10);
if Length(MyTPA) = 0 then FindColorsTolerance(MyTPA, 11446662, MSX1, MSY1, MSX2, MSY2, 10);
for i := 0 to High(MyTPA)do
begin
MyPoint := MyTPA[i]
MMouse (MyPoint.x, MyPoint.y, 3, 3);
if (IsUpTextMultiCustom(['ine'])) then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, 1);
Wait(500+random(250));
Exit;
end;
Wait(350+random(350));
end;
end;


procedure MinethatOtherjoint; //Mines left rock
var
MyTPA : TPointArray;
MyPoint : TPoint;
x, y, i : Integer;

begin
FindColorsTolerance(MyTPA, 15327132, 248, 201, 274, 227, 10);
if Length(MyTPA) = 0 then
FindColorsTolerance(MyTPA, 9801842, 248, 201, 274, 227, 10);
for i := 0 to High(MyTPA)do
begin
MyPoint := MyTPA[i]
MMouse (MyPoint.x, MyPoint.y, 3, 3);
if (IsUpTextMultiCustom(['ine'])) then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, 1);
Wait(500+random(250));
Exit;
end;
Wait(350+random(350));
end;
end;



begin

Smart_Server := 10;
Smart_Members := True;
Smart_Signed := True;
SetupSRL;
//ObjDTM_Setup;
DeclarePlayers;
begin
repeat
if (not MinethatOtherjoint) and (not Minethatjoint) then
Writeln('Couldnt find that purp lls');
until InvFull;
end;
end.

NickMystre

2012-01-31 07:47:39

This is the error you get …

[Error] (86:56): Type mismatch at line 85
Compiling failed.


What this means is that you have coded one variable type and then try to use it as another ie trying to use a boolean as an integer. PatDuffy actually gave you the answer a few posts back, and so did joeygupta.

You need to change these two procedures to functions that return a boolean.

This …
procedure Minethatjoint;
procedure MinethatOtherjoint;


… to this!
function Minethatjoint:boolean;
function MinethatOtherjoint:boolean;


Also in each function you need to set 'Result' to either true or false. 'Result' allocates if you will the answer of true or false to the name of the function. So that when you use this piece of code (below) - it will then work for you.

See the trivial function code below to illustrate …

function EqualsOne:boolean;
var
x:Integer;
begin
if x = 1 then
Result := True
else
Result := False
end;

Then a statement like this will have meaning and be correct …

... other code ...

if EqualsOne then // ie If EqualsOne is true then do.
...
else
...
end;

Rezozo

2012-01-31 20:57:29

From: NickMystre
This is the error you get …



What this means is that you have coded one variable type and then try to use it as another ie trying to use a boolean as an integer. PatDuffy actually gave you the answer a few posts back, and so did joeygupta.

You need to change these two procedures to functions that return a boolean.

This …
procedure Minethatjoint;
procedure MinethatOtherjoint;


… to this!
function Minethatjoint:boolean;
function MinethatOtherjoint:boolean;


Also in each function you need to set 'Result' to either true or false. 'Result' allocates if you will the answer of true or false to the name of the function. So that when you use this piece of code (below) - it will then work for you.

See the trivial function code below to illustrate …

function EqualsOne:boolean;
var
x:Integer;
begin
if x = 1 then
Result := True
else
Result := False
end;

Then a statement like this will have meaning and be correct …

... other code ...

if EqualsOne then // ie If EqualsOne is true then do.
...
else
...
end;

Thank You NickMystre, I did not have time to write a complete reply, (My Birthday party!), so I only gave a link.

Paradoxium

2012-01-31 23:54:21

thanks guys! i sort of understand now. happy belated birthday joeygupta! ima test it and see how it works out thanks again!

NickMystre

2012-02-01 00:03:26

From: joeygupta
Thank You NickMystre, I did not have time to write a complete reply, (My Birthday party!), so I only gave a link.


No worries. I hope that you had a ripper of a party. :)

Rezozo

2012-02-02 19:18:42

From: lordofballss
thanks guys! i sort of understand now. happy belated birthday joeygupta! ima test it and see how it works out thanks again!


Thx Yo.



From: NickMystre
No worries. I hope that you had a ripper of a party. :)


Thank you as well!

Brandon

2012-02-02 19:20:48

Instead of doing:

If X = 1 then
Result….

Do:

Result:= (X = 1);

Much cleaner.