SRL Archive - OSR Help

Complete noob looking for some assistance.


Blade bro4

2015-02-15 22:23:36

Hey, just started all of this. I'm looking to make a personal script that simply sits at the same spot with same camera angle on a RSPS and fletches/herblores/etc. Things that can be done without movement.

Anyway, I'm getting the error
[Error] C:\Simba\Scripts\Fletchbot.simba(89:1): 'BEGIN' expected at line 90
Compiling failed.

I don't even have a line 90, and I've tried putting a BEGIN there without much help. I've read a few tuturials, didn't think I'd need supreme knowledge to bot a RSPS. Thanks in advance!

[ATTACH]25044[/ATTACH]

honeyhoney

2015-02-15 22:51:24

Compare the two below. The first is similar to your implementation, the second is how you should have done it.

program FletchBot;

procedure run;
begin
//do stuff
end;

end.

program FletchBot;

procedure run;
begin
//do stuff
end;

begin
run();
end.

Notice how in the first example the scripts "main" function/procedure is missing a begin.
In the second we have added in the begin and have placed a call to the run() procedure so it knows which procedure to execute.

Take a look over https://villavu.com/forum/showthread.php?t=58935 for a more thorough explanation of what is going on.

Note: it's worth noting that it will only execute the run() procedure once. To make the script repeat the run() procedure you'll need to place it within a loop (see tutorial linked above for that too).

Blade bro4

2015-02-16 06:14:31

Ahh I even read that tut! Thanks, I've included this:


begin;
repeat run;
until(iskeydown(113));
end.

So now what would I go about for making this more advanced, for potential release one day?
I'm guessing the first thing would be using the banker by color instead of just clicking in one location, the same with finding the items from the inventory.
I shouldn't need an antiban for RSPS.

honeyhoney

2015-02-16 12:08:08

From: lran
So now what would I go about for making this more advanced, for potential release one day?
I'm guessing the first thing would be using the banker by color instead of just clicking in one location, the same with finding the items from the inventory.


Using static coordinates is rarely a good idea, although this is largely for antiban purposes and like you mention, perhaps not relevant for a private server. However, it'll definitely be good practice to get the coordinates based off of color.

For getting the coordinates of the banker you can use a variety of techniques. There's the spectrum of Color Tolerance Settings 0-2 (basically just finding a static color to finding a range of colors based on tolerance/hue/sat). There are DTMs too. You could even create TPAs.
For finding entities/objects I generally prefer using TPAs.
DTMs are really good for finding items in your inventory (create the DTM using 1 main-point in the middle of the item on tolerance 15-25 and then 4-5 sub-points that select the black outline (tolerance 0 or 1)).

Again, I'll let you browse the tutorial section, but hopefully I've given you a few pointers to start off with.

Blade bro4

2015-02-16 14:24:52

Another quick question while I look into this, is it possible to run two accounts at the same time? I tried spacing them out, and my mouse just spasms and they both misclick. Other bots use a clint-side pointer which makes sense to why it wouldn't work, but im' just wondering.

EDIT - Yeah, I'm going to look into the tuts, just wanted to get a crappy bot going while I learned, thanks a lot for dealing with my noobishness.

Harrier

2015-02-16 17:09:30

From: lran
Another quick question while I look into this, is it possible to run two accounts at the same time? I tried spacing them out, and my mouse just spasms and they both misclick. Other bots use a clint-side pointer which makes sense to why it wouldn't work, but im' just wondering.

EDIT - Yeah, I'm going to look into the tuts, just wanted to get a crappy bot going while I learned, thanks a lot for dealing with my noobishness.

Use SMART or VMs if you want to bot more than one account at a time.

Blade bro4

2015-02-16 18:23:06

Alright, I've been looking over more guides, especially https://villavu.com/forum/showthread.php?t=94909 this one, though it gets quite tricky at the end.

i'm getting
[Error] C:\Simba\Scripts\ApeAgility.simba(9:28): Invalid number of parameters at line 10
Compiling failed.

from my script.

program ApeAgility;
procedure ClickStone;
var
x, y:integer;
begin
if FindColorTolerance(x, y, 2188144, 334, 182, 334, 183, 5) then
begin
movemouse(x, y ,1 ,1);
wait(250);
clickmouse(x, y, mouse_left)
end;
end;
begin
StepStone := DTMFromString('mbQAAAHicY2VgYPBlZGDwB+IgRgg7EIh3AcW3AvEWIF4PxDuB2MGclSE3QZGhLEOZoaXCliHCW5ABG2DEgsEAAJ2ACX8=');
FreeDtm(StepStone);
end.

