SRL Archive - OSR Help

Trying to get the bot to ChopTree for me


Huthaifah

2011-07-11 03:28:43

I have this so far http://paste.villavu.com/show/v5vRobQEY4pI9YwqHyK7/
I want it to ChopTree until(InvFull)
Bank and repeat
Tell me how to do this and which commands and where to put what, cause I mess things up a lot.
Thanks.

KingKong

2011-07-11 04:12:59

offtopic: I would recommend you making some other script such as superheater/alcher to get used to some of the commonly used functions(thats how i started off).

ontopic: In your script, all you're doing is getting the co-ords of the tree, after that you need to click the tree, so you use mouse(x, y….), then use repeated loops to click the tree if you're not woodcutting.

masterBB

2011-07-11 04:27:06

I also made woodcutter as first script. It's quite a challenge. The hardest part is making an 'waitWhileCutting' function. Is it crowded where you are cutting? Else I suggest looking in SRL animation.scar.

Huthaifah

2011-07-11 04:34:19

No, I'm a member, so it's easier for me. Right now having trouble with banking IDK where to put it, this is what I have so far
http://paste.villavu.com/show/8ImCvwiqRQORIVhsnB5w/
And how easy is an alcher?

Bonfield

2011-07-11 04:36:34

here is a little help with the tree finding

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);

with Players[0] do
begin
Name := '*********';
Pass := '*********';
Nick := '';
Pin := '*********'; // Bank Pin
Member := True;
Active := True;
end;
end;

function FindTree: Boolean; // i suggest you change this to a function
Var
TreeLocation :Tpoint;
begin
if not LoggedIn then Exit; // this is good practice, and helps not causing infinite loops

if (FindColorTolerance(TreeLocation.x, TreeLocation.y, 1324067, MSX1, MSY1, MSX2, MSY2, 5)) then // searches for the colour
begin
MMouse(TreeLocation.X, TreeLocation.Y, 0, 0); // moves to the exact point the correct colour is found
if (WaitUpTextMulti(['Tree', 'ree', 'etc'], RandomRange(400, 550))) then // searches for correct uptext,
begin // need a wait as uptext doesnt appear right away
Result := True;
writeln('Successfully found and clicked a tree');
Exit
end else
begin
Result := False;
writeln('FindColor true but uptext false, Result := False');
Exit;
end
end else
begin
Result := False;
writeln('Could not find the correct colour, Result := False');
Exit;
end;
end;


end;

begin
SetupSRL;
DeclarePlayers;
LoginPlayer;
FindTree;
end.

i tried to explain it as i went, is should work but its just an idea i hope it helps

Huthaifah

2011-07-11 04:40:11

I need help with banking, where do I put the const
Bank_DR = 'db' ; // (Draynor Bank), and Bonfield changing right now.

1. Got this now. But when I put play it opens tab with bank includes.http://paste.villavu.com/show/TZIRDwMuZi3H2SYrEgbG/

Bonfield

2011-07-11 04:43:47

can you post what you have?

i would also suggest using TPointArrays for finding the trees, it will be alot more accurate, it is like creating a list(array) of tpoints where correct colours are found instead of just one single colour

there are alot of good tutorial on this

about the banking that would depend on how you have writen your banking procedure

masterBB

2011-07-11 04:44:17

From: Huthaifah
No, I'm a member, so it's easier for me. Right now having trouble with banking IDK where to put it, this is what I have so far
http://paste.villavu.com/show/8ImCvwiqRQORIVhsnB5w/
And how easy is an alcher?


I'm sorry. Don't understand you. Why is it easier cause you're a member? Also banking is just:
OpenBank('db',True);

Bonfield

2011-07-11 04:49:31


1. Got this now. But when I put play it opens tab with bank includes.


i dont understand this? when you press play it plays with bank tabs or inventory tabs? and what do you mean bank includes?

Huthaifah

2011-07-11 05:04:18

No lol, on simba it opens a new tab about bank includes. like OpenBank, DepositItems, you know what I mean.

@Master easier no bots so I can take my time and not wait for the tree to regrow.

masterBB

2011-07-11 05:08:37

From: Huthaifah
No lol, on simba it opens a new tab about bank includes. like OpenBank, DepositItems, you know what I mean.

@Master easier no bots so I can take my time and not wait for the tree to regrow.


You don't understand me, you need something like this:


repeat
repeat
ClickTree;
WaitWhileCutting;
until(InvFull);
Bank;
until(loadsdone = loadsyouwanttobedone);

Huthaifah

2011-07-11 05:10:39

Is it possible for one of you guys to take over my computer and show me how this goes?

Bonfield

2011-07-11 05:23:52

taking over your computer wont really help

something that helps me make scripts is planning

eg

willow banker

