SRL Archive - Jr. Member General Help and Discussion

If command help in lape


BigRedJapan

2015-05-09 15:17:10

Want to use this but its not allowing me

  if InArea(2672, 3421, 2670, 3416) && areTalking = True then 

Hoodz

2015-05-09 15:25:49

From: Rules of Joe
Want to use this but its not allowing me

  if InArea(2672, 3421, 2670, 3416) && areTalking = True then 


&& is java (and maybe some more languages), lape: and
 if (inArea(2672, 3421, 2670, 3417) and areTalking) then

but if you use reflection lape then it needs some addition code

edit: then it would be this:

if (Reflect.Tiles.InPolygon([point(2672, 3421), point(2670, 3417)]) and areTalking) then

KeepBotting

2015-05-09 15:29:10

The logical operator && in Java is equivalent to and in PascalScript/Lape.

E: Had this page loaded previously, didn't see hoodz's post :redface:

Turpinator

2015-05-09 19:21:27

Also, to ensure theres no issue with the logic, its best to wrap each logical comparison in parentheses (or brackets for you UK folks).

Soo…
if (condition1 and (var1 = 6)) then...
Also…
The usage of "areTalking = true" is redundant.
If areTalking returns true, you get (true = true) => true.
If areTalking returns false, you get (false = true) => false.

Other languages and when learning emphasis doing 'if SomeBool == true then', but it is really just redundant.

Twinki

2015-05-09 20:40:40

From: Turpinator
Also, to ensure theres no issue with the logic, its best to wrap each logical comparison in parentheses (or brackets for you UK folks).

Soo…
if (condition1 and (var1 = 6)) then...
Also…
The usage of "areTalking = true" is redundant.
If areTalking returns true, you get (true = true) => true.
If areTalking returns false, you get (false = true) => false.

Other languages and when learning emphasis doing 'if SomeBool == true then', but it is really just redundant.


That's what I've made a habit of doing


if (isWalking) and (isClicked) then

if not(isWalking) then

if (isWalking) or (isClicked) then

BigRedJapan

2015-05-09 20:48:56

I messed around with the loop but it doesnt run just stands doing nothing

Procedure Loop;
begin
if InArea(2668, 3420, 2673, 3417) then
begin
WriteLn('At Location, in square, May start script');
FindJudge;
WriteLn('Found Judge');
exit;
end ;
if (Reflect.Tiles.InPolygon([point(2672, 3421), point(2670, 3417)]) and areTalking) then
begin
if AlreadyinGame = true then
begin
ShootingArrow;
end;
exit;
end else
if AlreadyinGame = False then
begin
ChatJudge;
exit
end;
if getInvCount = +3 then
begin
EquipArrows;
exit;
end;
if (getInvCount = +2) and (AlreadyinGame = True) then
begin
ShootingArrow;
exit;
end;
end;

KeepBotting

2015-05-09 20:49:36

From: Twinki
That's what I've made a habit of doing


if (isWalking) and (isClicked) then

if not(isWalking) then

if (isWalking) or (isClicked) then

Lolol, I'm even more so

if (not(isLoggedIn())) then

:D

iEatApplez

2015-05-09 23:36:17

From: KeepBotting
Lolol, I'm even more so

if (not(isLoggedIn())) then

:D



repeat
wait(50);
until((Time.ElapsedTime > 5000) or (not(atLocation('thingy'))));

Love them.

iEatApplez

2015-05-09 23:46:36

From: Rules of Joe
I messed around with the loop but it doesnt run just stands doing nothing


Not sure about this but maybe it's because you're searching in an area between 2 tiles.
Reflect.Tiles.InPolygon finds all TTiles given and checks all the tiles in between. Try using 3 or 4 tiles, it'll make it much easier to find your character.

2nd, you have several 'Exit's in your loop.
I wrote some comments in the script.

From: Rules of Joe

Procedure Loop;
begin
if InArea(2668, 3420, 2673, 3417) then
begin
WriteLn('At Location, in square, May start script');
FindJudge;
WriteLn('Found Judge');
exit; //After an Exit; the script will exit the procedure or function.
end ;
if (Reflect.Tiles.InPolygon([point(2672, 3421), point(2670, 3417)]) and areTalking) then
begin //IMPORTANT: It won't run this, because it exits if it's in this area
if AlreadyinGame = true then
begin
ShootingArrow; //Nor this
end;
exit;
end else
if AlreadyinGame = False then
begin
ChatJudge;
exit
end; //Nor this...
if getInvCount = +3 then
begin
EquipArrows;
exit;
end;
if (getInvCount = +2) and (AlreadyinGame = True) then
begin
ShootingArrow; //You know it by now. Remove your Exits, only use them if you really need to
exit; //Exit your procedures/functions
end;
end;

rj

2015-05-10 00:47:46

From: Rules of Joe
I messed around with the loop but it doesnt run just stands doing nothing

Procedure Loop;
begin
if InArea(2668, 3420, 2673, 3417) then
begin
WriteLn('At Location, in square, May start script');
FindJudge;
WriteLn('Found Judge');
exit;
end ;
if (Reflect.Tiles.InPolygon([point(2672, 3421), point(2670, 3417)]) and areTalking) then
begin
if AlreadyinGame = true then
begin
ShootingArrow;
end;
exit;
end else
if AlreadyinGame = False then
begin
ChatJudge;
exit
end;
if getInvCount = +3 then
begin
EquipArrows;
exit;
end;
if (getInvCount = +2) and (AlreadyinGame = True) then
begin
ShootingArrow;
exit;
end;
end;


ehh why put + before the integer, it's implied that it's positive unless stated otherwise. Anyway I fixed a couple standards and removed the exit that is probably causing the issue:

Procedure Loop;
begin
if (InArea(2668, 3420, 2673, 3417)) then
begin
WriteLn('At Location, in square, May start script');
FindJudge; // might want to check if the judge was found, it will print found judge no matter what
WriteLn('Found Judge');
exit;
end ;
if (Reflect.Tiles.InPolygon([point(2672, 3421), point(2670, 3417)]) and areTalking) then
begin
if (AlreadyinGame = true) then
ShootingArrow;
//exit; this will exit if AlreadyInGame is false and the code below wont be reached
end else
if (AlreadyinGame = False) then
begin
ChatJudge;
exit;
end;
if (getInvCount = 3) then
begin
EquipArrows;
exit;
end;
if ((getInvCount = 2) and (AlreadyinGame = True)) then
begin
ShootingArrow;
exit;
end;
end;

Turpinator

2015-05-10 01:31:00

From: iEatApplez
Not sure about this but maybe it's because you're searching in an area between 2 tiles.
Reflect.Tiles.InPolygon finds all TTiles given and checks all the tiles in between. Try using 3 or 4 tiles, it'll make it much easier to find your character.

2nd, you have several 'Exit's in your loop.
I wrote some comments in the script.


He probably wants to just use
PointInBox(Reflect.Tiles.GetGlobalTile, IntToBox(2672, 3421, 2670, 3417))
or something.