PDA

View Full Version : How to Chop a tree! [beginner]



Mr. Doctor
09-07-2009, 03:53 AM
This tutorial was in moparisthebest and it was way outdated. I decided to update it and post it on the forums.It was mine. Enjoy!

What will this tutorial do?
It will help you how to chop a tree!

Ok lets start with the basics,First open up scar in your deskptop or some where.

Now a window will show up with this in it,

program New;
begin
end.


now program...
see how it says new?Well now make that new into anything you want(but put a space after new and put a semi colon after your name with no space)

ill name it chopatree.

program chopatree;
begin
end.


Now it should look like that!

a begin....
begins a procedure or the mainloop(ill explain it later)

end.(with period)...
will end the whole script, but put nothing after that!

now space it out like this!

program chopatree;




begin




end.


now put "const" between the begin and program

it should look like this...

program chopatree;


const


begin




end.


constant.....
This means that this "setting" will stay the same throughout the entire script.(bebes definition, cred goes to her)

now put something called a

procedure ;


after the


begin


procedure....
Procedures are like sections of the
script that can be called upon for many different reasons.(from bebe and kane,cred goes to both)

now it should look like something like this!

program chopatree;


const


procedure chop;
begin




end.


now my procedure is like a program, you can name it what ever you want,ill name it chop.

So put this under program

{.include srl/srl.scar}


srl is the main include,you use it in almost every script to include most of the functions of scar

now your script look something like this....


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

const


procedure chop;
begin




end.


now in your const put

treecolor1=;


now(you dont really need to)
login to runescape and put scar under so you can see the eyedropper thing
now click the "eyedropper" and click the tree, any part of it.

now look in your debug box in scar (the bottom box) there should be

Color Picked:

That means youve picked a color!

now after treecolor1 copy and paste the numbers(not the ones in the close rounds)

now your gonna make a procedure!

so your script should look like this now...


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

const
treecolor1=15123344;

procedure chop;
begin
end;



end.


NOTE*that color is a random color dont use it,Not RS

end;(with semi-colon)...
ends a procedure.

now put this in your procedure i will go over it...


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

const
treecolor1=15123344; //tree color

procedure chop;
var x,y :Integer;
begin
if(FindColorSpiralTolerance(x,y,treecolor1,msx1,ms y1,msx2,msy2,25))then
MMouse(x,y,3,3);
if(IsUpText('hop'))then
begin
GetMousePos(x,y);
Mouse(x,y,3,3,true);
end;
end;



end.


NOTE*for how many begins you have in a procedure, thats how many ends you have after the procedure.

that

if(FindColorSpiralTolerance(x,y,treecolor1,msx1,ms y1,msx2,msy2,25))then

lets start with "if" down....
if means that..
if it finds something that came up...

it needs to be there always.

(FindColorSpiralTolerance)

will find the color of the tree color and use tolerance.
x,y, is the co-ordinates you need it as a variable, add it like i did.

treecolor1, of course your tree color!

msx1,msy1,msx2,msy2,the co-ordinates for main screen(ms)

25,the tolerance.

mouse(x,y,3,3,true),clicks,3 is the pixels,true is the way you want to click...true=left false=right

Mmouse(x,y,3,3), moves the mouse

isuptext,finds the text that comes at the top left corner of the screen

'hop', text taken from the top left words (uptext), no first letter.

Getmousepos(x,y); gets the current mouse position at x,y

Now make a procedure like you did last time

Now in the procedure put

wait(timetochop)


Your thinking,where did that timetochop come from....
Put that in your const and after it put how long it takes to cut a tree!
but you cant just put 15 or anything you need to put it in milli seconds
so for ex

1000 is a second in milli seconds and so forth


Now go back to that procedure
Put a end after that wait time to mark the end of the procedure.

now your whole script should look like this...


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

const
treecolor1=15123344;
timetochop=15000;

procedure chop;
var x,y :integer;
begin
if(FindColorSpiralTolerance(x,y,treecolor1,msx1,ms y1,msx2,msy2,25))then
mmouse(x,y,3,3)
if(IsUpText('hop'))then
begin
GetMousePos(x,y);
Mouse(x,y,3,3,true)
end;
end;