start off in bank
check levels and if axe is equiped
if equiped walk to trees, if not search bank for one
when character is at the tree find and cut
wait until full
repeat

i write something like that, then make my procedures/functions to suit, doing this may or may not help you with your logic

did you understand the tree finding function i posted for you?

can you post everything you have made, i will try to help you

or you can go on irc

KingKong

2011-07-11 06:47:22

From: Huthaifah
And how easy is an alcher?


The alcher im using currently using to lvl up mage on my pure is about 60 lines with failsafe(with an 'ok' antiban). but since you want to utilise banking, you should make a superheater or smelter(use reflection to make things easy for yourself at the start)

Bonfield

2011-07-11 06:49:39

i would suggest learning colour then reflection, another good idea is to read scripts to see how people use the srl include

the script ma seem hard if you look at it like one massive piece of code, try to break it up into sections

Huthaifah

2011-07-11 11:34:33

Thanks, I want my bot to do wat you said Bonfield…..

Flight

2011-07-11 11:38:10

From: Bonfield
i would suggest learning colour then reflection, another good idea is to read scripts to see how people use the srl include

the script ma seem hard if you look at it like one massive piece of code, try to break it up into sections


That's always what I tell people to do for the best way of learning to script, look at example scripts people have made, look at how they do it. I find this to be a much faster learning process than reading tutorials.

Huthaifah

2011-07-11 11:41:17

