Log in

View Full Version : First Script pointers needed



Pupp3tMast3r
09-20-2006, 10:17 PM
Hi, this si the first script I've wrote, Big Grin but all it does is find a tree and clicks it. Embarrassed

I'd like to know were to go from here, how do i repeat my procedure 'CutTree' but only get it to start the loop again when i know the other tree has finnished beaing cut???

Alsoso were would i put in the script +1 the my unused 'TreesCut' variable, so that even if i modified this later to cut, say yews which you can get more than one log from befor the tree goes or no logs atall?


program WoodCutter;
{.include SRL\SRL.scar}

Var
LogsCut: Integer;

//----------------Set up begins--------------\\
Const
TreeColor1 = 2908240;
TreeColor2 = 793110;
TreeColor3 = 5079160;
//----------------Setup ends------------------\\

Procedure RealClick(x,y: Integer; Left: Boolean); //Left or Right click mouse (Human like)
begin
Wait(400+random(356));
Holdmouse(x, y, Left);
Wait(40 + random(31));
ReleaseMouse(x, y, Left);
Wait(400 +random(601));
end;

Procedure CutTree(TColor1, TColor2, TColor3: Integer); //Finds and clicks tree
begin
If (FindColorSpiralTolerance(x, y, TColor1, 5, 5, 514, 337, 20))
or (FindColorSpiralTolerance(x, y, TColor2, 5, 5, 514, 337, 20))
or (FindColorSpiralTolerance(x, y, TColor3, 5, 5, 514, 337, 20)) Then
begin
Wait(900 + random(601));
MMouse(x, y, 3, 3);
GetMousePos(x, y);
If (IsUpText('Chop')) Then
RealClick(x, y, True);
end;
end;

begin
SetupSRL;
DisguiseScar('My Documents');
ActivateClient;
CutTree(TreeColor1, TreeColor2, TreeColor3);
end.


Thanx for any help, any other pointers would also be appriciated.

Home
09-21-2006, 04:50 AM
I'm not sure did you meaned this...


program WoodCutter;
{.include SRL\SRL.scar}

Var
LogsCut: Integer;

//----------------Set up begins--------------\\
Const
TreeColor1 = 2908240;
TreeColor2 = 793110;
TreeColor3 = 5079160;
//----------------Setup ends------------------\\

Procedure RealClick(x,y: Integer; Left: Boolean); //Left or Right click mouse (Human like)
begin
Wait(400+random(356));
Holdmouse(x, y, Left);
Wait(40 + random(31));
ReleaseMouse(x, y, Left);
Wait(400 +random(601));
end;

Procedure CutTree(TColor1, TColor2, TColor3: Integer); //Finds and clicks tree
begin
If (FindColorSpiralTolerance(x, y, TColor1, 5, 5, 514, 337, 20))
or (FindColorSpiralTolerance(x, y, TColor2, 5, 5, 514, 337, 20))
or (FindColorSpiralTolerance(x, y, TColor3, 5, 5, 514, 337, 20)) Then
begin
Wait(900 + random(601));
MMouse(x, y, 3, 3);
GetMousePos(x, y);
If (IsUpText('Chop')) Then
RealClick(x, y, True);
end;
end;

Procedure Setup;
Begin
SetupSRL;
DisguiseScar('My Documents');
FindRs;
ActivateClient;
End;

begin
Setup;
Repeat
CutTree(TreeColor1, TreeColor2, TreeColor3);
Until(false)
end.


:)

Boreas
09-21-2006, 05:02 AM
This is just off the top of my head theory, and wont work with trees that you get more than 1 log from. There are better ways to do what you want but its something to think about while you wait for someone else to post.


repeat
cuttree //your cuttree proc
repeat
wait(10); //how often it checks whether tree has been cut
until(TreeHasBeenCut): //see below
until(PutAFailSafeHere); //when you it to stop


TreeHasBeenCut would be a function that checks if there are more logs in your inventory than when you started cutting the current tree. This means you would have a global variable to keep track of how many there are by either updating it whenever you drop/burn/fletch/bank and cut/pickup/withdraw any (more useful), or count how many there are in the inventory before and after cutting (easier).