procedure treewait;
begin
Wait(timetochop)
end;

end.


but wait...
The main loop!

mainloop....
the "main brain" of the script!

put a begin ontop of that end.

now space it out like this

begin


end;


now put it all like this

begin
ClearDebug;
SetUpSrl;
ActivateClient;
repeat
treewait;
chop;
until(false)
end.


ill tell you one by one what it means....

cleardbug;-clears the debugbox(the box at the bottom)
ActivateClient;-Activates the window you put the crosshair on
SetUpSRL;-sets up srl

repeat-repeats the procedure,functions lines ect. you put under it

treewait; and chop;-your procedures!

until- breaks out of a loop(repeat) until something happens
(false)-(goes with until) repeats it forever!

now your script should look like this!

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

const
treecolor1=15123344;
timetochop=15000;

procedure chop;
Var x,y :integer;
begin
if(FindColorSpiralTolerance(x,y,treecolor1,msx1,ms y1,msx2,msy2,25))then
MMouse(x,y,3,3);
if(IsUpText('hop'))then
begin
GetMousePos(x,y);
Mouse(x,y,3,3,true)
end;
end;

procedure treewait;
begin
Wait(timetochop)
end;


begin
ClearDebug;
SetUpSrl;
ActivateClient;
repeat
treewait;
chop;
until(false)
end.


congrats!, you made your first chop-a-tree script!

any problems? Post here or pm me!

Smarter Child
09-07-2009, 06:08 AM
Okay I guess its good, maybe add more failsafes, even if its beginners i think it still needs fail safes :p

Anyways nice tutorial.

JAD
09-07-2009, 06:13 AM
If the text 'hop' is up, you actually want to get the mouse position and then click at the current position:


procedure chop;
Var x,y :integer;
begin
if(findcolorspiraltolerance(x,y,treecolor1,msx1,ms y1,msx2,msy2,25))then
mmouse(x,y,3,3);
if(IsUpText('hop'))then
begin
GetMousePos(x,y);
mouse(x,y,0,0,true)
end;
end;




I think that you explain things way too well. Like you don't need to explain how to open up SCAR...etc., because a beginner tutorial should probably be read before reading any other tutorials anyways.

Good job though :)

Mr. Doctor
09-07-2009, 06:21 AM
Thanks Smart and JAD. Fail safes are really not needed imo in a noobie tutorial that just clicks a tree and waits. This is one that just explains the basics(tolerance,mouse,mmouse, color picking and some essential SCAR functions). But i kinda see your point. And JAD i like my readers to understand how and what im doing. I take that as a compliment actually. :)

edit: Added Getmouspos :D

edtor
09-14-2009, 06:03 AM
cul, this tut helped em a bti with Willow cutter

Mr. Doctor
09-15-2009, 08:13 AM
No problem. Anytime.

Ghostman
09-26-2009, 12:06 AM
Good tutorial

I have to agree failsafes are not really needed in this one, if they want to know about failsafes there are other tutorials on them.

Mr. Doctor
09-26-2009, 03:35 AM
Glad i could help!

WhiskySK
11-14-2009, 10:03 PM
Ok, i do not want to be an ass, but it would be better if you write it with standards. I like the program and how you set, but my eyes hurt when i see everything lowercase. Just a small note.

Thanks.

Mr. Doctor
11-14-2009, 11:28 PM
Object Pascal language reserved words and key words shall always be completely lowercase. Never capitalize words that SCAR displays in bold. It's completely unnecessary and looks ugly!

Official SCAR standards. Nothing about capitalization.

WhiskySK
11-15-2009, 07:22 AM
Yes, i know but you could at least:

FindColorSpiralTolerance

Just a small example. Again, i do not blame you, it is just my opinion.

Mr. Doctor
11-15-2009, 01:06 PM
I needed to waste some time so I added the caps. Thinking about making a intermediate version.

Death12652
11-24-2009, 03:39 AM
good post if I add stuff to it, use it for mining, and give you credit can I use it.

Great tutorial by the way.

Mr. Doctor
11-24-2009, 06:14 PM
good post if I add stuff to it, use it for mining, and give you credit can I use it.

Great tutorial by the way.

Sure. Thanks ;)