View Full Version : repeating thingy for rsps
i am making a simple woodcut chopper for a rsps, so i have this to wood cut procedure here
Procedure woodcutting;
begin
if FindColorSpiralTolerance(x, y, colour, x1,y1,x2,y2, tolerance) then //this is for finding the tree
begin
Mouse(x, y, 1, 1, True); // is there a better way to make it click just once?
until
(FindColorSpiralTolerance(x, y, colour2, x1,y1,x2,y2, tolerance) //this is the tree stump
end;
end;
i want to repeat this procedure until
(FindColorSpiralTolerance(x, y, colour3, x1,y1,x2,y2, tolerance)
how would i go about doing this?
Markus
04-16-2012, 08:29 AM
repeat
writeln('Do SOmething');
until (FindColorSpiralTolerance(x, y, colour2, x1,y1,x2,y2, tolerance));
so would this procedure click on the tree, wait till the stump appears, and repeat itself until it detects the logs in the last spot in the inventory?
Procedure Woodcutting;
begin
repeat //repeating till log appears in last spot in inv
if FindColorSpiralTolerance(x, y, TreeColour, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2) then // detecting tree and clicking
begin
Mouse(x, y, 1, 1, True);
until
(FindColorSpiralTolerance(x, y, TreeStump, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2) //detecting tree stump
until
(FindColorSpiralTolerance (x, y, LogColour, 653, 438, 674, 456, 2) // detecting log in last inv spot
end;
end;
1. you dont need a begin if you are only going to perform 1 action, but if u want to, then u have to always end it after the action (and not after the untils!)
2. every until is accompanied by repeat just like begin is accompanied by end.
the code should look something like this (notice how i use spaces to make it easier to see what im doing?--search standards on scripting tutorials for info):
Procedure Woodcutting;
begin
repeat //repeating till log appears in last spot in inv
repeat
if FindColorSpiralTolerance(x, y, TreeColour, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2) then // detecting tree and clicking
Mouse(x, y, 1, 1, True);
until(FindColorSpiralTolerance(x, y, TreeStump, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2) //detecting tree stump
until (FindColorSpiralTolerance (x, y, LogColour, 653, 438, 674, 456, 2) // detecting log in last inv spot
end;
From what i see, the script will spam click the tree (like crazy) until it gets chop down, so u need to learn about methods such as averagepixelshift etc so that it only clicks once to chop a tree.
Also ultilise the srl includes well, u can replace InvFull or ExistsItem(28) to replace ur findcolor for detecting log;)
Edit: just realise u already have the function to detect tree finished chopping, try this instead:
Procedure Woodcutting;
begin
repeat //repeating till log appears in last spot in inv
if FindColorSpiralTolerance(x, y, TreeColour, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2) then // detecting tree and clicking
begin
Mouse(x, y, 1, 1, True);
while not (FindColorSpiralTolerance(x, y, TreeStump, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2) do wait(100); //detecting tree stump
end;
until InvFull // detecting log in last inv spot
end;
It will find (or repeatedly tries to) the tree,click chop once, wait until stump appear, then repeat until ur InvFull. You did not create any failsafe though but that can be improved on later.
EDIT 2: pertaining to ur qns, "Go Advanced" when u are replying, then click on simba tag and insert ur code in between.
Also i believe most functions works on rsps (especially the InvFull, unless their inv coordinates are different)
riwu this is for a rsps so functions would be limited, but ty for fixing it up :P, and how do i put things into simba code in a forum post?
not sure why but this here
while not (FindColorSpiralTolerance(x, y, TreeStump, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2) do wait(100);
is not compiling correctly, is there something wrong?
debug says
[Error] (24:121): Closing parenthesis expected at line 23
Compiling failed.
not sure why but this here
while not (FindColorSpiralTolerance(x, y, TreeStump, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2) do wait(100);
is not compiling correctly, is there something wrong?
debug says
[Error] (24:121): Closing parenthesis expected at line 23
Compiling failed.
yeah do exactly as it says, add a closing parenthesis ")":
while not (FindColorSpiralTolerance(x, y, TreeStump, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2)) do wait(100);
sorry i just copy paste ur code, didnt check for syntax errors :p
masterBB
04-16-2012, 10:13 AM
while not(FindColorSpiralTolerance(x, y, TreeStump, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2)) do
wait(100);
thanks riwu for all the help
so this is my complete script, however it does not compile correctly
nvm
what am i doing wrong?
masterBB
04-16-2012, 10:19 AM
program WCandFM;
{$i SRL/SRL.simba}
var
x,y:Integer;
const
TreeColour = 12392;
TreeStump = 3105412;
LogColour = 541282;
TreeCoordsX1 = 128;
TreeCoordsY1 = 150;
TreeCoordsX2 = 232;
TreeCoordsY2 = 236;
Procedure Woodcutting;
begin
repeat
if FindColorSpiralTolerance(x, y, TreeColour, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2) then
begin
Mouse(x, y, 1, 1, True);
while not (FindColorSpiralTolerance(x, y, TreeStump, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2)) do
wait(100);
end;
until (FindColorSpiralTolerance (x, y, LogColour, 653, 438, 674, 456, 2)); //added );
end;
Procedure Firemaking;
begin
repeat
Mouse(694, 450, 1, 1, True);
wait (1400);
Mouse(676, 449, 1, 1, True);
wait (1400);
until(FindColorSpiralTolerance (x, y, 2963008, 653, 438, 674, 456, 2)); //added ;)
end;
procedure main;
begin
repeat
Woodcutting;
Firemaking;
until(false);
end;
begin //added begin ... end.
main;
end.
ur mainloop went missing:garfield:
also add extra ) for whichever u missed.
program WCandFM;
{$i SRL/srl.simba}
var
x,y:Integer;
const
TreeColour = 12392;
TreeStump = 3105412;
LogColour = 541282;
TreeCoordsX1 = 128;
TreeCoordsY1 = 150;
TreeCoordsX2 = 232;
TreeCoordsY2 = 236;
Procedure Woodcutting;
begin
repeat
if FindColorSpiralTolerance(x, y, TreeColour, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2) then
begin
Mouse(x, y, 1, 1, True);
while not (FindColorSpiralTolerance(x, y, TreeStump, TreeCoordsX1, TreeCoordsY1, TreeCoordsX2, TreeCoordsY2, 2)) do wait(100);
end;
until (FindColorSpiralTolerance (x, y, LogColour, 653, 438, 674, 456, 2))
end;
Procedure Firemaking;
begin
repeat
Mouse(694, 450, 1, 1, True); //clicking tinderbox
wait (1400)
Mouse(676, 449, 1, 1, True); //clicking log
wait (1400)
until
(FindColorSpiralTolerance (x, y, 2963008, 653, 438, 674, 456, 2)) //detects empty inv
end;
procedure main;
begin
repeat
Woodcutting;
Firemaking;
until(false)
end;
begin
SetupSRL;
main;
end.
edit: get :ninja: (:mad:)
ive gotten myself into a mess havent i? script is working BUT i have one small problem. as you see, the woodcutting procedure will cut, wait for stump and repeat until not(FindColorSpiralTolerance (x, y, 3029313, 653, 438, 669, 449, 20));. however, it is not recognzing that colour and continuing the script because it has not yet seen the tree stump.
program WCandFM;
{$i SRL/SRL.simba}
var
x,y:Integer;
const
TreeColour = 10328;
TreeColourTolerance = 3;
StumpColour = 26784;
StumpColourTolerance = 3;
TreeX1 = 0;
TreeY1 = 0;
TreeX2 = 515;
TreeY2 = 337;
procedure AntiBan;
begin
Case Random (20) of
1: Begin SleepAndMoveMouse(5000 + Random(750)); End;
2: Begin RandomRClick; End;
3: Begin PickUpMouse; End;
4: Begin MissMouse(100,100); End;
5: Begin RandomRClick; End;
6: Begin PickUpMouse; End;
7: Begin RandomMovement; End;
8: Begin BoredHuman; End;
9: Begin RandomRClick; End;
End;
end;
procedure ChopTree;
begin
repeat
if FindColorSpiralTolerance(x, y, TreeColour, TreeX1, TreeY1, TreeX2, TreeY2, TreeColourTolerance) then
begin
writeln('Found tree and chopping it down.');
Mouse (x ,y ,0 , 0, True);
end;
repeat
Wait(RandomRange(1000, 2000));
AntiBan;
writeln('Doing AntiBan.');
Until (FindColorSpiralTolerance(x, y, StumpColour, TreeX1, TreeY1, TreeX2, TreeY2, StumpColourTolerance)
or (FindColorSpiralTolerance (x, y, 3029313, 653, 438, 669, 449, 20)) = False)
writeln('Found tree stump, waiting for tree to appear');
wait(3000);
until not(FindColorSpiralTolerance(x, y, 3029313, 653, 438, 669, 449, 20));
Writeln('Full inventory, starting to firemake.');
end;
Procedure Firemake;
begin
repeat
Mouse(706, 444, 10, 10, True);
wait (200+Random(100));
Mouse(663, 444, 10, 10, True);
wait (1600+Random(100));
until (FindColorSpiralTolerance (x, y, 3029313, 653, 438, 669, 449, 20));
Writeln('Finished lighting all the logs, finding tree.');
end;
procedure main;
begin
repeat
ChopTree;
Firemake;
until(false);
end;
begin
ClearDebug;
SetUpSrl;
ActivateClient;
Repeat
main;
Until(false);
end.
how can i get myself around this?
and also, how do i use smooth mouse moving and pixel offsets? sorry bit of a noob and never really watched tuts
if its not recognising the colour then try change the colour? or increase ur color tolerance.
Pixel offsets are done using srl in-built functions such as MMouse instead of MoveMouse, Clickmouse2 instead of clickmouse. Refer to srl core for more functions.
Also if u "never really watched tuts" then i suggest u read some before going into scripting as that would make ur life easier ;)
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.