All of the draynor woodcutters are old :(. Help me fix this error, [Error] (6:1): Duplicate identifier 'Bank_DR' at line 5
Compiling failed.


http://paste.villavu.com/show/OE0tK3EGnOZaLNJxHsMu/

Smidqe

2011-07-11 13:08:44

From: Huthaifah
All of the draynor woodcutters are old :(. Help me fix this error, [Error] (6:1): Duplicate identifier 'Bank_DR' at line 5
Compiling failed.


http://paste.villavu.com/show/OE0tK3EGnOZaLNJxHsMu/


It gives that because there is already a constant Bank_DR in bank.scar. You should change it to something else.

const
Bank_FE = 'feb'; // (Falador East Bank)
Bank_FW = 'fwb'; // (Falador West Bank)
Bank_VE = 'veb'; // (Varrock East Bank)
Bank_VW = 'vwb'; // (Varrock West Bank)
Bank_GE = 'geb'; // (Varrock GE Bank)
Bank_DR = 'db' ; // (Draynor Bank)
Bank_AK = 'akb'; // (Al-Kharid Bank)
Bank_EV = 'eb' ; // (Edgeville Bank)
Bank_CT = 'ctb'; // (Catherby bank)
Bank_CM = 'clt'; // (Camelot bank)
Bank_NA = 'nab'; // (North Ardougne bank)
Bank_SA = 'sab'; // (South Ardougne bank)
Bank_YN = 'ynb'; // (Yanille bank)
Bank_NG = 'ngb'; // (North gnome bank)
Bank_SG = 'sgb'; // (South gnome bank)
Bank_WG = 'wgb'; // (Warrior guild bank)
Bank_FG = 'fgb'; // (Fishing guild bank)

kingarabian

2011-07-11 13:13:54

From: Huthaifah
All of the draynor woodcutters are old :(. Help me fix this error, [Error] (6:1): Duplicate identifier 'Bank_DR' at line 5
Compiling failed.


http://paste.villavu.com/show/OE0tK3EGnOZaLNJxHsMu/


You don't really need that as a const. And also don't half ass the script and expect it to compile.

Have the tree detection ready and completed 100%
then
Have it chop the tree and make sure its chopped or being chopped.
then
wait till full inventory and have it count the items.
THEN
Work on banking.

And don't forget walking. Continue reading tutorials. Read them 50000 times until you get it. Also look at other similar scripts. They don't have to be woodcutters, they could be miners that have the same concept.

Also don't say "help me" after each little error. Please try and figure it out.

But I like your progress.

Huthaifah

2011-07-11 14:21:48

The only updated tutorial is c0h3ns and he doesn't talk about this stuff..

Silent

2011-07-11 14:27:21

I hear you, try looking through the different includes in SRL for useful functions and use those instead of coding your own. It's saving me a lot of time and confusion. Then if you have specific issue, people here can help. :)

Huthaifah

2011-07-11 15:03:43

How do I add ChopTree? Or what is the function that chops the tree.

Bonfield

2011-07-11 16:02:33



function FindTreeAndChop: Boolean; // i suggest you change this to a function
Var
TreeLocation :Tpoint;
begin
if not LoggedIn then Exit; // this is good practice, and helps not causing infinite loops

if (FindColorTolerance(TreeLocation.x, TreeLocation.y, 1324067, MSX1, MSY1, MSX2, MSY2, 5)) then // searches for the colour
begin
MMouse(TreeLocation.X, TreeLocation.Y, 0, 0); // moves to the exact point the correct colour is found
if (WaitUpTextMulti(['Tree', 'ree', 'etc'], RandomRange(400, 550))) then // searches for correct uptext,
begin // need a wait as uptext doesnt appear right away
Mouse(TreeLocation.x, TreeLocation.y, 5, 5, True); // this is where you click the tree
Result := True;
writeln('Successfully found and clicked a tree');
Exit
end else
begin
Result := False;
writeln('FindColor true but uptext false, Result := False');
Exit;
end
end else
begin
Result := False;
writeln('Could not find the correct colour, Result := False');
Exit;
end;
end;


Mouse(TreeLocation.x, TreeLocation.y, 5, 5, True);


thats the part where the script will click the tree in the example i showed you, you have to write that SRL doesnt have preset functions like this

do you understand what the code i posted is supposed to do? not saying it will work but what it is supposed to do is it checks for a colour moves the mouse to it, checks the uptext and if bot are right its clicks the tree

i suggest read about TPA's and do the same. they can be bit hard to get your head around at first so if you would like help pm me or post here

Huthaifah

2011-07-11 16:49:58

Kk bot is working, except it keeps clicking the tree and doesn't stop until its gone. And I want to add randomness to the mouse so I Don't get banned easily. http://pastebin.com/AXWpdkUQ

Bonfield

2011-07-11 18:32:26

Yeah that's the stuff you need to work out, something like


while not InvFull do
begin
if FindTree then WaitWhileChopping else FindTree
// etc
end else
Bank;

Do you see what that is going to do? You should read through some tutorials and scripts to understand what/how to do things

Have a go at making a tree finding/cutting script and post it here or pm me

Also read what masterBB and kingarabian posted

Huthaifah

2011-07-11 18:35:10

Yeah, I understand it make the bot not click while chopping, which is the wait, or find another tree. Where do I put that in my script?

Bonfield

2011-07-11 18:41:17

I would put it in the mainloop, read my previous post I made some edits

Huthaifah

2011-07-11 18:46:36

I put it in the mainloop but it keeps messing up.

Bonfield

2011-07-11 18:49:52

It won't work, you dont have a WaitWhileChopping function, I'm just posting stuff to give you the idea of what to do, I'm not even sure if what i post compiles

I'm trying to help you with the script, not write it for you

Edit sorry if that sounds harsh it's not meant to be

Huthaifah

2011-07-11 19:09:22

Lol, it's okay, how do I put the function, go on
IRC

Bonfield

2011-07-11 19:19:53

I'm on an iPhone i don't know if I can go on irc

Yago

2011-07-11 19:39:49

You can use animation… Wich i would suggest, or wait until the tree is gone which i would not incase you misclicked…

Bonfield

2011-07-11 19:51:43

I wouldnt really use reflection for that, a simple count colour, or TPA check would work fine plenty of ways to check that you are cutting a tree

Does marpis' isanimating still work?

Huthaifah

2011-07-11 19:53:58

It stops clicking once the tree is gone, and then clicks 1 tree and clicks the other and mas clicks it.

Flight

2011-07-11 20:34:12

From: Bonfield
I wouldnt really use reflection for that, a simple count colour, or TPA check would work fine plenty of ways to check that you are cutting a tree

Does marpis' isanimating still work?


I never got color animation check to work for me.

Bonfield

2011-07-11 20:34:23

Have you made a WaitWhileChopping function? Are you just running the FindTree I wrote?

Edit: I'm pretty sure it worked really good at one point, i could be wrong, is any of the pixel shift stuff he wrote still used?

Huthaifah

2011-07-11 20:39:34

Try running this, and see if you get the problem, [Error] (41:23): Type mismatch at line 40
Compiling failed.

Bonfield

2011-07-11 20:40:33

Running what?

Huthaifah

2011-07-11 20:47:17

ohh forgot to post lolol, sec.
http://pastebin.com/QY7U6e6E

Bonfield

2011-07-11 20:50:42

What is this supposed to do?
*
(TreeLocation.x)(TreeLocation.y, 3, 3, true));

Is that supposed to be mouse?

Also


* * while (not(InvFull)) do
* * * FindTree; // need a begin here, you also dont want all these things happening while the inventory is empty
* * * WalkToBank;
* * * BankLogs; // is this finished? Cause it won't work it just counts at the moment
* * * WalkToTrees;
* until (Logs_Chopped >= LOGS);

Huthaifah

2011-07-11 20:51:22

No, the mmouse was already added, now the problem is coming from that line.

Bonfield

2011-07-11 20:57:42

But the pastebin you posted it's just how I posted it

Your also missing a comma between treelocation.x and treelocation.y

Smarter Child

2011-07-11 20:58:10

I told you to learn the basics first, Huthaifa.

Huthaifah

2011-07-11 20:59:14

I didn't write that line, Bebe did, she told me to use it.

I did but I added a parantheses and removed comma, because of this error, [Error] (41:22): Closing parenthesis expected at line 40
Compiling failed.

Bonfield

2011-07-11 21:10:09

Jad has a good tutorial on how to find/fix these annoyin errors

Huthaifah

2011-07-11 21:42:36

Alright will look at it now.

Home

2011-07-14 18:37:41

Hey mate. Add my msn if you need help. [email]home21200@hotmail.com[/email] I will be online in 10 hours. I need to sleep ;)

Huthaifah

2011-07-14 18:38:43

It's okay, I quit making the script, I don't understand anything I'm doing so I don't want to leech, thanks for the help though :)

