SRL Archive - OSR Help

Shortening Code


Yanhua

2011-12-23 19:02:10

How can I make this piece of code shorter?



Function FindOre:Boolean;
Var
X, Y:Integer;
Begin
SetAngle(False);
If Not Invfull Then Begin
MakeCompass('40');
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

If Not Invfull Then Begin
MakeCompass('80');
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

If Not Invfull Then Begin
MakeCompass('120');
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

If Not Invfull Then Begin
MakeCompass('160');
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

If Not Invfull Then Begin
MakeCompass('200');
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

If Not Invfull Then Begin
MakeCompass('240');
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

If Not Invfull Then Begin
MakeCompass('280');
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

If Not Invfull Then Begin
MakeCompass('320');
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

If Not Invfull Then Begin
MakeCompass('360');
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

end;

I've tried this, but it doesn't seem to work.

Function FindOre:Boolean;
Var
X, Y, T:Integer;
Begin
SetAngle(False);

Repeat

If Not Invfull Then Begin
MakeCompass('T');
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

IncEx(T, +40);

Until(InvFull);



end;

Dynamite

2011-12-23 19:08:40

Try:

Function FindOre:Boolean;
Var
X, Y, T:Integer;
Begin
SetAngle(False);
T := 40;
Repeat

If Not Invfull Then Begin
MakeCompass(T);
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

IncEx(T, +40);

Until(InvFull);



end;

Yanhua

2011-12-23 19:13:18

From: Dynamite
Try:

Function FindOre:Boolean;
Var
X, Y, T:Integer;
Begin
SetAngle(False);
T := 40;
Repeat

If Not Invfull Then Begin
MakeCompass(T);
If FindObjCustom(X, Y, ['ssen'], [8750732, 11579576, 1243514, 8224130], 2) Then
Begin
writeln('Found ore!')
Result := True;
MMouse(X, Y, 3, 3);
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Wait(500+randomrange(200,300));
If ChooseOption('Mine Rune Essence') Then
Result := True;
while (Not InvFull)
Do
wait(100+randomrange(50,70));
end;
Wait(500+randomrange(200,500));
end;

IncEx(T, +40);

Until(InvFull);



end;


Excellent. That's what I was missing. Thank you Sir. :D