SRL Archive - Research & Development Lounge

Woodcutting Functions


Dusk412

2008-05-28 22:17:51

Hey I made two woodcutting functions for a script I am making and I realized that they are actually pretty dang useful. One, called IsChopping returns true if you are actually cutting a tree and false if you aren't. The other, IsChopped, figures out if you are done cutting down the tree. While pretty useless by themselves (since they use the text that comes up), together they make a powerful tool that allows you to wait between cutting without having to guess how long it will take to cut down a tree. Simple yet efficient. If there are any bugs or possibilities I forgot let me know!

function IsChopping: Boolean;
begin
FixChat;
if ((FindBlackChatMessage('You do not have an axe which you have the woodcutting level to use.')) or (FindBlackChatMessage('You need a Woodcutting level of'))) then
begin
Result := False;
end;
if (FindBlackChatMessage('You swing your axe at the tree')) then
begin
Result := True;
end else
begin
Result := False;
end;
end;
function IsChopped: Boolean;
begin
FixChat;
if (FindColorTolerance(x, y, 16711680, MIx1, MIy1, MIx2, MIy2, 5)) then
begin
Mouse(x, y, 10, 1, True);
end;
if (FindBlackChatMessage('You get some logs.')) then
begin
Result := True;
end else
begin
Result := False;
end;
end;

Here is a sample on how you can use them in combination (used after you pick and click on a tree):
if (IsChopping) then
begin
repeat
Wait(500+random(150));
until(IsChopped);
end;

Sir R. M8gic1an

2008-05-29 02:14:11

oaks, willows, yews etc will get many 'you get some logs' but not be chopped.

~RM

Naum

2008-05-29 04:37:44

Nice but Maybe make it click once in a while, becuase sometimes the tree will vanish and it will still Find the color instead use this:
CountInvItems

^ I think^

Check ammount.scar

mixster

2008-05-30 04:52:22

The first function can be shortened a lot by using or instead of a string of if else's, observe:

function IsChopping: Boolean;
begin
Result := True;
FixChat;
if (FindBlackChatMessage('You do not have an axe which you have the woodcutting level to use.')) or (FindBlackChatMessage('You need a Woodcutting level of')) or (FindBlackChatMessage('You swing your axe at the tree')) then
Result := False;
end;
Note: I just have the Result := True at the beginning because then I don't need an else as if it does match one of those phrases then it will get set to false otherwise remain true.

Dusk412

2008-05-30 13:00:49

I'll fix it up top, one of those ors is a true instead of a false though.

There I think I fixed that bit.