Pupp3tMast3r
09-21-2006, 10:52 AM
what i mean is, if i left my woodcutting prcedure inside a loop as it is now, like repeat until(false), it would not finnish cutting a tree befor it found another one and run of to cut that :(

i want it to make sure its got a log, plus one to my variable and then check if there is still a tree infront of him??

would i get the mouse to stay put while cutting and wait until isuptext = false??? or would that be far too detectable :confused:

thanx for the help everyone :)

WT-Fakawi
09-21-2006, 12:36 PM
This is taken directly from Ratz!. IMHO these are good woodcutting (Treecutting) procs.

I use a FindDeformed method. Observe the Tree Bitmap (8 * 1) It is in fact a tiny "slice" from a tree. I compare this using scar's FindDeformedBitmapToleranceIn. Works smooth. (OpenBankQuiet uses this too...)
These kind of methods (FindDeformed, FindObjectDeformed) are good for static objects. They avoid wacky mousemovements, albeit they are a little laggy...
The Treecutting loop also relies on the text messages (Uptext en InChatMulti) to handle treecutting.

General rule of thumb is to use multiple techniques (Color and Bitmap and Text) to create a good cycle.




Tree:= BitmapFromString(8, 1, '68783458583D383824' +
'707834485022687834384822586036');


function FindTreeDeformed(var ObjX, ObjY :integer; UpText1, UpText2: String; BMP, a, b, c, d: integer): Boolean;
var
acc, ref : Extended;
var
XT, YT,times,tol : Integer;
begin
ref:=0.9; tol:=0;
for times:=1 to 4 do
begin
FindDeformedBitmapToleranceIn(BMP, XT, YT, a, b, c, d, tol, 2, True, acc);
if (acc >= ref) then
begin
MMouse(XT+8,YT,0,0);
if (IsUpText(UpText1) or IsUpText(UpText2)) then
begin
ObjX:=XT;
ObjY:=YT;
Result := True;
Exit;
end;
end;
ref := ref - 0.1;
tol:=tol+10;
FTWait(1);
end;
end;

//----------------------------------------------------------------------------//

function ChopTree : Boolean;
var CX, CY, RT, ChopTime, StopTime, ChP : Integer;
begin
if ( FindTreeDeformed(CX, CY, 'Tre' , 'ree', Tree, MSX1,MSY1,MSX2,MSY2 )) then
begin
Mouse ( CX+20, CY, 10, 0, True );
FindBirdsNest;
FlagFTWait;
FTWait(4);
if not InChatMulti('wing','axe','ree') then
begin
Result:=False;
Exit;
end;

MarkTime ( ChopTime );
repeat
MarkTime ( StopTime );
FTWait(5);
if ( ChopTime+15000 < StopTime ) then Break;
ChP:=ChP+1;
if FawkiDebug then writeln('Chop pass:'+IntToStr(ChP));
if InChatMulti('adv','atu','ance') then Exit;
until ( InChatMulti('get','log','ogs') );
if InChatMulti('get','log','ogs') then
begin
Result := True;
TreeCount:=TreeCount+1;
end;
end;
end;

Pupp3tMast3r
09-21-2006, 05:27 PM
Theres alot of info there Fawaki thanx, although it's slightly over my head.

would someone plz explain the "if not InChatMulti('wing','axe','ree') then..." in a little more depth(maning not so much what it does but more so why it is used here) and why there is a need to search IsUpText for "ree" would solely Tree not do or even 'shop'

thanx yet again everyone for all the help :spot:

*goes to dry run the script from Fakawi's post and make more sense of it*

$anta
10-25-2006, 12:21 AM
It's not good atall, but good for first scripter.

Maxtriplex
02-12-2007, 03:52 PM
its a good overall script for a first script

Bobarkinator
02-13-2007, 01:59 PM
Lately for my miner I've been thinking about that after it clicks the ore/tree and begins chopping that you wait until it does not find a specific color in a box on the tree. Ive just been thinking about this lately and wondering if it would work.