SRL Archive - OSR Help

Randomly click on coordinates.


KhiemTran

2013-02-02 06:11:36

Hi, how do I make Simba pick random coordinates from a set of coordinates.

Lets say if I have points (1,1) (2,2) (3,3) (4,4) (5,5).
How do I make the script pick randomly two coordinates out of the 5 and click on the coordinates?

Chris!

2013-02-02 06:20:50

You can use a case.

Basically what you'd do (roughly :s):

program Coords;
{$i SRL/srl.simba}

procedure RandomCoords; //Your procedure for clicking the random coords.
begin
case Random(50) of
1..10: ClickStuff; //Change "ClickStuff, ClickOtherStuff" etc.
11..20: ClickOtherStuff; //To your coordinate clicking code.
21..30: ClickMoreStuff; //Read this guide on cases: http://villavu.com/forum/showthread.php?t=53840
31..40: ClickEvenMoreStuff;
41..50: LetUsClickMoar;
end;
end;

begin
SetupSRL;
RandomCoords; //Using it in mainloop.
end.

You can implement that sort of thing into your script. If you need any more help, please post. :)

riwu

2013-02-02 06:32:06

r:= RandomRange(1, 6);
Mouse(r, r, 0, 0, mouse_Left);

OR

TPA:= [Point(1,1), ….];
rTP:= TPA[Random(Length(TPA))];
Mouse(rTP.x, rTP.y, 0, 0, mouse_Left);

Wardancer

2013-02-02 16:04:39

For the sake of it since I have 2 minutes to kill:

Mouse(TPA[Random(Length(TPA))].x, TPA[Random(Length(TPA))].y, 0, 0, mouse_Left);

(Just riwu's suggestion put on one line in case you dislike clarity in your scripts).

riwu

2013-02-02 20:24:33

From: Wardancer
For the sake of it since I have 2 minutes to kill:

Mouse(TPA[Random(Length(TPA))].x, TPA[Random(Length(TPA))].y, 0, 0, mouse_Left);

(Just riwu's suggestion put on one line in case you dislike clarity in your scripts).

You can't do that though, since a new number is generated when Random() is called, hence resulting in possibly different index of TPA for the x, y attributes. ;)
eg.
TPA[1].x, TPA[3].y
(unless you actually don't mind about x, y from different TPAs being mixed up)

Wardancer

2013-02-02 21:46:43

From: riwu
You can't do that though, since a new number is generated when Random() is called, hence resulting in possibly different index of TPA for the x, y attributes. ;)
eg.
TPA[1].x, TPA[3].y
(unless you actually don't mind about x, y from different TPAs being mixed up)


That's what I understood from the OP though when he asked for "two coordinates out of the 5 and click on the coordinates". Doesn't help with clarity when the same word is used for two different meanings in the same sentence though, haha.

KhiemTran

2013-02-03 10:00:22

Hi, thanks for the reply guys. I tested out the first random function. Not sure if it worked or not, most likely I messed up somewhere. At least it's running…

Here is my code, please feel free to modify it for me…

Procedure FightKnight;
var
x, y:Integer;
begin

if FindColorSpiral(x, y, 3274237, 257, 341, 345, 409) and
FindColorSpiral(x, y, 8215631, 445, 332, 517, 384) then
begin
MoveMouse(x, y);

case Random(50) of
1..10: ClickMouse(316, 584, 1); //Change "ClickStuff, ClickOtherStuff" etc.
11..20: ClickMouse(448, 598, 1); //To your coordinate clicking code.
21..30: ClickMouse(316, 584, 1); //Read this guide on cases: http://villavu.com/forum/showthread.php?t=53840
31..40: ClickMouse(448, 598, 1);
41..50: ClickMouse(316, 584, 1);
end;

wait(15000)
MoveMouse(385, 603);
wait(500)
ClickMouse(385, 603, 1);
end;
end;

Not even sure how to even use
 Mouse(TPA[Random(Length(TPA))].x, TPA[Random(Length(TPA))].y, 0, 0, mouse_Left);

The Killer

2013-02-03 10:43:09

Mouse(TPA[Random(Length(TPA))].x, TPA[Random(Length(TPA))].y, 0, 0, mouse_Left);

//wouldn't work as it would click on a mix of two tpa(s)


//this would click a random set of cords
TPA := [(0, 0), (1, 1), (2, 2), (3, 3), (4, 4), (5, 5)];
r := Random(Length(TPA));
Mouse(TPA[r].x, TPA[r].y, 0, 0 ,Mouse_Left);
edit: just noticed riwu posted pretty much the same thing. opps

Awkwardsaw

2013-02-03 10:52:09

I'm curious as to what you're using it for, maybe we could help you make something more efficient :)