PDA

View Full Version : My First Function ^^



Naike
02-12-2008, 10:02 PM
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
02-12-2008, 10:08 PM
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
02-12-2008, 10:10 PM
Ty ;) Just started agian and i forgot the most stuff :/
Have seen N3ss3s gone crazy with TPA's ?

gerauchert
02-12-2008, 10:14 PM
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
02-12-2008, 10:17 PM
Thats way better ^^ Thx for that!
Maybe start working on a Wcer could get me back..

HyperSecret
02-13-2008, 01:26 AM
remember when you use TIntegerArray you need the [] around the colors

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

drizzt
02-13-2008, 12:55 PM
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
02-13-2008, 01:01 PM
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
02-13-2008, 07:17 PM
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