SRL Archive - OSR Help

if statements


Ace257

2010-07-06 03:09:00

I have my script now i need more if statements, i was wondering if you put these at the beginning after you have found the dtm or when you move the mouse. Basically i need it to do if find then click integer A then repeat twice. if not then end, then find and click integer S, then find and click integer D, then F. then repeat the find S,D,F twice. then end then start if find and click Q then repeat twice, if not end, then find and click W, E, and R. If anyone could help this would be greatly appreciated. :)

//By:Ace257
Program Blacksmith;
{.Include SRL/SRL.scar}
Var
A, X, Y, S, D, F, Q, W, E, R:Integer;

Function FindDTMCustom(var A, X, Y:Integer): Boolean;
Begin
A := DTMFromString('78DA639466606050604001DFFB7918FE03694' +
'620FE0F048C52400633AA9A9FD39DC0342394CF68002414D1D494' +
'59A3AA0199638CAAE6479711AA1A564CF760A81101126204EC520' +
'212E204D42803090D026A40F6A8A1A9399684A20600913516A8');
Result := FindDTM(A, X, Y, MSX1, MSY1, MSX2, MSY2);
FreeDTM(A);
if not Result then
Begin
S := DTMFromString('78DA6334646060006124F073BA13986684F21' +
'98955A382A6A6CC1A558D161673D0D57001091654353FBA8C4857' +
'C382A906C3CDC4AA11C4EF66007B141176');
Result:=FindDTM(S, X, Y, MSX1, MSY1, MSX2, MSY2);
FreeDTM(S);
if not Result then
Begin
D := DTMFromString('78DA6394666060906140013F97BA826946289' +
'F511B4868A2AAF9B1468B74350640820555CDB7A742A4AB610312' +
'EC5450C30924B408B8991835A030D4450BC3326BD2D5480109563' +
'4BBBA8C50D4000004A01866');
Result:=FindDTM(D, X, Y, MSX1, MSY1, MSX2, MSY2);
FreeDTM(D);
if not Result then
Begin
F := DTMFromString('78DA6314626060906040013FBB6DC0342394C' +
'F488C1A4920218DAAE647BD21E96A40F688A2A9E9B1225D0D0FA6' +
'9AEFD53A986AD0DCF37DAA29E96A848104139A9A49DA987E4753F' +
'363B71DE96AE481040BAA9A6F138550D5F002096634F7E4C9A1AA' +
'61C334E7479612E96A40562BA3A58D525B1435000E251F40');
Result:=FindDTM(F, X, Y, MSX1, MSY1, MSX2, MSY2);
FreeDTM(F);
if not Result then
Begin
Q := DTMFromString('78DA6314616060906640015F73B919F881342' +
'394CF0852A38CAAE65B3F17440E590D139A9A6E6E5435202E3B9A' +
'9A6C347340F670A3A929E441510300EC0B083C');
Result := FindDTM(Q, X, Y, MSX1, MSY1, MSX2, MSY2);
FreeDTM(Q);
if not Result then
Begin
W := DTMFromString('78DA6314656060106640015F57B033F003694' +
'6289F510048F0A0A98985CAC1D480CC914155F36D8D32AA1A3E4C' +
'355F730550D5A86271CF5C66543520AE109A5D493CA86A2481040' +
'B9A9A1A6E143500E23D0BCA');
Result:=FindDTM(W, X, Y, MSX1, MSY1, MSX2, MSY2);
FreeDTM(W);
if not Result then
Begin
E := DTMFromString('78DA6314626060906640013F9A0DC1342394C' +
'F488C1A1120C189AAE6FB145554356240420055CDB77A61D2D548' +
'02093134BB0AA450D50802096E3473B2D851D5B001091E34735AB' +
'951D40000EECC0DB8');
Result:=FindDTM(E, X, Y, MSX1, MSY1, MSX2, MSY2);
FreeDTM(E);
if not Result then
Begin
R := DTMFromString('78DA6314656060E0664001DFEA99C1342394C' +
'FC8072444D0D414B190AE460C53CDD7995CA4AB01B9591A55CDF7' +
'896AA86A848084289A9A6A114C354A6876ED664355A30C24C4D1D' +
'49CE24555A3002464D0EC9AC44DB21A0071CB136A');
Result:=FindDTM(R, X, Y, MSX1, MSY1, MSX2, MSY2);
FreeDTM(R);
End;
End;
End;
End;
End;
End;
End;
End;
Begin
If FindDTMCustom(A, X, Y) Then
Begin
MoveMouseSmooth(X, Y);
Wait(1000+random(100));
ClickMouse(X, Y, True);
ClickMouse(X, Y, True);
End;
If FindDTMCustom(S, X, Y) Then
Begin
MoveMouseSmooth(X, Y);
Wait(1000+random(100));
ClickMouse(X, Y, True);
ClickMouse(X, Y, True);
End;
If FindDTMCustom(D, X, Y) Then
Begin
MoveMouseSmooth(X, Y);
Wait(1000+random(100));
ClickMouse(X, Y, True);
ClickMouse(X, Y, True);
End;
If FindDTMCustom(F, X, Y) Then
Begin
MoveMouseSmooth(X, Y);
Wait(1000+random(100));
ClickMouse(X, Y, True);
ClickMouse(X, Y, True);
End;
If FindDTMCustom(Q, X, Y) Then
Begin
MoveMouseSmooth(X, Y);
Wait(100+random(100));
ClickMouse(X, Y, True);
ClickMouse(X, Y, True);
End;
If FindDTMCustom(W, X, Y) Then
Begin
MoveMouseSmooth(X, Y);
Wait(100+random(100));
ClickMouse(X, Y, True);
ClickMouse(X, Y, True);
End;
If FindDTMCustom(E, X, Y) Then
Begin
MoveMouseSmooth(X, Y);
Wait(100+random(100));
ClickMouse(X, Y, True);
ClickMouse(X, Y, True);
End;
If FindDTMCustom(R, X, Y) Then
Begin
MoveMouseSmooth(X, Y);
Wait(100+random(100));
ClickMouse(X, Y, True);
ClickMouse(X, Y, True);
End;
End.