hope it's not too ugly! Basically what I'm trying to do is an agility course, and this is clicking the first object there.


EDIT-
Here's another one i tried after some other guides

program agility2;
{$DEFINE SMART}
{$i srl/srl.simba}

begin
procedure Clickstone;
var x,y:integer;
if FindObj(x, y, 'tepping', 1591120, 5) then
begin
MoveMouse(x, y, 1, 1, false);
ChooseOption('ump');
end;
end;







end.

this is throwing me Exception in Script: Unable to find file 'srl/srl.simba' used from 'C:\Simba\Scripts\agility2.simba'

Hoping i'm not completely hopeless, would really like to get to work. That seems that one of my…extensions or files is wrong? Strange.

riwu

2015-02-16 21:15:18


movemouse(x, y ,1 ,1);
MoveMouse() only accepts 2 arguments. Remove the last 2, or use the srl include and use MMouse()

If a script is using srl/srl.simba, it is outdated.

Blade bro4

2015-02-16 21:26:45

From: riwu

movemouse(x, y ,1 ,1);
MoveMouse() only accepts 2 arguments. Remove the last 2, or use the srl include and use MMouse()

If a script is using srl/srl.simba, it is outdated.


Wow, it was highlighting the wrong line! Fixed that. And I was told to put that there from guides in the tutorial section here…are the tuts outdated? My script just compiled, i'll give it a try now and continue on the course!


EDIT - apparently all of the tutorials I'm trying to use are outdated. FindObj isn't even IN the functionlist and that's how the tutorial told me to find an object!

From what I'm understanding, the following code should work, to just click on this stinking rock, but it doesn't and it won't :/

program ApeAgility;
procedure ClickStone;
var
x, y:integer;
begin
if FindColorTolerance(x, y, 2188144, 334, 182, 334, 183, 5) then
begin
movemouse(x, y);
wait(250);
ClickMouse(x, y, 1)
end;
end;
begin

repeat
ClickStone;
until(false)
end.

riwu

2015-02-16 22:07:29

Try adding a debug
writeln([x,y]);
above the movemouse(x, y);
if there's no debug it means the color not found (too low tol?)
Also make sure u set the target window with the crosshair

Blade bro4

2015-02-16 22:12:38

From: riwu
Try adding a debug
writeln([x,y]);
above the movemouse(x, y);
if there's no debug it means the color not found (too low tol?)
Also make sure u set the target window with the crosshair

program ApeAgility;
procedure ClickStone;
var
x, y:integer;
begin
if FindColorTolerance(x, y, 1459020, 334, 182, 334, 183, 100) then
begin
movemouse(x, y);
wait(250);
ClickMouse(x, y, 1)
wait(5000);
end
else
writeln('didnt find the rock');
end;
begin

repeat
ClickStone;
until(false)
end.

All of that's done, here's the current code. I've been talking on IRC and messing with the tolerance, either it's too low and returns 'didnt find the rock' or simply clicks the coords (at 200+)

Blade bro4

2015-02-17 22:03:17

Alright! Another day, another couple of hours failing hard.

Today, I decided to try and code the agility course using DTM's.

program ApeAgilityD;

procedure ClickStone;
var Stonedtm, x, y:integer;

begin

Stonedtm := DTMFromString('mggAAAHicY2NgYAhgZGDwBuIgIA4GYl8g9gTiSUC5GVA8AYj7oHRBsgKDoRYLg7stK0NVjjJDfpI8kM3LwA+UY8SCmXCIQwAAREwJ0w==');

if FindDTM(Stonedtm, x, y, 0, 0, 512, 336) then
writeln('found rock');

FreeDTM(Stonedtm);
end;


begin;
ClickStone;
end.

IT compiles and executes, but i can't get it to return the text 'found rock' so i'm obviously doing something wrong. In the DTM editor, it's finding only that point when I click "Show matching DTM's."

Am i missing something? I even tried it with another object that isn't anything near the surrounding area. I have no idea what I'm doing wrong, I've read a good bit of guides and thought I'd be able to at least get this portion started and DTM click the entire course.

