PDA

View Full Version : [WoodCutting] Help with script



henryuscola
02-23-2015, 06:24 AM
Hi, I'm having trouble making a basic woodcutting script for an rsps my script compiles sucessfully however it does not click on the tree even with the color selected

heres what i have so far

program YewCutter;
{$I SRL-6/SRL.simba}

Procedure ChopYew;
var
X,Y:Integer;
Begin
if mainscreen.findObject(x, y, 1717802, 21, ['Yew'], MOUSE_MOVE) Then
wait(250);
ClickMouse(X, Y, mouse_left)
end;
begin
MouseSpeed := 15;
End.

cosmasjdz
02-23-2015, 07:44 AM
Hi, I'm having trouble making a basic woodcutting script for an rsps my script compiles sucessfully however it does not click on the tree even with the color selected

heres what i have so far

program YewCutter;
{$I SRL-6/SRL.simba}

Procedure ChopYew;
var
X,Y:Integer;
Begin
if mainscreen.findObject(x, y, 1717802, 21, ['Yew'], MOUSE_MOVE) Then
wait(250);
ClickMouse(X, Y, mouse_left)
end;
begin
MouseSpeed := 15;
End.

You not calling ChopYew procedure. Try this:

program YewCutter;
{$I SRL-6/SRL.simba}

Procedure ChopYew;
var
X,Y:Integer;
Begin
if mainscreen.findObject(x, y, 1717802, 21, ['Yew'], MOUSE_MOVE) Then
begin
wait(250);
ClickMouse(X, Y, mouse_left);
end
else writeln('tree not found'); // <- failsafe to prevent mouse clicking -1,-1 if tree not found.
end;
begin
MouseSpeed := 15;
ChopYew(); // <- basicly missed this line
end.

henryuscola
02-23-2015, 01:25 PM
Hello, so far the script compiles successfully but it cant seem to find the color and the script ends.
this is what it says in the debug;

-- TRSMainscreen.findObject()
---- No colors found
-- TRSMainscreen.findObject(): False
tree not found
Successfully executed.

cosmasjdz
02-23-2015, 01:43 PM
Hello, so far the script compiles successfully but it cant seem to find the color and the script ends.
this is what it says in the debug;

-- TRSMainscreen.findObject()
---- No colors found
-- TRSMainscreen.findObject(): False
tree not found
Successfully executed.

Aparently either you didnt dragged simba cursor called select screen to your game window or/and colors bad especially when debug says no colors found :D

henryuscola
02-23-2015, 01:56 PM
Thank you for your help is there a way i could make it search for the tree colors without the script stopping? like have it on a repeat loop until i manually stop the script

Flight
02-23-2015, 02:07 PM
Unsure about SRL6 but here's a way to do a loop X amount of times, or until the desired task was completed successfully:

program YewCutter;
{$I SRL-6/SRL.simba}

Function ChopYew(): Boolean;
var
X,Y:Integer;
Begin
if mainscreen.findObject(x, y, 1717802, 21, ['Yew'], MOUSE_MOVE) Then
begin
writeln('Found the Yew tree');
wait(250);
ClickMouse(X, Y, mouse_left);
rexult := true;
end else
writeln('Tree not found'); // <- failsafe to prevent mouse clicking -1,-1 if tree not found.
end;

var
i : Integer;

begin
MouseSpeed := 15;

for i:=0 to 4 do // Loop 5 times [0,1,2,3,4]
if ChopYew() then
break; // Successfully chopped a Yew tree so break the loop
end.

cosmasjdz
02-23-2015, 02:08 PM
Thank you for your help is there a way i could make it search for the tree colors without the script stopping? like have it on a repeat loop until i manually stop the script

Yes.

program YewCutter;
{$I SRL-6/SRL.simba}

Procedure ChopYew;
var
X,Y:Integer;
Begin
if mainscreen.findObject(x, y, 1717802, 21, ['Yew'], MOUSE_MOVE) Then
begin
wait(250);
ClickMouse(X, Y, mouse_left);
end
else writeln('tree not found'); // <- failsafe to prevent mouse clicking -1,-1 if tree not found.
end;
begin
MouseSpeed := 15;
repeat
ChopYew();
until false;
end.

This repeats searching tree untill you stop script.

or you might do it repeat untill it clicks tree:

program YewCutter;
{$I SRL-6/SRL.simba}

function ChopYew(): boolean;
var
X,Y:Integer;
Begin
result:=false;
if mainscreen.findObject(x, y, 1717802, 21, ['Yew'], MOUSE_MOVE) Then
begin
wait(250);
ClickMouse(X, Y, mouse_left);
result:=true; // returns true if found and clicked on tree so loop can stop itself.
end
else writeln('tree not found'); // <- failsafe to prevent mouse clicking -1,-1 if tree not found.
end;
begin
MouseSpeed := 15;
repeat
wait(100); // waits few ms before trying again
until ChopYew();
end.

henryuscola
03-02-2015, 07:06 AM
Thank you all for the help I have so far made the script run on a loop searching for the yew trees.