SRL Archive - SRL Archives

polymorphism idea.. :)


Awkwardsaw

2009-12-01 20:33:36

after helping(i hope) ferocity, i came up with this simple little time saver/ ease maker :p


{*******************************************************************************
function mouseuptext(Arr : TVariantarray): boolean;
by: Awkwardsaw
Description: it will either move the mouse, move the mouse and check the uptext,
both + check the mouse, or just click the mouse depending on what
paramaters you fill in.
the first 4 elements are required! or the function is just useless
to use. the next element is true/ false. if you do not want to click
then leave it as a 0, or ''. if you do not want to check uptext,
do not fill in the next element :)
ex: mouseuptext([306, 280, 0, 0]); - just moves mouse
mouseuptext([306, 280, 0, 0, 0, 'ree']); - moves mouse, checks uptext
mouseuptext([306, 280, 0, 0, true, 'ree']); - checks uptext, clicks
mouseuptext([306, 280, 0, 0, false]); - just clicks
*******************************************************************************}
function mouseuptext(Arr : TVariantarray): boolean;
begin
mmouse(arr[0], arr[1], arr[2], arr[3]);
if high(arr) >= 5 then
if arr[5] <> null then
begin
result := waituptext(arr[5], 10);
if not result then exit;
end;
result := true;
if (high(arr) < 4) then exit;
if not VarType(Arr[4]) = 11 then
exit;
mouse(arr[0], arr[1], arr[2], arr[3], arr[4]);
end;

the descriptions should explain it enough :)

why you should use it:

begin
mousespeed := 15;
mouseuptext([x, y, 0, 0, true, 'ree']);
end.

is a lot better than

begin
mousespeed := 15;
mmouse(x, y, 0, 0);
if isuptext('ree') then
mouse(x, y, 0, 0, true);
end.

it is also faster.. :)

YoHoJo

2009-12-01 20:40:30

:D I like it, putting a bunch of commonly used together functions and procedures together for simplicity, woo woo.

Awkwardsaw

2009-12-01 20:42:30

From: YoHoJo
:D I like it, putting a bunch of commonly used together functions and procedures together for simplicity, woo woo.


well, that and its faster based off of my tests, and it "might" be easier for people to learn one function, than 3(possibly 4) :)

Ultra

2009-12-01 22:03:46

Wtf is point of the first function?

Awkwardsaw

2009-12-01 22:10:17

From: Ultra
Wtf is point of the first function?


i couldnt find a function that would do what i needed, and it would be to messy/ useless to add to the origional one. so i just made that separate :)

also, i'm trying to make it so it determins what type the variant is, instead of just checking if its a boolean :p

Sex

2009-12-01 22:36:40


function mouseuptext(Arr : TVariantarray): boolean;
begin
mmouse(arr[0], arr[1], arr[2], arr[3]);
if high(arr) >= 5 then
if arr[5] <> null then
begin
result := waituptext(arr[5], 10);
if not result then exit;
end;
result := true;
if (high(arr) < 4) then exit;
if not VarType(Arr[4]) = 11 then
exit;
mouse(arr[0], arr[1], arr[2], arr[3], arr[4]);
end;
1st function was useless..

marpis

2009-12-02 04:56:16

From: Awkwardsaw
i couldnt find a function that would do what i needed, and it would be to messy/ useless to add to the origional one. so i just made that separate :)

also, i'm trying to make it so it determins what type the variant is, instead of just checking if its a boolean :p


Just do this
If (VarType(MyVariable) = VarBoolean) Then

I don't remeber if it's Var_Boolean or VarBoolean though :rolleyes:
CTRL + Space helps!

Awkwardsaw

2009-12-02 08:10:51

From: marpis
Just do this
If (VarType(MyVariable) = VarBoolean) Then

I don't remeber if it's Var_Boolean or VarBoolean though :rolleyes:
CTRL + Space helps!


:duh:

i couldnt find that when i ctrl spaced, and ctrl f'd the manual :(

Coh3n

2009-12-02 21:32:35

Not bad, but to be honest, you made a long function that could be done in only a couple lines (as you showed in your first post). Could you explain to me how it's faster? I'm not saying it's not faster, I just don't see how it is. :smile:

Awkwardsaw

2009-12-02 22:38:34

From: Coh3n
Not bad, but to be honest, you made a long function that could be done in only a couple lines (as you showed in your first post). Could you explain to me how it's faster? I'm not saying it's not faster, I just don't see how it is. :smile:


i honestly have no idea how it is either, but its ~100 miliseconds faster when ever i tested, just try it out :)


marktime(t);
mouseuptext([x, y, 0, 0, true, 'ree']);
writeln(inttostr(timefrommark(t)));


marktime(t);
mmouse(x, y, 0, 0);
if isuptext('ree') then writeln('wat');
mouse(x, y, 0, 0, true);
writeln(inttostr(timefrommark(t)));

Coh3n

2009-12-02 23:56:32

Okay, I used this script to test both methods:

program New;
{.include srl/srl.scar}

function MouseUpText(Arr : TVariantarray): boolean;
begin
mmouse(arr[0], arr[1], arr[2], arr[3]);
if high(arr) >= 5 then
if arr[5] <> null then
begin
result := waituptext(arr[5], 10);
if not result then exit;
end;
result := true;
if (high(arr) < 4) then exit;
if not VarType(Arr[4]) = 11 then
exit;
mouse(arr[0], arr[1], arr[2], arr[3], arr[4]);
end;

var
x, y, Time, secondTime: Integer;
begin
SetupSRL;
ActivateClient;

x := 581; y := 226;

{MarkTime(Time);
MMouse(x, y, 4, 4);
if WaitUpText('ield', 10) then
Mouse(581, 226, 0, 0, False);
Writeln('Took: ' + IntToStr(TimeFromMark(Time)) + '.');}

MarkTime(secondTime);
MouseUpText([x, y, 4, 4, False, 'ield']);
Writeln('Took: ' + IntToStr(TimeFromMark(secondTime)) + '.');
end.
I tested each method six times to get averages of each. I came up with these numbers:
[PHP]
Using the current method:
905, 1092, 843, 983, 1046, 890
Average: 964.83.

Using your method:
905, 1170, 1248, 1185, 858, 1138
Average: 1084 exactly.
[/PHP]
I did six tests for each because doing one is pretty inaccurate. The MMouse procedure doesn't move the mouse at the same speed each time, thus causing some runs to be faster, and some to be slower. According to my testing, you're method is actually slower.

Now, I hate begin the guy that brings other people's work down, so I try by best not to. I'm not saying what you did was useless or anything like that because it's not. It can't be used to save a few lines of code throughout your script. It just didn't make sense to me that it would be faster. :smile:

Still, good work.

Coh3n

Dervish

2009-12-03 11:38:12

MouseUpText looks more pro *hint*

mixster

2009-12-03 11:59:16

The only problem is you need them specify it in the exact order else it will die. To make it more user friendly (ie no death if they do 'ree', False instead of False, 'ree'), the more complex the code, the slower it gets.

Nava2

2009-12-03 14:35:40

This is ugly, and not necessary. Sorry, I won't put this in.. someone else might but I think its overkill and not necessary for SRL.

The old way is faster, and more versatile. If someone wants to use this in their script thats great, but its not like people have to type this in everytime they click etc. The scripter does it once per click.

The idea for Polymorphism with SCAR would only work if we could somehow hack overloading into PascalScript, otherwise its a lot of uneeded and hard to understand code for those who are new.