Thanks in advance.

honeyhoney

2015-02-18 14:27:08

From: lran
Am i missing something? I even tried it with another object that isn't anything near the surrounding area. I have no idea what I'm doing wrong, I've read a good bit of guides and thought I'd be able to at least get this portion started and DTM click the entire course.


The DTM may no longer work if the camera rotates etc.

It's probably worth giving us a screenshot so we can see what you're trying to do.

3Garrett3

2015-02-18 15:49:10

Looking over what you're working through, I'm really glad you're working on this and it's great to see you learning.

Here's what I would suggest:

DTMs are much more difficult when you're looking for mainscreen items. They work really well when you have inventory things or even some minimap things. As soon as the screen rotates at all, your DTM won't be found though, and that's what I think is making yours break.

Your example with findColorTolerance was much closer to what I'd recommend. I'll give you a brief explanation after I show you the "corrected" code.


program ApeAgility;

procedure ClickStone;
var
x, y : integer;
begin
if FindColorTolerance(x, y, 1459020, 334, 182, 334, 183, 100) then
begin
movemouse(x, y);
wait(250);
ClickMouse(x, y, 1)
wait(5000);
end else
writeln('didnt find the rock');
end;

begin
repeat
ClickStone;
until(false)
end.

So here is a good frame-work for your code. It looks almost identical to what you posted, right? What I've changed is how the code looks, this is called the code "standards". It means how it is indented and where you put spaces. It makes it a lot easier to read when you follow the way I've done it because that's how everyone is used to reading it.

I noticed a couple problems with your findColorTolerance line though. Here's how the function works:

findColorTolerance(x, y, Color, x1, y1, x2, y2, Tolerance)

Let's look at the different letters (variables) I've got up there.

x and y are the coordinates of the color that is found. You've used them properly in your code above.

"Color" is the color of the item. You should get this from the color picker, and I assume this is what you've done.

The x1, y1, x2, y2 form a box in which you should search for this color. I see that you have (334, 182, 334, 183) in your function. The problem with this is that you've given it a 1 pixel box to search for the color and if you move at all (or rotate the camera) it won't work at all. x1 and y1 are the top left corner of the box you want to search in. This is normally the top left of your mainscreen. You can find the coordinates using the color picker, it tells you the coordinates when you pick it. The x2 and y2 are the bottom right corner of the box, and normally the bottom right of the mainscreen. Find these coordinates the same way. You'll probably find that they're something close to (0, 0, 500, 500) or something like that.

The final part is Tolerance. This number is 0-255 and it means how "close" to the color you picked it needs to be. You've chosen a tolerance of 100. This means that if you picked a grey rock, it might be matching blue or green or anything. That's probably why it's clicking 200 pixels away from the target you have. I suggest trying a tolerance of 5, maybe 10 if you can't find the color properly.

So with all of that corrected, you should have something like this:


program ApeAgility;

procedure ClickStone;
var
x, y : integer;
begin
if FindColorTolerance(x, y, 1459020, 0, 0, 500, 500, 5) then
begin
movemouse(x, y);
wait(250);
ClickMouse(x, y, 1)
wait(5000);
end else
writeln('didnt find the rock');
end;

begin
repeat
ClickStone;
until(false)
end.

Now, of course there's a lot more features you can add in once you've gotten the hang of what I showed you above. For now though that will technically work. I would not suggest using it on RS3 or OSRS, but a private server should be completely fine.

Best of luck, feel free to ask any other questions you have!

Blade bro4

2015-02-18 16:33:22

From: 3Garrett3
Looking over what you're working through



Thanks a lot! I sure wish you'd posted this the first day. I'll be looking to do that next, i couldn't figure out x1/y1/x2/y2 for awhile. I've been working on standards, hopefully my last bit wasn't all too bad. I'll give this a shot later, thanks!

3Garrett3

2015-02-18 16:37:17

From: lran
Thanks a lot! I sure wish you'd posted this the first day. I'll be looking to do that next, i couldn't figure out x1/y1/x2/y2 for awhile. I've been working on standards, hopefully my last bit wasn't all too bad. I'll give this a shot later, thanks!


