SRL Archive - OSR Help

else Procedure


BigRedJapan

2013-05-19 15:31:19

Procedure Judge;
begin
FindJudge;
begin
TalkJudge;
end
else
begin
LogOut;
TerminateScript;
end;
end;

I have this peace of code and its giving me error. I want it to FindJudge, then talk if it doesnt log and terminate script.

Haxz

2013-05-19 15:53:16

Procedure Judge;
begin
FindJudge;
if not TalkJudge then
begin
LogOut;
TerminateScript;
end;
end;

BigRedJapan

2013-05-19 16:12:32

says mismatch! uhhh

The Mayor

2013-05-19 16:16:14

From: Rules of Joe
says mismatch! uhhh


Maybe TalkJudge is a procedure and not a Function which returns true/false. Would need to see your script.

Sin

2013-05-19 16:18:54

An else will only compile if there's an if statement preceding it.

So it should be 'if FindJudge then.. else..' etc.

BigRedJapan

2013-05-19 16:55:22

FindJudge is a procedure that I wrote!

Procedure FindJudge;
begin
SetAngle(1);
if FindObjCustom(X, Y, ['omp', 'tition', 'judge'], [judge1, judge2, judge3], 5)then
begin
MMouse(x, y, 3, 3);
if IsUpTextEx('udge')then
writeLn('Found Judge');
ClickMouse2(mouse_Left);
end;
end;

al4k

2013-05-19 17:12:18

You've written your script as if FindJudge is a boolean function.
Change it to this

Function FindJudge: Boolean;
begin
Result := False;
SetAngle(1);
if FindObjCustom(X, Y, ['omp', 'tition', 'judge'], [judge1, judge2, judge3], 5)then
begin
MMouse(x, y, 3, 3);
if IsUpTextEx('udge')then
begin
writeLn('Found Judge');
ClickMouse2(mouse_Left);
Result := True;
end;
end;
end;

You should also change TalkJudge in the same manner, as another failsafe

Also, put a wait between your MMouse and IsUpText, or use WaitUpText

The Mayor

2013-05-19 17:17:02

Procedure Judge;
begin
FindJudge;
if not TalkJudge then
begin
LogOut;
TerminateScript;
end;
end;


Basically what this is saying is:


if (TalkJudge = False) then
begin
Logout;
TerminateScript;
end;

But your TalkJudge procedure cannot return true or false as only functions can return results. For example, if you wanted to turn that FindJudge into a function you could go:

Function FindJudge: Boolean; // A boolean returns true or false.
begin
SetAngle(1);
if FindObjCustom(X, Y, ['omp', 'tition', 'judge'], [judge1, judge2, judge3], 5)then
begin
MMouse(x, y, 3, 3);
if IsUpTextEx('udge')then
writeLn('Found Judge');
ClickMouse2(mouse_Left);
Result := True; // If it finds & clicks the judge, result is true.
end;
end;



EDIT: Ninjed :ninja:

BigRedJapan

2013-05-19 17:25:19

Learned Something New! <3 :ninja:

Now it just skips over the code i wrote and goes straight to the equip arrows part!

The Mayor

2013-05-19 17:41:16

From: Rules of Joe
Learned Something New! <3 :ninja:



And another question are DTMs broken?

i get this error!

Exception in Script: The given DTM Index[0] doesn't exist
The following DTMs were not freed: [SRL - Book of Knowledge]


No DTMs work. I think that is just some SRL error that you get if you terminate your script?

BigRedJapan

2013-05-19 17:44:58

Iv added the code you offered me and changed the TalkJudge and now it just Skips over the find and talk part and goes right for the equip part of the code!

al4k

2013-05-19 17:58:46

Does it move the mouse at all? If not then the FindObj is returning false so you should double check that

BigRedJapan

2013-05-19 18:07:23

It doesnt move at all!

al4k

2013-05-19 18:15:32

hmm, if you post all the code causing the problem I'll read over it

BigRedJapan

2013-05-19 19:09:58

I am Using Alot of ibot_dung11 DTM and Colors! Which I will give my Respects to! But The reason why im rewritting this is because I need it to Solve Randoms and work with OSR not P07!

The Mayor

2013-05-19 19:34:07

You never told it to find the judge


Procedure Judge;
begin
if FindJudge then
if not TalkJudge then
begin
writeLn('Found judge but couldn''t talk');
Logout;
TerminateScript;
end;
end;

BigRedJapan

2013-05-19 23:55:56

Fixed!