SRL Archive - Research & Development Lounge

My First Function ^^


Naike

2008-02-12 17:02:59

Hi,
This is my first Function! Just starting to script agian after some minor problems ^^.

Its my newby tree finder!, Finds any tree in Rs with right setup.


FindaTree('TreeName', TreeColor1, TreeColor2, Tolerance, HowLongInSec);

TreeName, Name of the tree!
TreeColor1-2, TreeColor ( Pick a pretty rare color )
Tolerance, Use 3-10 ( 10 is very high. )
HowLongInSec, How long it will look for tree until it gives up.


Procedure FindaTree(TreeName: String; TreeCol1, TreeCol2, Tolerance, HowlongInSec : integer);
Var
Time, x, y, i, Count : integer;
TreeColor : Array[0..1] of Integer;
Begin
TreeColor[0] := TreeCol1;
TreeColor[1] := TreeCol2;
MarkTime(Time);
Repeat
For i:= 0 to 1 do
If FindColorSpiralTolerance(x, y, TreeColor[i], MSX1, MSY1, MSX2, MSY2, Tolerance) then
begin
MMouse(x, y, 0, 0);
If IsUpText(TreeName) then Mouse(x, y, 0, 0, False);
If ChooseOption('hop') then Exit;
end else Count := Count + 1;
Until(TimeFromMark(time) > 1000*HowLongInSec) or (Count = 3);
end;

HyperSecret

2008-02-12 17:08:16

for i := 0 to 1 do;

not

for i := 0 to 2 do;

the array of colors is only 0 and 1 so you dont need the 2 because it starts at 0 and goes to 1

besides that nice a basic keep going

Naike

2008-02-12 17:10:19

Ty ;) Just started agian and i forgot the most stuff :/
Have seen N3ss3s gone crazy with TPA's ?

gerauchert

2008-02-12 17:14:48

From: N1ke!
Ty ;) Just started agian and i forgot the most stuff :/
Have seen N3ss3s gone crazy with TPA's ?


n3ss3s is the TPA machine :p

You could make the colors in the syntax be a TIntegerArray so you could pick multiple colors as well…something like this:

Procedure FindaTree(TreeName: String; TreeColor: TIntgerArray; Tolerance, HowlongInSec : integer);
Var
Time, x, y, i, Count : integer;
TreeColor : TIntegerArray;
Begin
MarkTime(Time);
Repeat
For i:= 0 to GetArrayLength(TreeColor - 1) do
If FindColorSpiralTolerance(x, y, TreeColor[i], MSX1, MSY1, MSX2, MSY2, Tolerance) then
begin
MMouse(x, y, 0, 0);
If IsUpText(TreeName) then Mouse(x, y, 0, 0, False);
If ChooseOption('hop') then Exit;
end else Count := Count + 1;
Until(TimeFromMark(time) > 1000*HowLongInSec) or (Count = 3);
end;

Naike

2008-02-12 17:17:26

Thats way better ^^ Thx for that!
Maybe start working on a Wcer could get me back..

HyperSecret

2008-02-12 20:26:46

remember when you use TIntegerArray you need the [] around the colors

FindaTree('Oak', [6574684, 6746746, 9385068], 15, 10);

drizzt

2008-02-13 07:55:09

if you do work on a woodcutting script, just a suggestion, since JaGeX is crackin' down on us, maybe you could use a random click function so it won't always right click chop, maybe just throw a left click on there every once in a while. it'd be pwnsome for those little JaGeX noobs to try to find it, in my opinion.

gerauchert

2008-02-13 08:01:16

most scripts use that already…its just a case statment:


case random(4) of
0,1,2: Mouse(x,y,3,3,True);
3: begin
Mouse(x,y,3,3,False);
ChooseOption('hop');
end;
end;

drizzt

2008-02-13 14:17:22

hmm..wow, i've seen it before i think, but only one 1 of the scripts i used, but thats pretty dandy..nice procedure n1ke btw