SRL Archive - SRL Archives

DoGnomeObstacle ~~ Agility


Baked0420

2008-12-07 06:34:00

Tell me how this looks, it's my first attempt at making a function. Please don't flame, just tell me what you like, don't like, and how I can improve it.

(I haven't tested it yet, I don't know how good it'll work but I don't see why it wouldn't)

{*******************************************************************************
function DoGnomeObstacle(Color:TIntegerArray; Text:TStringArray; Tol, Pause:Integer): Boolean;
By: Baked0420
Description: It does the Gnome Agility Course, just put in the uptext under text,
the color of the obstacle under color, set the tolerance you want,
and how long you want it to wait after clicking an obstacle under
pause.
*******************************************************************************}
Function DoGnomeObstacle(Color:TIntegerArray; Text:TStringArray; Tol, Pause:Integer): Boolean;
begin
if(not(LoggedIn)) then Exit;
If(FindObjCustom(x, y, Text, Color, Tol)) then
begin
MMouse(x, y, 2, 2);
if(IsUpTextMultiCustom(Text)) then
begin
Mouse(x, y, 2, 2, True);
wait(Pause + random(500));
end;
end;
end;

Floor66

2008-12-07 06:41:31

Well.. Isn't it kind of. unnecessary?
It's just a FindObjCustom only it has clicking included :P
And, FindObjCustom already checks for UpText:


{*******************************************************************************
Function DoGnomeObstacle(Color : TIntegerArray; Text : TStringArray; Tol : Integer):
Boolean;
By: Baked0420
Description: It does the Gnome Agility Course, just put in the uptext under text,
the color of the obstacle under color, set the tolerance you want,
and how long you want it to wait after clicking an obstacle under
pause.
*******************************************************************************}

Function DoGnomeObstacle(Color : TIntegerArray; Text : TStringArray; Tol : Integer): Boolean;
Begin
If Not LoggedIn Then Exit;
If FindObjCustom(x, y, Text, Color, Tol) Then
Begin
Mouse(x, y, 2, 2, True);
Wait(Pause + random(500)); //Pause isnt set..?
End;
End;

Baked0420

2008-12-07 06:56:07

I know, I have checking for UpText again kind of as a failsafe to make sure it has the right thing moused over, so if it somehow messed up it won't click the wrong thing, but I suppose it's a little unnecessary, it just helps shorten your script a lot instead of using:


Begin
If Not LoggedIn Then Exit;
If FindObjCustom(x, y, Text, Color, Tol) Then
Begin
Mouse(x, y, 2, 2, True);
Wait(Pause + random(500));
End;
End;


that like 7 times for the Gnome Agility course, but with actually text, colors, and wait. It helps save time if you just have to write it once, and it saves lines of script so instead of it being say a 300 line script it may be like I don't know 250, it helps clean up the script a little in my opinion. I just made it for my agility script to help me save time and I figured I'd post it to see what people think of it. But thanks for the feedback, I'll try to add stuff to make it more useful.

EDIT: I copied my function you posted then saw the note after I posted it, wow thanks I totally forgot and never realized I didn't add pause, I'll add it into my first post, not something hard to add =P. Ok I added it in, and if you look, I had pause in the discription like where I write the function noted, but I didn't have it in the actual function lol, thanks for catching that for me.

Floor66

2008-12-07 07:07:46

And, when adding parameters to a function, each different type (integer, boolean, etc) has to be seperated with a semicolon ';'.
So:

Function Test(ThisIsAnInt, ThisToo : Integer; ButThisIsABool : Boolean): Boolean;

Baked0420

2008-12-07 07:17:38

oh thanks, like I said in my first post it is my first function, so I didn't know, thanks for telling me, I would've never fixed that. haha you make me feel like such a noob scripter, because I already made two stupid mistakes. I'll go fix that in my first post also now.

Floor66

2008-12-07 07:21:15

Your exactly what I was first :p
Dont worry

Baked0420

2008-12-07 07:24:39

haha well, I don't usually make my own functions for my scripts, so I guess it doesn't matter too much, because all my scripts worked that I made, or most anyway, and the reason I probably didn't catch those errors you did is because I made that function for my agility script, but I never put it into affect, I just wanted to make it so I could shorten it if I wanted, but for now, it's in my script noted, so it doesn't compile so it never told me any errors with it that i didn't catch.