The DTM one you posted was pretty good standards, it has a little bit too many spaces (or line breaks, whatever you'd like to call them) but that's subjective and varies a lot more between people.

If anything is too confusing in what I posted just let me know. If anything is so simplified it's offensive then forgive me, I wanted to make sure I wasn't complicating anything. Good luck again, I'm looking forward to seeing what you come up with!

Blade bro4

2015-02-19 20:21:47

From: 3Garrett3
The DTM one you posted was pretty good standards, it has a little bit too many spaces (or line breaks, whatever you'd like to call them) but that's subjective and varies a lot more between people.

If anything is too confusing in what I posted just let me know. If anything is so simplified it's offensive then forgive me, I wanted to make sure I wasn't complicating anything. Good luck again, I'm looking forward to seeing what you come up with!


[ATTACH]25064[/ATTACH]

Here's my progress at the moment. Pretty satisfied with how far I've come, coveting that best newcomer rank:P

It's not perfect, I'm having some issues at the moment and i'll get back to work on it tomorrow. Really appreciate all of the help.

3Garrett3

2015-02-20 10:12:41

From: Blade bro4
[ATTACH]25064[/ATTACH]

Here's my progress at the moment. Pretty satisfied with how far I've come, coveting that best newcomer rank:P

It's not perfect, I'm having some issues at the moment and i'll get back to work on it tomorrow. Really appreciate all of the help.


I'm going to write my comments here as I go through, then I'll fix the comment in my copy, and then I'll post the "fixed" code:

  • I notice you are indenting 2 tabs over in your first two procedures. 2 Spaces (or one tab) is all that's required. You seem to have it fixed in the rest of them though.
  • ClickStone: You have an "end else" statement and then a few lines after that. You need to say "end else" and then have everything inside of a "begin/end" statement in order for everything to be performed. Simba by default only counts the line immediately below the "else" so if you have lines after that they'll be done regardless of what the else statement says. For example here you have "if findcolor then blah blah else writeln('didnt find stone'), logout, terminate script" The script will go "if I find the color, then click. If I don't find the color, writeln that I didnt. Then (regardless of the color finding) logout and terminate". If that didn't make sense, just refer to the correction I put below.
  • ClickTree and ClickBars: The only problem I see here is the same as the ClickStone part.
  • ClickSlope: You have the same "end else" problem as before, and I think this one confused you more. You have an additional begin/end statement that isn't actually needed. I think it's because you weren't sure how the "else" part worked entirely. It's hard to explain, so it's best to just look at the code I used to fix it. Basically the begin/end goes for the things you want "else" to do, and the rest of the stuff can just go after the "end" and it will be called regardless of the "else".
  • ClickRope: The only problem I see here is the same as the ClickStone part.
  • ClickDown: Here you've got the same thing as ClickSlope.
  • Main loop: Perfect here, there's nothing wrong with what you've got.

So here's the fixed code:


program ApeAgility; //Begin two tiles east from stepping-stone (all grass tile)

procedure Logout;
var
x, y : integer;
begin
movemouse(754, 11);
wait(250);
ClickMouse(x, y, 1);
wait(500);
movemouse(643, 403);
wait(250);
ClickMouse(x, y, 1);
wait(500);
end;

procedure CompassNorth;
var
x, y : integer;
begin
movemouse(542, 22);
wait(250);
ClickMouse(x, y, 1);
wait(500);
end;

procedure ClickStone;
var
x, y : integer;
begin
if FindColorTolerance(x, y, 2056815, 175, 171, 195, 190, 2) then
begin
movemouse(x, y);
wait(250);
ClickMouse(x, y, 1);
wait(5000);
end else
begin
writeln('didnt find the stone');
wait(1000);
Logout;
TerminateScript;
end;
end;

procedure ClickTree;
var
x, y : integer;
begin
if FindColorTolerance(x, y, 5547729, 138, 138, 171, 165, 10) then
begin
//writeln('found tree!');
movemouse(x, y);
wait(250+random(200));
ClickMouse(x, y, 1);
wait(4000+random(500));
end else
begin
writeln('didnt find the tree');
wait(1000);
//Logout;
//TerminateScript;
end;
end;

procedure ClickBars;
var
x, y : integer;
begin
if FindColorTolerance(x, y, 6265273, 258, 164, 269, 170, 5) then
begin
movemouse(x, y);
wait(250+random(200));
ClickMouse(x, y, 1);
wait(15000+random(500));
end else
begin
writeln('didnt find the bars');
wait(1000);
Logout;
TerminateScript;
end;
end;

procedure ClickSlope;
var
x, y : integer;
begin
if FindColorTolerance(x, y, 2056044, 153, 113, 228, 202, 5) then
begin
movemouse(x, y);
wait(250+random(200));
ClickMouse(x, y, 1);
wait(3500+random(500));
end else
begin
writeln('didnt find the slope');
wait(1000);
Logout;
TerminateScript;
end;

movemouse(661, 132); //minimap
wait(250+random(200));
clickmouse(661, 132, 1);
wait(6000+random(500));
end;

procedure ClickRope;
var
x, y : integer;
begin
if FindColorTolerance(x, y, 4886967, 310, 69, 321, 78, 5) then
begin
movemouse(x, y);
wait(250+random(200));
ClickMouse(x, y, 1);
wait(4000+random(500));
end else
begin
writeln('didnt find the rope');
wait(1000);
Logout;
TerminateScript;
end;
end;

procedure ClickDown;
var
x, y : integer;
begin
if FindColorTolerance(x, y, 4292770, 298, 43, 322, 57, 5) then
begin
movemouse(x, y);
wait(250+random(200));
ClickMouse(x, y, 1);
wait(2000+random(500));
end else
begin
writeln('didnt find the downtree');
wait(1000);
Logout;
TerminateScript;
end;

movemouse(572, 115); //minimaptostart
wait(250+random(200));
clickmouse(572, 115, 1);
wait(8000+random(500));
end;

begin
repeat
CompassNorth;
ClickStone;
ClickTree;
ClickBars;
ClickSlope;
ClickRope;
ClickDown;
until(false)
end.

So I'll be honest with you, and I expect you know this as well. This script is relatively simple because it's made for a private server. The real fun comes when you try to script for RS3 (or OSRS, whichever you prefer) because there are a lot more anti-bot systems in place. The code you've used here, clickmouse and movemouse, is much more "bannable" than the SRL functions for mouse moving and clicking.

If you're interested in getting that sweet trophy, you'll need to show that you can use SRL to make some scripts. Obviously I can't guarantee anything because I have no power towards who gets what kind of trophies, but it's how I've seen other people get it.

Now that you know the basics of how Simba works and interacts with RS, you can read through a couple tutorials and make your first RS3 or OSRS scripts. There are two versions of SRL, one for RS3 and one for OSRS, so the tutorial I would recommend depends on which one you would prefer. If you're going the RS3 route I would suggest this tutorial first and then this tutorial second. If you're planning on OSRS, I would ask someone who knows a bit more about it, I don't use OSRS. I really don't know what the best tutorials are, and there are a few funky things going on with people updating new includes and stuff.

I'm glad that you're having fun so far with the learning progress. Keep that mindset and don't let frustrating things get you down, it happens to all of us. Feel free to keep posting here for other help, or to PM me if that works best for you. As always, if I explained something and it doesn't really make sense, feel free to ask.

Blade bro4

2015-02-22 16:00:21

From: 3Garrett3
I'm going to write my comments here as I go through.


Hey, a little update. I've given up on that one (colours are impossibly close together.) and I'm working on a different course. I feel I've corrected everything you've asked, I just have one problem!

@YouPee - This is what we're discussing, my proggy is pulling "0" after many laps :/.

Here it is!
[ATTACH]25091[/ATTACH]

3Garrett3

2015-02-23 09:42:53

From: Blade bro4
Hey, a little update. I've given up on that one (colours are impossibly close together.) and I'm working on a different course. I feel I've corrected everything you've asked, I just have one problem!

@YouPee - This is what we're discussing, my proggy is pulling "0" after many laps :/.

Here it is!
[ATTACH]25091[/ATTACH]


The problem you have is here:


procedure Proggy;
begin
TimeElapsed := (GetTimeRunning/60000);
LapsDone := 0;
begin
Writeln('|/\|/\|---Total Laps Complete: ' + IntToStr(LapsDone) + ' laps----|/\|/\|');
Writeln('|\/|\/|---We have ran for:' + IntToStr(TimeElapsed) + ' minutes-----|\/|\/|');
end;
end;

Inside of your Proggy function, you've got it set to say "LapsDone := 0" so every time it runs through the Proggy, it sets the laps done to 0.

Keep up the good work!