SRL Archive - OSR Help

Whats worng with my loop? Its spam click!


rya

2010-06-30 13:34:10

Well im trying to cut a Yew tree but it keeps clicking it, why?
Also any other coments on the code would be nice

program new;
{.include SRL/SRL.scar}

Var Debug,Info:Boolean;

Procedure WriteDebug(Text:String);
Begin
If Debug Then
writeln(Text);
End;

Procedure WriteInfo(Text:String);
Begin
If Info Then
writeln(Text);
End;

//Kill = cut
//Find = is there?
Function Tree(what:string):Boolean;

Var Colour,Toll,x,y:Integer;

Begin

SetColorToleranceSpeed(2);
SetToleranceSpeed2Modifiers(0.04,0.51);
Colour := 3832169 //For ease of use
Toll := 27 // ^^^^^^^^^^^^
Result := False

If FindColorSpiralTolerance(x,y,Colour,MSX1,MSY1,MSX2,MSY2,Toll) Then

Case What Of

'Kill':
Begin
MMouse(x,y,10,10);
Wait(250+Random(750));
If IsUpText('ew') Then
Begin
GetMousePos(x,y);
Result := True
If Random(45) = 12 Then
Begin
Mouse(x,y,0,0,True);
Wait(250+Random(1500));
ChooseOption('ut');
End Else
Mouse(x,y,0,0,True);
End;
End;

'Find': Result := True

End;
End;

Procedure TreeMaster;
Var I,B:Integer;
Begin

WriteDebug('Starting Tree Master');
MarkTime(B);
Repeat

If InvFull Then
Exit;

Tree('Kill')

If Tree('Find') Then
WriteDebug('Function Tree(find) is True, Must be still cutting, Going in to Loop for 10 mins Max!');

MarkTime(I);
Repeat // While cutting loop

If InvFull Then
Begin
WriteInfo('Inv is full');
Exit;
End;

If Not Tree('Find') Then
Begin
WriteDebug('Tree(find) is false, Tree is gone going to wait for new one');
WriteInfo('Tree is gone');
Break;
End;

I := TimeFromMark(I);

If (I >= 6000000) Then
WriteDebug('10 mins past, cant be cutting tree ending loop');

Until (I >= 6000000)

MarkTime(I);

Repeat //Looking loop

If Tree('Find') Then
Begin
WriteDebug('Found tree, exiting LOOP');
Break;
End;

If Not Tree('Find') Then
Wait(500+Random(700));

I := TimeFromMark(I);

If (I >= 6000000) Then
Begin
WriteDebug('Its been 10 mins looking for tree exiting');
Exit;
End;

Until(False)

B := TimeFromMark(B);
Until(B >= 54000000);
WriteDebug('Its been half an hour ending now');
End;

begin
SetupSRL;
Debug := True
Info := True
ActivateClient;
Wait(750);
Treemaster;
end.
thanks

Frement

2010-06-30 13:42:42

You should have a while cutting function, you can use like PixelShift() to detect if your character is moving.

EDIT: I'll be offline for some time, so someone else can explain some more :)

Shuttleu

2010-06-30 14:38:16

sorry but i might be missing something but on your tree function for 'find' you have it so if it finds the tree on the screen then it results yes
and later in the script you use that to see if your cutting
but just because the tree is on the screen doesn't mean that your cutting…

~shut

g0tp0t

2010-07-07 15:43:56

Lol :P. I think your problem is when you try to 'Find' a tree, u find it anywhere one the screen. if there are 2 vidible yews(or even just a yew colord pixel XD) then your script assumes it has nut finished cutting the yew.

That us exactly what shuttle saw too :D. lol.

You say your script continually clicks, so im curious as to what exactly your script sees.

To see all those pixels with the yew color, you should add this before your findcolortolerance and case statement


FindColorsTolerance(YewColTPA,YewColorHere,MSX1,MSY1,MSX2,MSY2,{tolerance here, u will test this to see what value works best by drawing the pixels this finds on the runescape client});

Now that you have assigned all the pixels your pc thinks are yew trees a spot in the TPA, you can use this in a function that maybe someone else will post wich draws them on screen