NCDS

2010-07-06 03:20:49

You use them correctly.
You may however be interested in if..then..else statements which work like this:

If FindDTMCustom(E, X, Y) Then
Begin
MoveMouseSmooth(X, Y);
Wait(100+random(100));
ClickMouse(X, Y, True);
ClickMouse(X, Y, True);
End // Notice no ';'
else
If FindDTMCustom(R, X, Y) Then
Begin
MoveMouseSmooth(X, Y);
Wait(100+random(100));
ClickMouse(X, Y, True);
ClickMouse(X, Y, True);
End;
That would only execute the code after the 'else' if the previous if..then statement returned false.

Also, you may want to break that up into functions. If your not sure what they are, go to the beginners section of tutorial island on the forums and read up on them. It wouldn't take long at all, they are simple.

This tutorial may help with explaining procedures and functions: http://villavu.com/forum/showthread.php?t=51210

It may help us help you if you can actually try and explain what you are doing with this?

Shuttleu

2010-07-06 03:34:59

just like NCDS said
what you have said is a bit confusing and vauge
if you can explain more detailed what you want us to do and (less importantly) what you want it to do

~shut

Ace257

2010-07-06 04:06:43

that was very helpful thanks! im still a little confused on the repeat procedure part in the tut though. So i just simply name the procedure and it repeats it? and say for instance i want to find these numbers not in any order, but jsut one of each. 1,2,3. could you give me an example on how to do this.

i luffs yeww

2010-07-06 04:11:54

To repeat something, you can do this.


var
i: Integer;
begin
repeat
Writeln(i);
Inc(i);
until(i > 4);
end.

That will output

0
1
2
3
4

:) Hope that helps.

Ace257

2010-07-06 04:58:06


That will output

0
1
2
3
4

:) Hope that helps.


thanks that helped out a lot!
i think i've got just about everything figured out! :)

masterBB

2010-07-06 11:51:59

wow, almost everything ^^ I guess we got a new SRL master here!

And use Mouse(..) instead of ClickMouse(..) And put a random wait between those clicks…

And you don't use var A in findDTMCustom…