SRL Archive - SRL Archives

ChooseOptionNumber(option: Integer): Boolean;


JAD

2009-08-15 02:03:30


{*******************************************************************************
Procedure ChooseOptionNumber(option: Integer): Boolean;
by: JAD
Description: Chooses option based off of coordinates for less lag.
Option 1 = upper most option, option 2 = one below that, and so on.
*******************************************************************************}
function ChooseOptionNumber(option: Integer): Boolean;
var
x,y,mx,my, i, t: Integer;
begin
if(not(LoggedIn))then
Exit;
GetMousePos(x,y);
my := yy + 25 + random(7); //28 = perfect center
mx := xx + random(37);
if(not(option = 1))then
for i := 2 to option do
my := my + 15;
MMouse(mx,my,0,0);
MarkTime(t);
repeat
wait(50+random(40));
if(FindColor(mx,my,6121839,mx-25,my,mx+25,my+2))then
begin
Result := true;
GetMousePos(mx,my);
Mouse(mx,my,0,0,true);
wait(40+random(60));
Exit;
end;
until(TimeFromMark(t) > 1500+random(900));
Result := false;
end;


ChooseOption causes me a good amount of lag on more occasions than one. This just does it by which ever option number for minimal lag and maximum speed.

marpis

2009-08-15 02:17:52

I think you should make it use just one parameter 'option'.
I think it's the text TPA that causes lag, so you could add there the optionbox finding, and then the rest would be easy maths. Very good idea tho'! rep+++

JAD

2009-08-15 02:25:09

From: marpis
I think you should make it use just one parameter 'option'.
I think it's the text TPA that causes lag, so you could add there the optionbox finding, and then the rest would be easy maths. Very good idea tho'! rep+++


Well right now it bases where the options are at by where the mouse right clicks. I could change it so that it just bases it off of the top of the option box, but searching for the option box might still be the cause of some of the lag though.

Edit: Took out x,y to just use a GetMousePos. If you are calling ChooseOption then it's probably called right after right clicking the spot.

3Garrett3

2009-08-15 02:55:44

So this is just an easier version without lag for choosing an option? Can I steal it (credits of course) for use in my smelter?

JAD

2009-08-15 06:54:25

From: 3Garrett3
So this is just an easier version without lag for choosing an option? Can I steal it (credits of course) for use in my smelter?


Of course. It just chooses the option without needing to look for anything (text tpa, option menu…etc.). It does make sure that it is at the option menu though by looking for the lit up color it makes when you hover an option on the menu. It just chooses the option based off of the coordinates of where you right clicked at (with a good amount of randomness).

3Garrett3

2009-08-15 06:56:50

I'm assuming option 2 is "5" and 3 is "10" and 4 is the last typed and 5 is "x"

Or are they real numbers, or what?

JAD

2009-08-15 06:58:50

From: 3Garrett3
I'm assuming option 2 is "5" and 3 is "10" and 4 is the last typed and 5 is "x"

Or are they real numbers, or what?


I guess I should have one of those

{*********************

things in there. It counts from the top. The top most option is 1, the one below that is 2…etc.

I'll edit comments into the function.

Gu3st...

2009-08-15 11:41:28

From: JAD
I guess I should have one of those

{*********************

things in there. It counts from the top. The top most option is 1, the one below that is 2…etc.

I'll edit comments into the function.

So if I right click a willow log then it would be
1 - Use
2 - Drop
3 - Examine
4 - Cancel

??

ian.

2009-08-15 14:13:42

From: Zyt3x
So if I right click a willow log then it would be
1 - Use
2 - Drop
3 - Examine
4 - Cancel

??


That's what it seems like.

JAD

2009-08-15 19:15:19

From: Nava2
This won't go in SRL, sorry bud.

Its too risky, and bad practice in a lot of cases.

What is slow is ReturnPointsNotInTPA. Just so you know :)


I really don't see how it's too risky. I've been using in my scripts that have run for hours at a time manually stopped (scripts that work in the bank like my fletcher, and one I'm working on that walks).

It also may seem like it's risky in situations like right clicking a bank booth and using it or something (because you might have right clicked players as well), but the option to use-quickly is 2 all the time, no matter how many options. I use it in my custom bank opener without problems. Even if you were cutting a tree, chop would always be the first option, no matter how many there were.

I have seen the script lag at the exact time the script right clicked too. It is very fast in this instance because it right clicks, moves the mouse to the designated option, waits until the color of the option high light pops up (once lag is over), and then clicks right away.


That's ok though, I don't care if it's committed or not. I just don't want people thinking it's risky so people can use it in their scripts.




@Zytex, yes, that is how it works.

HyperSecret

2009-08-15 19:47:56

I only use it in withdrawing from the bank. The bank withdraw text with ChooseOption/WaitOption in the bank is always what takes like 3-5 seconds to respond to and click…