Yago

2011-07-14 18:39:41

From: Huthaifah
It's okay, I quit making the script, I don't understand anything I'm doing so I don't want to leech, thanks for the help though :)


Don't quit just take a break to read up some more…

There are a lot of sexy tuts in the tut section… That's where I learned from.

Huthaifah

2011-07-14 18:56:51

I'm only 13 and don't understand half the things I read from the tuts….

**BANNED The Man

2011-07-14 19:05:22

Add my msn, [email]dynamite-boom@hotmail.co.uk[/email]

You can ask me all the nooby questions you need :)

-Boom

Yago

2011-07-14 19:12:41

From: Huthaifah
I'm only 13 and don't understand half the things I read from the tuts….


That's the fun of this forum … I was 12 and understood much less than you.

Lol - I used t o play spam the help forums lol…

masterBB

2011-07-14 19:34:56

From: Huthaifah
It's okay, I quit making the script, I don't understand anything I'm doing so I don't want to leech, thanks for the help though :)


You're not allowed to quit once you start scripting. I will try to help you understand your script.

If you press run on simba it will start running the between the begin and end.(notice the point). So that is were I will start explaining.


begin
SetupSRL;
DeclarePlayers;
LoginPlayer;
Logs_Chopped := 0;
repeat
while (not(InvFull)) do
begin
FindTree;
//your wait function
end;
WalkToBank;
BankLogs;
WalkToTrees;
until (Logs_Chopped >= LOGS);
Logout;
end.

The following lines are used to set up the script. SetupSRL loads everything it needs and sets the mouse speeds. It's placed correctly at the beginning of the loop. DeclarePlayers will run the procedure were you entered your player information. This is used by LoginPlayer, so it should always be before LoginPlayer. You did this correctly.
LoginPlayer will fill in the form and logs you in. It is however a better practice to call it after a check if the player is already LoggedIn. Final code can be seen down here. Notice I didn't use a begin and end; there, If they aren't used only one line of code will be run after the if-statement.

SetupSRL;
DeclarePlayers;
if not(LoggedIn) then
LoginPlayer;

The next code you used is Logs_Chopped := 0;, this code isn't needed. If you declare(make) a variable of the type Integer(a number) it will start as 0. So it's already 0 here.

I hope I still got you here? Cause now it's getting interesting. I will explain the loops you use.

You start with a repeat loop. A repeat loop repeats everything between repeat and until(condition);. When it reaches the bottom it will go up again. Unless the condition after until is True. Then it will continue at the next line.

Another loop you used is the while loop. There are a few differences between them. One of those is that you don't need two line like repeat and until, but only one. So the same rules apply as with if statements. Only the line after then is run, unless it's a begin, in that case it will run everything between the begin and the end;.

One of your problems is in the while loop. Here is a possible situation:
  1. Is your InvFull?
  2. No it isn't.
  3. Click a tree.
  4. Is your InvFull?
  5. No it isn't.
  6. Click a tree.
  7. Is your InvFull?
  8. No it isn't.
  9. Click a tree.
This all happens within a second. That is the spam clicking you were talking about. You want to wait until the tree is down. This is the hardest part of writing a woodcutter. With a wait function it could look like this:
  1. Is your InvFull?
  2. No it isn't.
  3. Click a tree.
  4. Wait till tree is down.
  5. Is your InvFull?
  6. No it isn't.
  7. Click a tree.
  8. Wait till tree is down.
  9. Is your InvFull?
  10. Yes it is full.
  11. Walk to bank.
This will eliminate the spam clicking.

I will help you further tomorrow.

Bonfield

2011-07-15 00:22:06

I told you that you could message me with any help you need, don't let a few mistakes phase you

Everyone starts out the same way

kingarabian

2011-07-15 03:52:41

Huthaifah pay close attention to what your fellow scripters are trying to teach you.