SRL Archive - Research & Development Lounge

FindAndUse


Dumpin

2007-11-23 13:50:52

Little function I made because I was bored / trying to learn arrays better and better :)

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

{*************************}
{ FindAnd Use Function }
{* by: Dumpin *}
{Description:
Finds an Object and Uses it}
{*************************}

Function FindAndUse(Name : string; Color : TintegerArray; Tolerance: integer): boolean;
var
B,C, x, y, L : integer;
FoundC : boolean;
begin
For B := 0 To High(Color) Do
begin
L := High(Color);
For B := 0 To L Do
begin
if FindColorTolerance(x, y, Color[b], MIX1,MIY1, MIX2, MIY2, Tolerance) then
begin
FoundC := True;
Break;
end;
end;
if FoundC then
begin
mouse(x,y, 0, 0, False);
if IsUpText(Name) then
wait(100+ random(100));
ChooseOption('se');
C := C+1;
Result := true;
end;
end;
end;

begin
SetupSRL;
wait(2000);
FindAndUse('ey', [1410982], 10);
end.


Well basically It Finds / uses an Item in your inventory :P

Fill in a part of the item name / the color(s) / tolerance and voilá

FindAndUse('ey', [1477031], 10);

this can be edited for other options… do it if you want / PM me if you can't =D

n3ss3s

2007-11-23 15:25:36

Good job, to avoid doing GetArrayLength(Color) - 1 use

"For B := 0 To High(Color) Do"

Also, to make the loop faster, make a new integer type var, and do like

"L := High(Color);"

and then "For B := 0 To L Do"

That ways it doesn't have to count everytime ;)

Dumpin

2007-11-23 16:05:17

aahh nice :) updated it… can you tell me what High does?

Raskolnikov

2007-11-23 16:13:06

I like it :D, what if you did had there be a TStringArray like there is in FindObjCustom?

Dumpin

2007-11-23 16:14:42

From: cut em2 it
I like it :D, what if you did had there be a TStringArray like there is in FindObjCustom?


yea but I didn't want to for some way rofl… well of for today ill go to bed :)

Cya and post my topic full for tommorow =D

Santa_Clause

2007-11-23 16:49:29

Holy crap! Deja vu! I made something exactly like this, with exactly the same parameters…except it clicked on use, drop or wield then exited the procedure.

n3ss3s

2007-11-24 02:26:53

Lol….


Dumpin, High(ArrayHere) is basically same as "GetArrayLength(ArrayHere) - 1"

Dumpin

2007-11-24 03:15:20

From: n3ss3s
Lol….


Dumpin, High(ArrayHere) is basically same as "GetArrayLength(ArrayHere) - 1"


ok, but why should I use that instead of GetArrayLength?

n3ss3s

2007-11-24 03:44:32

a) The L := High or GetArrayLength - 1 and then For B := 0 To L Do

or

b) High?


A: a) Speed
A: b) Leet

Dumpin

2007-11-24 04:22:57

Ok :P got it ^^

Raskolnikov

2007-12-08 01:51:39

If you don't mind Dumpin I'm gonna use your function for an include gathering. I will include Credits!!!