SRL Archive - OSR Help

Not Sure How To Loop This?


g ked

2014-04-03 22:35:33

Hey, i'm somewhat of a noob, anyways, this bot is very very basic, clicks the ore, and empties my inventory, now I just can't seem to get this loop down, what i'm having the bot do is check for ore in the last inventory spot so it knows when i have a full inventory.

program Mcoal;
{$i srl/srl.simba}
var
X,Y:Integer;

Procedure MineCoal;
begin
if FindColorTolerance(X, Y, 2306876, 127, 122, 367, 282, 5) then
begin
mmouse(x, y,1,1);
wait(250);
ClickMouse(X, Y, mouse_Left)
wait (5000);
end;
end;

Procedure Empty;
begin
if FindColorTolerance (X, Y, 2636860, 684, 426, 734, 465, 5) then
begin
TypeSend('::empty');
wait (250);
mmouse (x, y, 252, 391);
wait (250);
ClickMouse (X, Y, mouse_Left)
end;
begin
if (not(FindColorTolerance (X, Y, 2636860, 684, 426, 734, 465, 5))) then
begin
end;
end;
end;


Procedure Wait4;
begin
wait (1000);
end;

begin
MouseSpeed := 15;
SetupSRL;
MineCoal;
Empty;
Wait4;
end.

Flight

2014-04-03 23:00:41

Untested, infact not even compiled (because I don't have that include):


program Mcoal;
{$i srl/srl.simba}

function isInvFull(): Boolean;
var
X,Y : Integer;
begin
result := findColorTolerance(X, Y, 2636860, 684, 426, 734, 465, 5);
end;

procedure MineCoal();
var
X,Y : Integer;
begin
if FindColorTolerance(X, Y, 2306876, 127, 122, 367, 282, 5) then
begin
mmouse(x, y, 1, 1);
wait(250);
ClickMouse(X, Y, mouse_Left)
wait(5000);
end;
end;

procedure Empty();
var
X,Y : Integer;
begin
if FindColorTolerance(X, Y, 2636860, 684, 426, 734, 465, 5) then
begin
TypeSend('::empty');
wait(250);
mmouse(x, y, 252, 391);
wait(250);
ClickMouse(X, Y, mouse_Left)
end;
end;

begin
SetupSRL;
MouseSpeed := 15;

Repeat
if not isInvFull() then
MineCoal
else
Empty;
wait(1000);
Until(False); //Infinite loop
end.

g ked

2014-04-03 23:33:07

However can I thank you?

Flight

2014-04-03 23:36:32

No need to at all, just continue working and experimenting. :tongue:

g ked

2014-04-03 23:47:29

From: Flight
No need to at all, just continue working and experimenting. :tongue:


So I just so happened to make this bot, a little more complicated, I decided to try and add a Bitmap. I've used bitmaps before but for some reason this one is being very weird. Could you take a look?

program Mcoal;
{$i srl/srl.simba}

function isInvFull(): Boolean;
var
Clickyes, X,Y : Integer;
begin
result := findColorTolerance(X, Y, 2636860, 684, 426, 734, 465, 5);
end;

procedure MineCoal();
var
X,Y : Integer;
begin
if FindColorTolerance(X, Y, 2306876, 127, 122, 367, 282, 5) then
begin
mmouse(x, y, 1, 1);
wait(250);
ClickMouse(X, Y, mouse_Left)
wait(5000);
end;
end;

procedure Empty();
var
Clickyes, X,Y : Integer;
begin
if FindColorTolerance(X, Y, 2636860, 684, 426, 734, 465, 5) then
begin
TypeSend('::empty');
wait(250);
if FindBitmapToleranceIn(Clickyes, X, Y, 165, 383, 327, 454, 145) then
begin
mmouse(x, y,1,1);
wait(250);
ClickMouse(X, Y, mouse_Left)
end;
end;
end;

begin
SetupSRL;
Clickyes := BitmapFromString(25, 11, 'meJyFUUEOwjAM6/8fwYUcgH+AKs' +
'oHxnboUwh4WG7aalM0ZZ3tOo7l9frcUkr+RqG3vHrdXtVKRW8/JHs' +
'tp+Cv49E7q5EqdZf6qx1KDV2BNeP2Uqf8tsmA7PEEYjgcugKmt6eH' +
'SqcTSlEksKijWX0/S7MOADxYqqkCd6GDcB27WptYsKeD06eGz133M' +
'A1Zowixa0R6xTDekElfs/OA0XvP94UTEXN5LIciH2nf7Vc=');
MouseSpeed := 15;

Repeat
if not isInvFull() then
MineCoal
else
Empty;
wait(1000);
Until(False); //Infinite loop
freebitmap (Yess);
end.


[Error] C:\Simba\Scripts\Mcoal.simba(44:3): Unknown identifier 'Clickyes' at line 44
Compiling failed.



The one you posted above would work just fine, but when it goes to click yes, or mmouse right here:

procedure Empty();
var
X,Y : Integer;
begin
TypeSend('::empty');
wait(300);
mmouse (x,y,260,402);
wait(250);
ClickMouse(X, Y, mouse_Left)
end;

it randomly clicks around the screen :/

Flight

2014-04-04 02:41:24

From: g ked

The one you posted above would work just fine, but when it goes to click yes, or mmouse right here:

procedure Empty();
var
X,Y : Integer;
begin
TypeSend('::empty');
wait(300);
mmouse (x,y,260,402);
wait(250);
ClickMouse(X, Y, mouse_Left)
end;

it randomly clicks around the screen :/


In this procedure where do you want the mouse to click?

In this line:

mmouse (x,y,260,402)
the mouse will be moved to the X coordinate of "x" (which is default set to 0), same with "y". The 260 is a randomness of -260 - +260 to give to the X coordinate, and the 402 is the randomness to give to the Y coordinate. The parameters of the "mmouse" procedure is: 'Procedure MMouse(X_Coordinate, Y_Coordinate, X_Randomness, Y_Randomness);'.

Also, the procedure 'ClickMouse' will click at the X/Y coordinate you feed it, and again here you fed it undefined values (0 and 0) so it will left-click at the coordinate (0,0). I strongly recommend you use "clickMouse2(MOUSE_LEFT);" which will left-click at where ever the current position of the mouse is.

I hope that helps you not only fix the problem but understand why it happened in the first place.

g ked

2014-04-04 20:37:45

Come to think of it, that helps alot that you explained that, i thought the two numbers i was inputting were where it would click, thanks alot Flight!