PDA

View Full Version : Simplistic Beginners Guide To RS3 Scripting



The Mayor
06-15-2014, 07:43 AM
Simplistic Beginners Guide To RS3 Scripting
Updated: 12th May 2015



This tutorial is designed to give you a very basic overview of RS3 scripting. You may be aware of my AIO RS3 and SRL6 scripting tutorial (http://villavu.com/forum/showthread.php?t=107757), but it may be a bit complicated if you’re just starting out. This tutorial is short and sweet, and sufficient to give you a basic understanding of the main SRL-6 (the include we use for RS3) scripting techniques.

This tutorial is split into the following sections:

Simba basics
Mouse basics
MainScreen basics
Backpack basics
Minimap basics
BankScreen basics
ActionBar basics
DepositBox basics
LodestoneScreen basics
ToolScreen basics
ProductionScreen basics
ProgressScreen basics
PowersScreen basics
ConversationBox basics
Chatbox basics
CollectBox basics
GrandExchange basics
LootScreen basics


NOTE: I'm still working on the last 2 or 3 sections, and I plan to add a section on logging in your player etc.

Please leave a comment if this has helped you, or if you have any questions :)



1) Simba Basics


Printing to the debug box


The first thing you need to know is how to write text to the debug box (the box at the bottom of the simba GUI). This is done using the writeLn command (which means write on a new line). Take a look at this example:


http://puu.sh/9ucho/275f3a4545.PNG


You also need to know how to clear the debug box. This is done using the clearDebug() command. In the following example I clear the debug and then print Goodbye, meaning the first line I wrote gets cleared before I print the second line:

http://puu.sh/9ucjL/db32e14cd6.PNG



Wait a second!


Next you should know how to wait. Using waits in your script is very useful, especially if you are learning. This is done using the wait(milliseconds) command. This example is similar to that above, except it waits 3 seconds before printing goodbye.


http://puu.sh/9ucl2/1de6920c89.PNG


It is also important to know that waiting for an exact amount of time is not very human like, so it is better to wait for a random amount of time. We do this using the randomRange(min, max) procedure. The following snippet is exactly the same as the previous one, except it waits for a random amount of time between 1 and 4 seconds:


http://puu.sh/9BTy4/56b5784e7b.png




Understanding coordinates


Understand coordinates is important as each location on your screen has its own coordinates (x and y). See in the bottom left corner of simba there are 2 numbers inside parentheses. These are the current (x, y) coordinates of your mouse. Move your mouse and see how they change. These are the current coordinates of your mouse:


http://puu.sh/9ucmp/06e84ff895.PNG





2) Mouse and Clicking Basics


Moving and clicking the mouse is quite important (obviously). I’ll show you some of the different ways to do that. You can move and/or click a point on the screen (if you know the x and y coordinates) or you move/click anywhere inside a box. Before we get into that, first you need to know the 3 different mouse actions:


MOUSE_MOVE
MOUSE_LEFT
MOUSE_RIGHT

The first one just moves the mouse, the second one left clicks the mouse, and the final one right clicks the mouse. These are used inside the following mouse functions.

Moving the mouse and clicking a point


This function moves the mouse to point(x, y) and will then click the mouse depending on the mouseAction you select:

mouse(x, y, mouseAction);

Let’s say I wanted to move the mouse to point (100, 100) and not click. I could use:

mouse(100, 100, MOUSE_MOVE);

If I wanted to move the mouse to point(100, 100) and then right click, I would use this:

mouse(100, 100, MOUSE_RIGHT);

This is demonstrated in the picture below. This will load SMART and move the mouse to point 100, 100 on the login screen (this also demonstrates a how a procedure works – see AIO tutorial). Write this in simba and press play if you want to test it! Make sure you write everything, including the $DEFINE and $I lines at the top (I explain these below).


http://puu.sh/9ucnF/97203b1de9.PNG


Sometimes it is good to have a little bit of randomness when moving the mouse so the mouse doesn't land in exactly the same spot every time. This can be achieved with this function:

mouse(x, y, ranX, ranY, mouseAction);

This is the same as above, except is has ranX and ranY, which is the randomness (in pixels) it will add to x and y. If I wanted to move the mouse to point(100, 100) with a randomness of 5 pixels in each direction (so x = 100-105 and y = 100-105) I would use:

mouse(100, 100, 5, 5, MOUSE_MOVE);

Now let’s say you wanted to just click the mouse without moving it. You can use fastClick(mouseAction) for this. For example, to left click the mouse without moving it:

fastClick(MOUSE_LEFT);

Now let’s put the things you've learn so far together. This snippet combines mouse moving, mouse clicking, writing text, and waiting (copy and paste this into simba and press run). If you were wondering, the {$DEFINE SMART} and {$I SRL-6/SRL.simba} at the top are just to include the SMART and SRL files from your C:/simba folder. The setupSRL() procedure at the start of the main loop loads all the files that you just included.


program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure practiceMouse();
begin
mouse(200, 200, MOUSE_MOVE);
wait(3000);
mouse(50, 50, MOUSE_MOVE);
wait(3000);
fastClick(MOUSE_RIGHT);
writeLn('We just right clicked');
wait(3000);
mouse(300, 30, MOUSE_MOVE);
end;

begin
clearDebug();
setupSRL();
practiceMouse();
end.



Moving the mouse and clicking inside a box


The previous section you learnt how to move the mouse and click a point. The other way to move and/or click a mouse is inside a box. The good thing about this method is the mouse moves anywhere inside the box, so you don't need randomness.

A box is made up of 2 points – the top left corner and bottom right corner of the box. Even though a box has 4 corners, you only need to know 2 points to make a box. See this picture taken from my AIO tutorial:


http://puu.sh/6tTBa


In simba, a box variable is called a TBox, and is made up of 4 integers (i.e., 2 coordinates for each point). Here I make a box out of integers:

intToBox(x1, y1, x2, y2);

The following is an example of declaring a TBox variable called myBox and assigning 4 integers to it:


procedure makeMyBox();
var
myBox: TBox; // Created a TBox variable called myBox
begin
myBox := intToBox(10, 10, 50, 50); // Assigned these coordinates to the myBox variable
end;


Now that you know how to make a box, let’s move the mouse inside that box. You do this using the mouseBox function:

mouseBox(box, mouseAction);

where box is a Tbox, and mouseAction is one of the 3 mouseActions described above.

If you are wondering how to get the coordinates for your box, you can simply use the coordinates displayed in the bottom left corner of simba (like I showed you above). If you are selecting coordinates from the SMART client (which you probably are), remember to drag the cross-hair from simba to SMART (so the coordinates start counting from the top left corner of the SMART window and not your desktop). The cross-hair looks like this:

http://puu.sh/9ugqj/cbd4a1d0d3.png

Time for a practical example. Let’s create a box around the settings button on the runescape login screen, and then move the mouse inside that box and left click. This will open up the settings screen.


http://puu.sh/9ucxQ/ea42dc03f7.jpg



program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure practiceBox();
var
settingsButton: TBox; //declare TBox variable
begin
settingsButton := intToBox(735, 80, 750, 100); // Top left, bottom right points
mouseBox(settingsButton, MOUSE_LEFT); // Left click the box we just made
end;

begin
clearDebug();
setupSRL();
practiceBox();
end.


If you run the following code, you will see it clicks the settings button and opens up the settings menu! Now I’ll show you another way to click a box. Instead of declaring a TBox variable and putting that variable inside the mouseBox function, you can create a box directly inside the mouseBox function. This example will open up the settings menu like before, wait 4 seconds, and then click the X to close it using another mouseBox:


procedure practiceBox();
var
settingsButton: TBox; // Declare TBox variable
begin
settingsButton := intToBox(735, 80, 750, 100);
mouseBox(settingsButton, MOUSE_LEFT);
wait(4000);
mouseBox(intToBox(630, 105, 640, 115), MOUSE_LEFT); // Notice how I made the box inside the mouseBox function
end;


Well done, now you know all about moving and clicking the mouse! Welcome to the l33t club of RS pro scripters. InB4AIODungScript.




3) Main Screen Basics


Here at SRL we refer to the screen where your player is as the mainScreen. In this section we will cover how to change the angle of the mainScreen, how to find objects (using colour finding), and how to check if text matches.


Changing the mainScreen angle


Changing the angle is useful as you probably want to make the angle high (like a birds eye view) after you login, as this makes it easier to play the game. You can change the mainScreen angle using the function:

mainScreen.setAngle(angle);

There are 2 angles built in to SRL-6. Each of these has a picture to demonstrate.

MS_ANGLE_LOW:


http://puu.sh/9ucyS/8bd8350638.PNG


MS_ANGLE_HIGH:


http://puu.sh/9uczt/5b6c34b488.PNG


This snippet will set the angle high, wait 3 seconds, and then set the angle low (try it if you want - just login manually):


program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure changeAngleBoss();
begin
mainScreen.setAngle(MS_ANGLE_HIGH);
wait(3000);
mainScreen.setAngle(MS_ANGLE_LOW);
end;

begin
clearDebug();
setupSRL();
changeAngleBoss();
end.




Finding objects on the mainScreen


Now let’s find objects on the screen and click them. Before we get into finding colours, let's do a quick section on text recognition. Recognising text is very important as it's used to recognise objects, NPC and items. When you hover your mouse over an object, a box pops up. We call this the mouseOverText. If I hover over this Evergreen Tree, this is the mouseOverText:


http://puu.sh/9ucAp/6012a239f7.PNG


Next we have the chooseOption menu. This is different to the mouseOverText so don't confuse them. The chooseOption menu pops up when you right click. If I right click an Evergreen Tree, this is the chooseOption menu:


http://puu.sh/9ucBr/c1a4f05941.PNG


Remember what both the mouseOverText and chooseOptions look like as we will use them later. Now let’s use a very general object finding function. This is the simplest form of the mainScreen.findObject function:

mainscreen.findObject(x, y, color, tolerance, mouseOverText, mouseAction);

We are going to attempt to right click an Evergreen Tree and select the 'Chop down Evergreen' option from the chooseOption menu. First we need to pick some colours of the tree. The image below is a screenshot of Auto Colour Aid (ACA), which we use to pick colours. If you don't know how to use this (or need to download it), please look at ACA section in my AIO tutorial (http://villavu.com/forum/showthread.php?t=107757) (it's about half way down). These are the colours I have picked from the tree (notice I’m just using CTS1 here - I'm only interested in the color and the RGB tolerance on the left of ACA).


http://puu.sh/9ucDg/18d065ec31.PNG


I need to put the colour and tolerance from ACA into that mainScreen.findObject function. I also need to put the mouseOverText and mouseAction. The mouseOverText can be any part of the text that appears in the mouseOverText pop up box (see picture above). I've chosen to use 'vergreen'. Note that text is case sensitive, meaning that 'Chop Tree' is not the same as 'Chop tree'. Since I’m right clicking the tree, the mouse action is MOUSE_RIGHT. I've put this together:


program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure clickTree();
var
x, y: integer; //we need to declare these variables since findObject outputs/requires these
begin
if mainscreen.findObject(x, y, 925721, 11, ['vergreen'], MOUSE_RIGHT) then
begin
writeLn('We right clicked a tree!'); // If findObject returns true, this will print
chooseOption.select(['hop down']); // This will choose ‘Chop down’ in chooseOptions menu
end;
end;

begin
clearDebug();
setupSRL();
clickTree();
end.


If I run this it will successfully find and click 1 evergreen tree. Try it if you want (you should probably pick your own colours). Note that this object finding function is very basic and can be a little bit unreliable in some cases. My AIO tutorial covers more advanced object finding techniques.






4) Backpack Basics


In this section we are going to cover the basics of dealing with the backpack.


Moving and clicking a backpack slot


First of all I’ll tell you how to move the mouse to a backpack slot and click. You could create your own mouseBox function like we did above, but there are easier ways already built into the SRL-6 include.

Take a look at the following function:

tabBackPack.mouseSlot(slot, mouseAction);

This can move and/or click any slot in the backPack. The slot parameter can be any number between 1 and 28, and the mouseAction you already know (move, left or right click). Look at the following picture:


http://puu.sh/9ucDX/06264a5818.PNG


If I wanted to move the mouse to the first backpack slot and hover over the logs I would use this:

tabBackPack.mouseSlot(1, MOUSE_MOVE);

Let’s combine a few things you've learnt already. I want to right click the item in the first slot and drop it, but only if it's a log. If I had a party hat in the first slot (which I normally do, obviously) I wouldn't want to drop that by mistake, so we need to check the mouseOverText first.


program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure dropItem();
begin
tabBackPack.mouseSlot(1, MOUSE_MOVE); // Move mouse to slot 1

if isMouseOverText(['raft Logs']) then // If text matches then start the next 'begin..end block'
begin
fastClick(MOUSE_RIGHT); // Right click
chooseOption.select(['rop Logs']); // Choose the drop option
writeLn('We dropped a log!');
end else
writeLn('There wasn''t a log in slot 1'); // If the mouseOverText didn't match, this will print instead

end;

begin
clearDebug();
setupSRL();
dropItem();
end.


Now you know how to move the mouse, left click, right click, check mouseOverText and select an option from the chooseOptions menu for any slot in the backpack! Now I will go over a few other useful backpack functions.


Waiting for the backpack count to change


The following function waits up to a maximum time for the backpack count to change:

tabBackPack.waitForShift(waitTime);

If I clicked a tree and I wanted to wait for a maximum of 5 seconds for the logs to appear in my inventory I would do this (and by max time I mean if you got logs after 1 second it would stop waiting).

tabBackPack.waitForShift(5000);

For example, in the clickTree() procedure I wrote above, I could simply add this line after I click the tree to wait for a log to appear in my backpack.


procedure clickTree();
var
x, y: integer;
begin
if mainscreen.findObject(x, y, 925721, 11, ['vergreen'], MOUSE_RIGHT) then
begin
writeLn('We right clicked a tree!');
chooseOption.select(['hop down']);
tabBackPack.waitForShift(5000); // After we click tree, wait for logs to appear
end;
end;




Checking if the backPack is full


Another useful function is tabBackPack.isFull(), which returns true if the backpack has an item in every slot. This is useful in many situations, such as if you’re mining or woodcutting and you want to keep mining until the backpack is full. Let’s use the example above of clicking the Evergreen Tree. I can make it repeat that procedure until the backpack is full.


program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure clickTree();
var
x, y: integer;
begin
if mainscreen.findObject(x, y, 925721, 11, ['vergreen'], MOUSE_RIGHT) then
begin
writeLn('We right clicked a tree!');
chooseOption.select(['hop down']);
tabBackPack.waitForShift(5000);
end;
end;

begin
clearDebug();
setupSRL();

repeat
clickTree(); // Repeat this procedure until we have 28 logs
until tabBackPack.isFull();

end.



Dropping items in the backPack


The last inventory function I’ll show you is how to easily drop items. There are a number of ways to drop items, such as dropping everything, different drop patterns, or only dropping specific slots. These are all accomplished with the function:

tabBackPack.dropItems();

There are a number of different dropping patterns. For example, I could drop all items in order starting at slot 1 all the way to slot 28, or I could start at slot 28 and work backwards. These are the drop patterns built into SRL-6:


DROP_PATTERN_REGULAR (slot 1 to 28)
DROP_PATTERN_BACKWARDS (slot 28 to 1)
DROP_PATTERN_SNAKE (slot 1 to 5, 10 to 6, 11 to 20, etc.)
DROP_PATTERN_UP_DOWN (Moves down the columns; slot 1, 6, 11, 16, 21, 26, 2, 7 etc.)

If I wanted to drop everything in order from slot 1 to slot 28 I would write:

tabBackPack.dropItems(DROP_PATTERN_REGULAR);

I can also drop only certain slots by putting all the slots I want to drop in an array. For example, if I wanted to drop slots 1, 3, 10, and 20 I could go:

tabBackPack.dropItems([1, 3, 10, 20]);

Let’s put this in our script to complete a basic power chopper! (like, OMG totally cool).


program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure clickTree();
var
x, y: integer;
begin
if mainscreen.findObject(x, y, 925721, 11, ['vergreen'], MOUSE_RIGHT) then
begin
writeLn('We right clicked a tree!');
chooseOption.select(['hop down']);
tabBackPack.waitForShift(5000);
end;
end;

begin
clearDebug();
setupSRL();

repeat // Notice the 2 repeat loops (1 repeats the whole script, 1 the chop tree procedure only)

repeat
clickTree();
until tabBackPack.isFull();

tabBackPack.dropItems(DROP_PATTERN_SNAKE); // Once backpack is full, it will drop everything

until false; // Until false means it will repeat this loop forever

end.


Well done on creating your first runescape script for RS3. You can now tell all of your friends you are a "pro scriptwriter".





5) Minimap Basics


In this section I want to cover the minimap. There are two functions I want to explain here; how to rotate the compass, and how to find and click minimap symbols.


http://puu.sh/9ucFh/a3b2a60fb7.PNG


Rotating the compass


Rotating the compass is done using the function:

minimap.setAngle(angle);

There are 4 angles already built in to SRL-6. These are:


MM_DIRECTION_NORTH
MM_DIRECTION_SOUTH
MM_DIRECTION_EAST
MM_DIRECTION_WEST


If I wanted to make the compass north I would go:

minimap.setAngle(MM_DIRECTION_NORTH);

I could also move it to any angle I wanted by writing the actual angle (from 0 to 360). For example, if I wanted it between North and East (i.e., 45 degrees) I would go:

minimap.setAngle(45);


Clicking minimap symbols


Minimap symbols are found using this function:

minimap.findSymbol(var TPoint, symbol, searchBox);

You can see the function takes 3 parameters, which I'll take you through below. The second parameter is the symbol you want to find. There are ~94 symbols in SRL-6, these are some of them (the full list with images can be found in this thread (https://villavu.com/forum/showthread.php?t=110849)):



MM_SYMBOL_TREE
MM_SYMBOL_RUNECRAFTING
MM_SYMBOL_MINING
MM_SYMBOL_BANK
MM_SYMBOL_LODESTONE


The last parameter, searchBox, is a TBox where you want to look for the symbol (remember we created a TBox above). Instead of creating your own box around the minimap interface, SRL-6 has allows you to get the boundaries of any interface (mainscreen, chatBox, etc.) by using:

.getBounds()

So to get a TBox around the minimap interface I can use:

minimap.getBounds()

I want to find and click the lodestone symbol, so I will use MM_SYMBOL_LODESTONE for the symbol:

http://puu.sh/cbFWX/01849382e0.jpg

So far my function looks like this:

minimap.findSymbol(var TPoint, MM_SYMBOL_LODESTONE, minimap.getBounds());

Now I'll explain the first parameter var TPoint. The var in front of the parameter means that it is an OUTPUT parameter, not INPUT parameter like the others. Basically, the coordinates of the symbol it finds are stored in this variable which you can use later (remember a TPoint is made up of X and Y coordinates).

As the TPoint is an output parameter, we need to declare a TPoint variable which will store the information it receives from the findObject function. You'll see below I've declared a TPoint called "myPoint". When it finds the lodestone symbol, the X and Y coordinates are stored in "myPoint". I then left click "myPoint" to make my player run to the symbol:


procedure clickTheLodestone();
var
myPoint: TPoint; // I've declared this TPoint.
begin
minimap.findSymbol(myPoint, MM_SYMBOL_LODESTONE, minimap.getBounds());

mouse(myPoint, MOUSE_LEFT); // Now we click 'myPoint' (the above function stored the coordinates of the symbol in 'myPoint');
end;








6) Bank Screen Basics


In this section I want to cover the basics with the bankScreen. This will include how to open and close the bank, and how to deposit and withdraw items. This is the RS3 bankScreen:


http://puu.sh/9BOGt/8dc5232e39.jpg



Opening and closing the bank


It is actually quite easy to open the bank as there is already a function built into SRL-6. This function is:

bankScreen.open(bankType);

where the bankType is the type of bank you are opening. The valid options for this are:



BANK_NPC_BLUE
BANK_NPC_GREY
BANK_NPC_GREEN
BANK_NPC_DRAYNOR
BANK_BOOTH
BANK_CHEST_SW
BANK_CHEST_SHANTAY
BANK_CHEST_DUEL
BANK_CHEST_CW
BANK_CHEST_GROTTO
BANK_TABLE_BURTHORPE
BANK_CHEST_LUMBRIDGE


For example, I'm standing in Varrock West Bank and I want to open the bank:


http://puu.sh/9BOs5/bcc29fe740.jpg



Since the bankers are blue, I would use the function:

bankScreen.open(BANK_NPC_BLUE);

Closing the bank is a lot easier. You just use the function:

bankScreen.close();



Depositing items


These are a number of ways to deposit items. I'll show you 3 ways: quick deposit, certain slots, and the preset buttons. There are other ways too, such as finding DTMs or bitmaps, but I won't cover those now.

The first function is the quickDeposit:

bankScreen.quickDeposit(depositType);

Where the depositType parameter is the quick deposit button you want to click. There are 4 buttons, which are:



QUICK_DEPOSIT_INVENTORY
QUICK_DEPOSIT_EQIUPMENT
QUICK_DEPOSIT_BOB
QUICK_DEPOSIT_MONEY_POUCH


For example, if I wanted to deposit all 28 of these logs into the bank, I would want to quick click the QUICK_DEPOSIT_INVENTORY button, like so:

bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);


http://puu.sh/9BQFB/cd0fc1e700.jpg


The second method is to deposit certain slots. If there are items which you don't want to deposit, it is best to deposit certain slots by using the function:

bankScreen.deposit(slots);

The slots parameter is an integer array (a set of numbers as opposed to an individual number). Arrays are filled inside square brackets. Here are a few examples of how I can fill this in:



[1..28] will deposit all slots from 1 to 28
[2..28] will ignore slot 1 and deposit the rest
[1, 2, 10] will deposit slots 1, 2 and 10, and ignore the rest.


Take the following example. I want to deposit the logs only, and ignore slot 1 (my axe) and slot 28 (my small pile of coins). I would write:

bankScreen.deposit([2..27]);


http://puu.sh/9BR3v/72c08d298a.jpg


The last method I'm going to show you is the preset buttons. You have to setup your presets in-game before using these. The good thing about this method it that it deposits, withdraws, and closes the bank all at the same time. This is the function:

bankScreen.clickButton(button);

Where the button parameter is one of the following:



BANK_BUTTON_PRESET_1
BANK_BUTTON_PRESET_2


For example, if I wanted to click the first preset button, I would use this:

bankScreen.clickButton(BANK_BUTTON_PRESET_1);


http://puu.sh/9BROA/e73ad85ea9.jpg




Withdrawing items


There is one function you need to know when withdrawing items, which is:

bankScreen.withdraw(slot, amount, mouseOverText);

Where the slot is the bank slot number, the mouseOverText you already know, and the amount is any number OR one of the following:



WITHDRAW_AMOUNT_ALL
WITHDRAW_AMOUNT_ALL_BUT_ONE


Bank slots start in the top left at 1, and go across the rows, and then down the columns. Like so:


http://puu.sh/9BSkW/df1ea99762.jpg


The 3rd parameter, the mouseOverText, just double checks that the item in the slot is the one you want to withdraw. You can leave this blank to ignore the text and withdraw any item. If I wanted to withdraw all of the coins I would go:

bankScreen.withdraw(20, WITHDRAW_AMOUNT_ALL, ['oins']);

Or if I wanted to withdraw 25 items in slot 8 (in this case law runes) I could go:

bankScreen.withdraw(8, 25, ['']);



Putting it all together


Now I'm going to put together everything you've learnt about the bankScreen into one simple program. Let's say I'm making a script that fletches logs into bows. I want to do the following:


Open the bank at Varrock West
Deposit everything in my inventory
Withdraw 28 oak logs, which are in slot 10
Close the bank


Read the following snippet and try and understand it:


program exampleBank;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure doBankingStuff();
begin

if bankScreen.open(BANK_NPC_BLUE) then // Open the bank
begin
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY); // Press the quick deposit button
wait(randomRange(1000, 2000));
bankScreen.withdraw(10, WITHDRAW_AMOUNT_ALL, ['']); // Withdraw all from slot 10
wait(randomRange(1000, 2000));
bankScreen.close(); // Close the bank
end else
writeLn('Couldn''t find the bank for some reason!');

end;

begin
clearDebug();
setupSRL();
doBankingStuff();
end.


I could also achieve the same result using the preset buttons (if I have setup my preset in-game previously):


program exampleBank;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure doBankingStuff();
begin

if bankScreen.open(BANK_NPC_BLUE) then
bankScreen.clickButton(BANK_BUTTON_PRESET_1) // This deposits, withdraws, and closes the bank
else
writeLn('Couldn''t find the bank for some reason!');

end;

begin
clearDebug();
setupSRL();
doBankingStuff();
end.






7) ActionBar Basics


In this section I want to cover the actionBar. I'll show you how to click (and key press) actionBar slots, how to reading the player's HP/Adrenaline/Prayer/Summoning percent, and enable or disable auto-retaliate.

http://puu.sh/cbG9a/af9723e84f.jpg


Clicking an actionBar slot



To click an actionBar slot using the mouse, you could make a mouseBox like we did right at the beginning, but you should use this function:

actionBar.clickSlot(slot, mouseAction)

Where the slot is a number from 1 to 14, and the mouseAction you should already know from above.

If I wanted to left click the slice ability (in slot 1), I would write:

actionBar.clickSlot(1, MOUSE_LEFT)

To actually type '1' using the keyboard instead of clicking with the mouse, I can use this function:

typeSend(text, pressEnter)

The first parameter is a string, and the second is a boolean, so to type 1 and not press enter, I would write:

typeSend('1', false)


Getting the players HP/Adrenaline/Prayer/Summoning percentage



You can return the players current HP percent (and the other stats) as an integer. Each of these stats has a slightly different function, but they are used in exactly the same way:


actionBar.getHPPercent();
actionBar.getAdrenalinePercent();
actionBar.getPrayerPercent();
actionBar.getSummoningPercent();


If I wanted to print my current HP percent I could write:


program actionBarExample;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure actionBarTest();
var
myHP: integer;
begin
myHP := actionBar.getHPPercent(); // Now the 'myHP' variable is holding our current HP
writeLn(myHP);
end;

begin
clearDebug();
setupSRL();
actionBarTest();
end.



Enabling or disabling auto-retaliate



You can enable of disable auto-retaliate by clicking the retaliate button. To do this we use the function:

actionBar.setRetaliate(enabled);

The 'enabled' parameter is a boolean, so it can be either True or False. If I wanted to enable retaliate I would write:

actionBar.setRetaliate(True);






8) DepositBox Basics


In this section I want to cover the depositBox. This is basically the same as the bankScreen section above, so I will quickly skim over this without going into too much detail. I'll show you how to deposit items by clicking them, and by using the deposit buttons at the bottom of the interface.

http://puu.sh/e06Ul/c4ffd636e5.png


Depositing items in the DepositBox



The first method is by using the quick deposit button. The button you will use the most is the inventory button:

depositBox.quickDeposit(QUICK_DEPOSITBOX_INVENTORY );

Just like the bankScreen, there are 3 other constants which you can use instead of the INVENTORY button:


QUICK_DEPOSITBOX_EQUIPMENT
QUICK_DEPOSITBOX_BOB
QUICK_DEPOSITBOX_MONEY_POUCH

The next deposit method is to click the actual items. Again, this is identical to the bankScreen code, except you are calling it through the depositBox interface type. To deposit slots 2 to 28 I would write:

depositBox.deposit([2..28]);

Once you have finished depositing items, you can close the depositBox by writing:

depositBox.close();






9) LodestoneScreen Basics


In this section I want to cover the lodestoneScreen. I'll show to show you how to lodestone teleport to any location.

http://puu.sh/cbFOa/cbfe080d5a.jpg


Lodestone teleporting



Teleporting via the lodestone network is very easy in SRL-6. There is just one function you need to be familiar with.

lodestoneScreen.teleportTo(location);

This function opens the lodestoneScreen and clicks the location you set. The location can be one of 23 locations. Here are some examples:


LOCATION_EDGEVILLE
LOCATION_FALADOR
LOCATION_PORT_SARIM
LOCATION_VARROCK
LOCATION_DRAYNOR_VILLAGE
LOCATION_LUMBRIDGE

If I wanted to teleport to Varrock I would write:

lodestoneScreen.teleportTo(LOCATION_VARROCK);

This function also checks that the lodestone is unlocked, and that it isn't P2P, so you don't try and click something that you cannot.







10) ToolScreen Basics


In this section I'll cover the ToolScreen, which is the interface that pops up when you first click a log, or try and use a needle for crafting. I'll show you how to select a tool from this interface.

http://puu.sh/e0jdD/16f8b53bf5.jpg


Selecting a tool



There are two ways to select a tool. You can either select a tool using a string (i.e., the name of the tool, like 'Needle'), or the slot number where the tool is located. Here are two ways to select the Knife in the above image:

toolScreen.select('Knife');

And since the knife is in the second position, I can use the integer:

toolScreen.select(2);

I'll cover the next 2 interfaces before combining these in a practical example.







11) ProductionScreen Basics


In this section I want to cover the ProductionScreen, which is used in many skills, such as smithing, cooking, and fletching. Firstly, I'll show you how to select an item, and then click the start button.

http://puu.sh/cbG3i/047b89aa3c.jpg


Selecting an item



To select an item, all you need to know is what slot the product is in. Like all the slots in SRL-6, they start at the top-left, go across the row, and then down to the next column. If I wanted to click the arrow shafts in the above image, I would write:

productionScreen.selectBox(1);


Clicking the start button



Once the item is selected, then you most likely want to press the start button. This is very simple, and all you have to write is:

productionScreen.clickStart();

Once you click the start button, the progressScreen will open (which is covered in the next section).






12) ProgressScreen Basics


In this section I'll cover the ProgressScreen. The only thing that you really want to do with the progressScreen is wait until it's no longer open, or until the 'Cancel' button changes to the 'Done' button.

http://puu.sh/cbG5V/738a693e60.jpg


Wait until the progressScreen is no longer open



All interfaces in SRL-6 (like the bankScreen, depositBox, lodestoneScreen etc.) have a boolean function:

.isOpen(waitTime);

This function returns true if the interface is open. The 'waitTime' parameter is optional, and it's used if you want to wait a few seconds for the interface to open. You can use the result of this function to tell when the progressScreen (or any other interface) is no longer open. In the following snippet, I will put together some of the code you've already learnt from the backpack, toolScreen, productionScreen, and progressScreen interfaces:


program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure makeSomeArrowShafts();
begin

tabBackpack.mouseSlot(1, MOUSE_LEFT); // Left click backpack slot 1 (e.g., logs)

if toolScreen.isOpen(2000) then // If the toolScreen is open within 2 seconds, click the Knife
toolScreen.select('Knife');

if productionScreen.isOpen(5000) then // If productionScreen is open within 5 seconds
begin
productionScreen.selectBox(1); // Select the first box (arrow shafts)
productionScreen.clickStart(); // Click the start button

if progressScreen.isOpen(5000) then // if progressScreen is open within 5 seconds
begin
writeLn('The progressScreen is open!');

repeat
wait(1000);
until (not progressScreen.isOpen()); // Repeat waiting 1 second until it's not open anymore

end;

end;

end;

begin
clearDebug();
setupSRL();
makeSomeArrowShafts();
end.


You could literally combine this little script with the woodcutting example in the above section, and you just about have a fully functional arrow shaft maker! Or you could combine this with the banking snippet above to cut bows, cut gems, crush chocolate...whatever you want!



Getting the progressScreen button



If you want your script to be a little bit faster, you can wait for the progressScreen 'Done' button (or until the 'Cancel' button is no longer present). You can get the current button using the function:

progressScreen.getButton();

Instead of waiting until the progressScreen is no longer open, I could change that loop to wait until the button is not equal to the cancel button:


repeat
wait(1000);
until (progressScreen.getButton() <> PROGRESS_BUTTON_CANCEL);








13) PowersScreen Basics


In this section I'll cover the PowersScreen, which is mainly used in combat related scripts. Using this interface, you can change your combat mode (e.g., momentum, revolution), modify the experience types for each combat style (e.g., defence XP for ranged combat style), and add abilities to the action bar.

http://puu.sh/e0ygr/5bc7cb0169.jpg


Selecting a combat mode



In RS3 there are now 3 combat modes: Full Manual, Revolution, and Momentum, as seen on the left side of the image above. You can set the combat mode using the function:

powersScreen.setCombatMode(combatMode);

The combat mode can be one of the following:



MODE_MANUAL
MODE_REVOLUTION
MODE_MOMENTUM


If I wanted to set my player's combat mode to momentum (like it is in the above image), I would write:

powersScreen.setCombatMode(MODE_MOMENTUM);

These powersScreen functions automatically open the powersScreen if it's not already open, making it very easy for you as a scripter.


Setting combat experience



On the right-hand side of the above image, there are different XP selection settings, for each of the three combat styles. You can set the experience type, for a particular combat style using the function:

powersScreen.setCombatExperience(combatStyle, ExperienceType);

The combat style can be one of the following:



MELEE_STYLE
RANGED_STYLE
MAGIC_STYLE


and the ExperienceType can be one of the following:



XP_BALANCED
XP_RANGED_AND_DEFENCE
XP_MAGIC_AND_DEFENCE
XP_ATTACK
XP_STRENGTH
XP_RANGED
XP_MAGIC
XP_DEFENCE


For example, if I wanted to set my player's melee combat style to defence XP, I would write:

powersScreen.setCombatExperience(STYLE_MELEE, XP_DEFENCE);

This function also prevents you from doing something silly, like setting the melee combat style to rangedXP.



Adding abilities to the actionBar



A great feature of the powersScreen is the ability to add abilities to the actionBar for customised setups. There are over 140 different abilities that you can add to the actionBar with the following function:

powersScreen.addAbilityToActionBar(ability, slot);

The 'slot' parameter is the actionBar slot number where you want to add the ability. If an ability already exists in the slot, it will clear the previous ability before adding the new one. The ability parameter can be one of many, here are some examples:



PS_SLICE
PS_HAVOC
PS_AIR_BOLT
PS_VARROCK_TELEPORT
PS_LVL_6_ENCHANT


As I said, there are over 140 different abilities. The full list can be found in the spoiler below:


{ Attack Abilities }
PS_SLAUGHTER
PS_SLICE
PS_OVERPOWER
PS_HAVOC
PS_BACKHAND
PS_FORCEFUL_BACKHAND
PS_SMASH
PS_BARGE
PS_FLURRY
PS_SEVER
PS_HURRICANE
PS_MASSACRE
PS_METEOR_STRIKE
PS_BALANCED_STRIKE

{ Strength Abilities }
PS_STOMP
PS_KICK
PS_PUNISH
PS_DISMEMBER
PS_FURY
PS_DESTROY
PS_QUAKE
PS_BERSERK
PS_CLEAVE
PS_ASSAULT
PS_DECIMATE
PS_PULVERISE
PS_FRENZY

{ Ranged Abilities }
PS_PIERCING_SHOT
PS_SNAP_SHOT
PS_DEADSHOT
PS_SNIPE
PS_DAZING_SHOT
PS_BINDING_SHOT
PS_NEEDLE_STRIKE
PS_TIGHT_BINDINGS
PS_FRAGMENTATION_SHOT
PS_ESCAPE
PS_RAPID_FIRE
PS_RICOCHET
PS_BOMBARDMENT
PS_INCENDIARY_SHOT
PS_UNLOAD
PS_DEATHS_SWIFTNESS

{ Magic Abilities }
PS_ASPHYXIATE
PS_WRACK
PS_OMNIPOWER
PS_DRAGON_BREATH
PS_SONIC_WAVE
PS_IMPACT
PS_CONCENTRATED_BLAST
PS_DEEP_IMPACT
PS_COMBUST
PS_SURGE
PS_DETONATE
PS_CHAIN
PS_WILD_MAGIC
PS_METAMORPHOSIS
PS_TSUNAMI
PS_SUNSHINE

{ Magic Combat Spells }
PS_AIR_STRIKE
PS_CONFUSE
PS_WATER_STRIKE
PS_EARTH_STRIKE
PS_WEAKEN
PS_FIRE_STRIKE
PS_AIR_BOLT
PS_CURSE
PS_BIND
PS_WATER_BOLT
PS_EARTH_BOLT
PS_FIRE_BOLT
PS_AIR_BLAST
PS_WATER_BLAST
PS_SNARE
PS_SLAYER_DART
PS_EARTH_BLAST
PS_FIRE_BLAST
PS_DIVINE_STORM
PS_AIR_WAVE
PS_WATER_WAVE
PS_VULNERABILITY
PS_EARTH_WAVE
PS_ENFEEBLE
PS_FIRE_WAVE
PS_STORM_OF_ARMADYL
PS_ENTANGLE
PS_POLYPORE_STRIKE
PS_STAGGER
PS_AIR_SURGE
PS_WATER_SURGE
PS_TELEPORT_BLOCK
PS_EARTH_SURGE
PS_FIRE_SURGE

{ Magic Teleport Spells }
PS_HOME_TELEPORT
PS_MOBILISING_ARMIES_TELEPORT
PS_VARROCK_TELEPORT
PS_LUMBRIDGE_TELEPORT
PS_FALADOR_TELEPORT
PS_HOUSE_TELEPORT
PS_CAMELOT_TELEPORT
PS_ARDOUGNE_TELEPORT
PS_WATCHTOWER_TELEPORT
PS_GOD_WARS_DUNGEON_TELEPORT
PS_TROLLHEIM_TELEPORT
PS_APE_ATOLL_TELEPORT
PS_TELE_OTHER_LUMBRIDGE
PS_TELE_OTHER_FALADOR
PS_TELE_OTHER_CAMELOT

{ Magic Skilling Spells }
PS_ENCHANT_CROSSBOW_BOLT
PS_LVL_1_ENCHANT
PS_BONES_TO_BANANAS
PS_LOW_LEVEL_ALCHEMY
PS_LVL_2_ENCHANT
PS_TELEKINETIC_GRAB
PS_SUPERHEAT_ITEM
PS_LVL_3_ENCHANT
PS_HIGH_LEVEL_ALCHEMY
PS_CHARGE_WATER_ORB
PS_LVL_4_ENCHANT
PS_BONES_TO_PEACHES
PS_CHARGE_EARTH_ORB
PS_CHARGE_FIRE_ORB
PS_CHARGE_AIR_ORB
PS_LVL_5_ENCHANT
PS_LVL_6_ENCHANT

{ Defensive Abilities }
PS_ANTICIPATION
PS_BASH
PS_REVENGE
PS_PROVOKE
PS_IMMORTALITY
PS_FREEDOM
PS_REFLECT
PS_RESONANCE
PS_REJUVENATE
PS_DEBILITATE
PS_PREPARATION
PS_BARRICADE

{ Constitution Abilities }
PS_WEAPON_SPECIAL_ATTACK
PS_REGENERATE
PS_SIPHON
PS_INCITE


For example, if I wanted to put the slice melee ability into the first actionBar slot (as in the image above) I would write:

powersScreen.addAbilityToActionBar(PS_SLICE, 1);








14) ConversationBox Basics


In this section I'll cover the ConversationBox. The conversationBox appears when ever you are talking to someone, and sometimes when you get game notifications. Sometimes you need to proceed through the conversation by clicking the continue button, and selecting conversation options.

Pressing the continue button



http://puu.sh/e0C8n/c6dbc18529.jpg

conversationBox.continue(spaceBar, wait);

conversationBox.continue(True, True);



Selecting a conversation option



http://puu.sh/e0CeP/71520f5dda.jpg

conversationBox.selectOption(2);

conversationBox.selectOption(['PIN']);







15) ChatBox Basics


In this section I'll cover the ChatBox.

http://puu.sh/e0CSf/de7f802d82.png


Reading the XP Bar




chatBox.getXPBar();





Finding text on lines




chatBox.findTextOnLines(['ello'], [1..5]);









16) CollectBox Basics


In this section I'll cover the CollectBox.

http://puu.sh/e0D4n/c1e7af76b8.png


Pressing a collect button




collectBox.collectButton(button);



COLLECT_BUTTON_BANK
COLLECT_BUTTON_INV


collectBox.collectButton(COLLECT_BUTTON_BANK)







17) GrandExchange Basics


GrandExchange compatibility was recently added to SRL-6, and in this section I'll show you how to buy and sell items, and how to look-up prices.

http://puu.sh/eCu7n/7a70bc1178.png



Selling an item on the GE



Selling an item is very easy, and can be done with the function:

grandExchange.sellItem(packSlot, price, quantity);

The first parameter is the backpack slot where the item you're selling is located. In the above image, you can see I have 1000 noted Swamp toads in the first backpack slot, so packSlot would be 1.


The 'price' parameter is a string; valid options are:

'mid'
'-5'
'+5'
Any other number


The 'quantity' parameter is a string; valid options are:

'1'
'10'
'100'
'all'
Any other number



So if I wanted to sell all of my Swamp toads at 5% above the current mid price, I would write:

grandExchange.sellItem(1, '+5', 'all');

and if I wanted to sell 50 of them for 2000 each, I would write:

grandExchange.sellItem(1, '2000', '50');



Buying an item on the GE



Buying an item is similar to selling an item; the function is:

grandExchange.buyItem(itemName, price, quantity);

The itemName is the name of the item you are buying (make sure it's accurate). The only difference to the 'price' and 'quantity' parameters when buying an item is that there is no 'All' option for the quantity (as you cannot buy 'all' of an item).


The 'price' parameter is a string; valid options are:

'mid'
'-5'
'+5'
Any other number


The 'quantity' parameter is a string; valid options are:

'1'
'10'
'100'
Any other number


If I wanted to buy 5000 Swamp toads at mid price, I would write:

grandExchange.buyItem('Swamp toad', 'mid', '5000');



Looking up the price of an item



With the following function you can return the current mid price of any item on the grand exchange:

grandExchange.getPrice(item);

The 'item' parameter is an integer; it's ID number.

For example, if I wanted to find the price of a Swamp toad, I would use Swamp toad's ID, which is 2150:

grandExchange.getPrice(2150);

Item IDs can be found on the on the item's Grand Exchange webpage. The webpage for Swamp toads is:

http://services.runescape.com/m=itemdb_rs/Swamp_toad/viewitem.ws?obj=2150

and you will notice the last 4 digits of the URL are the item's ID number. Alternatively, you could look up IDs at itemdb.biz







18) Loot Screen Basics


Recently Jagex added the loot screen as a new way to collect drops. In this section I'll show you some of the lootScreen methods available to you.

http://puu.sh/hKH9y/1342c9ceb1.png


Looting certain slots



You can loot an individual slot with:
lootScreen.lootSlot(1);

Or you can loot an array of slots with:
lootScreen.lootSlots([1, 2, 3, 14]);



Looting DTMs



I haven't covered how to make a DTM in this tutorial, so if you don't know how to make an item DTM you better go and read my AIO Beginners Guide!

To loot a single DTM:
lootScreen.lootDTM(MyDTM);

Or you can loot an array of DTMs:
lootScreen.lootDTMs();

Both of these methods will loot ALL of the matching DTMs.



[B]Using the loot buttons



lootScreen.clickButton(LOOT_BUTTON_ALL);

lootScreen.clickButton(LOOT_BUTTON_CUSTOM);

So to give you an example snippet:


procedure lootStuff();
begin
// if mainScreen.findObject(.....) // Clicking ground loot

if lootScreen.isOpen(5000) then
begin
lootScreen.lootSlots([1, 2, 3, 4]);
writeLn('We just looted the first 4 slots');
lootScreen.close();
end;

end;

beefman
06-15-2014, 10:19 AM
Much appreciated, Mayor! This will be unimaginably useful! Loving the Evergreen pic XD

Gunner
06-15-2014, 03:20 PM
This is even more noob-friendly than your AIO tut. Wish we had this a few months ago when I started lol. Oh well, at least this gives me a "back in my day, we didn't have all this fancy..." :P

Great guide, good job.

SeaHorseShooter
06-20-2014, 06:29 AM
None of the code is working for me? The writeLn and stuff works, but when it involves launching SMART nothing works. The cameras don't move, the mouse does not move to click on the options on the one part nothing. Any help?

The Mayor
06-20-2014, 06:34 AM
None of the code is working for me? The writeLn and stuff works, but when it involves launching SMART nothing works. The cameras don't move, the mouse does not move to click on the options on the one part nothing. Any help?

Have you included SMART and SRL6 at the top of the script?

{$DEFINE SMART}
{$I SRL-6/SRL.simba}


and have you

setupSRL();

in your Main Loop?

SeaHorseShooter
06-20-2014, 06:37 PM
Have you included SMART and SRL6 at the top of the script?

{$DEFINE SMART}
{$I SRL-6/SRL.simba}


and have you

setupSRL();

in your Main Loop?

I have typed exactly what you have and even tried to paste the code you have into simba
program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure practiceMouse();
begin
mouse(200, 200, MOUSE_MOVE);
wait(3000);
mouse(50, 50, MOUSE_MOVE);
wait(3000);
fastClick(MOUSE_RIGHT);
writeLn('We just right clicked');
wait(3000);
mouse(300, 30, MOUSE_MOVE);
end;

begin
clearDebug();
setupSRL();
practiceMouse();
end.

even tried with the camera code, still didn't work I have no clue whats wrong.

SeaHorseShooter
06-20-2014, 06:38 PM
does not even say in the console 'We just right clicked'.

The Mayor
06-20-2014, 08:49 PM
does not even say in the console 'We just right clicked'.

Either your interfaces are not set correctly, or your graphics settings are not correct. I assume you have run a rs3 script before? I can TV you if you like? Skype the.mayor.rs

SeaHorseShooter
06-20-2014, 09:56 PM
Either your interfaces are not set correctly, or your graphics settings are not correct. I assume you have run a rs3 script before? I can TV you if you like? Skype the.mayor.rs
I got it working! Turns out I messed up some stuff on my graphics settings. Thank you! :)

Truncheon
07-02-2014, 07:19 PM
What a very well written and in-depth guide. A nice slow introduction to from the basics to the nitty gritty to set almost anyone with at least half a brain to scripting delight. It would be bad to not say thanks, so thank you!

Penguin
07-12-2014, 12:37 AM
Excellent guide, but I'm trying to get my banking down, the depositing is working okay but whenever I try to withdraw anything I get this

Exception in Script: Runtime error: "The given DTM Index[1] doesn't exist" at line 701, column 20 in file "C:\Simba\Includes\srl-6\lib\utilities\wrappers.simba"
The following bitmaps were not freed: [Minimap Mask]
File[C:\Simba\Includes\SRL-6/logs/SRL log (11-07-14 at 05.33.10 PM).txt] has not been freed in the script, freeing it now.

any help would be great :)

The Mayor
07-12-2014, 01:02 AM
Excellent guide, but I'm trying to get my banking down, the depositing is working okay but whenever I try to withdraw anything I get this

Exception in Script: Runtime error: "The given DTM Index[1] doesn't exist" at line 701, column 20 in file "C:\Simba\Includes\srl-6\lib\utilities\wrappers.simba"
The following bitmaps were not freed: [Minimap Mask]
File[C:\Simba\Includes\SRL-6/logs/SRL log (11-07-14 at 05.33.10 PM).txt] has not been freed in the script, freeing it now.

any help would be great :)

Post your code.

Penguin
07-12-2014, 01:28 AM
program Suhsuhsoopaheetin;
{$DEFINE SMART}
{$i srl-6/srl.simba}

Var
x, y:integer;
CastBox, CoalBagBox, CoalBagDrop: TBox;


Procedure Graphics;
begin
minimap.setAngle(MM_DIRECTION_SOUTH);
end;
Procedure MakingBoxes;
begin
CastBox := intToBox(630, 365, 662, 392);
CoalBagBox := intToBox(600, 90, 630, 120);
CoalBagDrop := intToBox(595, 143, 643, 156);
//CoalWithdraw :=
//RuniteWithdraw :=
end;

Procedure SuperHeating;

begin
MouseBox(CastBox, MOUSE_MOVE);
If (isMouseOverText(['unite ore']))then
begin
repeat
KeyDown(49);
Wait(randomRange(20, 25));
Keyup(49);
Wait(randomRange(50, 150));
fastclick(MOUSE_LEFT);
Wait(randomRange(1500, 350));
until
(isMouseOverText(['une bar']));
end;
end;

//Procedure OpeningBank;
//begin
//end;

Procedure Banking;


Var
Coal, Runite, Runebar: Integer;

begin
Coal := 1;
Runite := 2;
RuneBar :=3;
bankScreen.deposit([3..8]);
wait(randomRange(150, 350));
bankScreen.withdraw(Coal, WITHDRAW_AMOUNT_ALL);
wait(randomRange(150, 350));
MouseBox(CoalBagBox, MOUSE_RIGHT);
wait(randomRange(10, 100));
MouseBox(CoalBagDrop, MOUSE_MOVE);
wait(randomRange(10, 100));
fastclick(MOUSE_LEFT);
wait(randomRange(150, 350));
bankScreen.withdraw(Runite, 5);
wait(randomRange(150, 350));
bankScreen.withdraw(Coal, WITHDRAW_AMOUNT_ALL);
end;
begin
clearDebug();
setupSRL();
Graphics();
MakingBoxes();
Banking();
//SuperHeating();
TerminateScript();
end.

edited:
Even if i commented out the integers and set the withdraw to just 1 or 2 or w/e, I get the same error

The Mayor
07-12-2014, 02:00 AM
edited:
Even if i commented out the integers and set the withdraw to just 1 or 2 or w/e, I get the same error

Ahh. Sorry I forgot the last parameter in the withdraw function (mouseOverText). I've updated it :)

Penguin
07-12-2014, 02:02 AM
Ah, Thank you :D

Crit
07-21-2014, 12:32 PM
Nice one mayor! Btw a little spelling error just under the picture for withdrawing items in bank. Says "mosueOverText" ;) well written guide though!!

The Mayor
07-23-2014, 10:24 AM
Nice one mayor! Btw a little spelling error just under the picture for withdrawing items in bank. Says "mosueOverText" ;) well written guide though!!

DemTypos. I never raed what I type.

theorange
07-26-2014, 02:51 AM
This is fantastic beginners guide to RS3 scripting, I found it to be great in explaining the language and using different aspects of it. Great job!

KeepBotting
07-27-2014, 11:27 PM
This is wonderful. Reminds me of Griff's SRL-5 tutorial, which I used to begin scripting.

Korasi spec FTW
07-30-2014, 08:07 AM
I'm new to this. Tried to start up SMART, and this shows on the debug panel:



-- setupSRL()
---- Setting up SRL...
---- initSmart():
------ Attempting to pair to a previously spawned client
------ smartPairToExistingClient():
-------- Found no free clients to pair to
------ smartPairToExistingClient(): result = false
------ Attempting to spawn a new client..
------ smartCreateClient():
---------- smartGetParameters(): Succesfully grabbed paramters
-------- getJavaPath():
---------- Attempting to search for your Java path
---------- ERROR: Failed To Find Path: C:\Program Files (x86)\Java\
---------- WARNING: Failed to find your Java path
---------- HINT: If RS is failing to switch to OpenGL mode, add JRE to your systems path before JDK (if you have JDK)
-------- getJavaPath()
-------- Using parameters [http://world12.runescape.com/, f52784816396786405]
-------- Using plugins "OpenGL32.dll"
-------- FATAL ERROR: Failed to spawn a SMART client
Successfully executed.


What do I do?

Lipcot
07-30-2014, 06:58 PM
Thanks a lot for this mayor, im a new user trying to script and your guides are awesome and really well explained

Spaceblow
08-01-2014, 01:22 PM
This must be the best guide that I've ever read, everything is explained really well. You're a good person.

The Mayor
08-03-2014, 04:40 AM
This is fantastic beginners guide to RS3 scripting, I found it to be great in explaining the language and using different aspects of it. Great job!


This is wonderful. Reminds me of Griff's SRL-5 tutorial, which I used to begin scripting.


Thanks a lot for this mayor, im a new user trying to script and your guides are awesome and really well explained


This must be the best guide that I've ever read, everything is explained really well. You're a good person.

Why thank you :o

Adieux
08-04-2014, 09:37 PM
Im trying to follow this guide as I want to learn to script but for some reason, some of the code you're showing here doesnt want to compile in my simba.

For example, I type FastClick(Mouse_left); And it says 'Unknown declaration "fastclick" at line 3, column 1"
Anything wrong here or have the declarations been changed to something different.

I've updated the extensions and simba, but no go.

Thanks for any help!

The Mayor
08-04-2014, 09:52 PM
Im trying to follow this guide as I want to learn to script but for some reason, some of the code you're showing here doesnt want to compile in my simba.

For example, I type FastClick(Mouse_left); And it says 'Unknown declaration "fastclick" at line 3, column 1"
Anything wrong here or have the declarations been changed to something different.

I've updated the extensions and simba, but no go.

Thanks for any help!

Well, fastClick is a function built into SRL6, so you have to 'include' the SRL6 files at the top of your script to give simba access to them. Make sure you have:

{$I SRL-6/SRL.simba}

at the top, and then

setupSRL

at the start of your main loop, just like it shows you.

Adieux
08-04-2014, 11:04 PM
Well, fastClick is a function built into SRL6, so you have to 'include' the SRL6 files at the top of your script to give simba access to them. Make sure you have:

{$I SRL-6/SRL.simba}

at the top, and then

setupSRL

at the start of your main loop, just like it shows you.

Oh ok Sorry about that!
I got it to work thank you very much!

Adieux
08-05-2014, 01:49 AM
Sorry for posting again, trying to withdraw some maple logs
when I enter "aple" or "logs" as the mouse over text it opens bank, looks for the logs, but doesnt recognize it and it terminates the script.
I tried switching the item to fellstalk herbs and used that for mouse over text but it worked fine, just wont work with maple logs.

Any idea what might be going on?

lanadekat
08-05-2014, 12:30 PM
Sorry for posting again, trying to withdraw some maple logs
when I enter "aple" or "logs" as the mouse over text it opens bank, looks for the logs, but doesnt recognize it and it terminates the script.
I tried switching the item to fellstalk herbs and used that for mouse over text but it worked fine, just wont work with maple logs.

Any idea what might be going on?
You can just put maple logs in slot 1 and use:
bankScreen.withdraw(1, WITHDRAW_AMOUNT_ALL, ['']);

1 = the bankslot, so you can put it in wathever bank slot you want.

Adieux
08-05-2014, 04:31 PM
You can just put maple logs in slot 1 and use:
bankScreen.withdraw(1, WITHDRAW_AMOUNT_ALL, ['']);

1 = the bankslot, so you can put it in wathever bank slot you want.

Yeah I was going to do this but, if the logs run out will the script keep withdrawing anything from slot 1?

theorange
08-08-2014, 10:03 PM
Yeah I was going to do this but, if the logs run out will the script keep withdrawing anything from slot 1?

Have the script check, after your withdraw function, to see what the backpack count is.

backpack.count() Is what i think the function is, it will return an integer, if the number it returns is less than 28, break out of the script, as you have no more logs left in the bank.

Marius90
08-17-2014, 02:40 PM
Hi nice tutorial i learned a few things from here , anyway i wanted to make a script to spread ashes for prayer skill ... i wanted to use the preset button code and action bar ... and i cant find the action bar code ... could somene help me please.
Thank You!

The Mayor
08-17-2014, 09:07 PM
Hi nice tutorial i learned a few things from here , anyway i wanted to make a script to spread ashes for prayer skill ... i wanted to use the preset button code and action bar ... and i cant find the action bar code ... could somene help me please.
Thank You!

I guess I could add an action bar section. To click slot 1:

actionBar.clickSlot(1, MOUSE_LEFT)

Marius90
08-17-2014, 10:58 PM
Thanks for replaying ...i found this code in iBuryBones script
typeSend('1', false);
wait(randomRange(500, 700));
until tabBackpack.count() = 0 or chatbox.findAnyText(['ave any lef']);
Do you think this could work for me to ? didn't had time to test

The Mayor
08-18-2014, 03:20 AM
Do you think this could work for me to ? didn't had time to test

I can't test everything for you too...

Marius90
08-18-2014, 09:48 AM
Hi, I tested that code and it does work really well.. anyway i asked you maybe you have encounterd that code before and you may know if it would worked ...anyway thank you for your replyes

Lama
09-26-2014, 12:21 AM
You should emphasize case sensitivity for isMouseOverText and chooseOption.select, in the sense of (['rop Logs']), not (['rop logs']). It wasn't entirely apparent for me at least, but I figured it out quickly enough.

The Mayor
09-26-2014, 09:00 AM
You should emphasize case sensitivity for isMouseOverText and chooseOption.select, in the sense of (['rop Logs']), not (['rop logs']). It wasn't entirely apparent for me at least, but I figured it out quickly enough.

It's a good idea to mention that. Done!

tulpiuka
10-04-2014, 10:38 AM
Nice now i have a grasp of what is what. Now all that's left is the rest... which is a lot. My first attempt will probably be a bunch of copy and paste from all the scripts i have and see if i can make something work. Can't wait for action bar basics. Trying to find out how to press actionbar slot with a keyboard. Not with a mouse. Is there some kind of manual for these things in github? I found something there but i dont know if it's up to date.

The Mayor
10-04-2014, 11:22 AM
Nice now i have a grasp of what is what. Now all that's left is the rest... which is a lot. My first attempt will probably be a bunch of copy and paste from all the scripts i have and see if i can make something work. Can't wait for action bar basics. Trying to find out how to press actionbar slot with a keyboard. Not with a mouse. Is there some kind of manual for these things in github? I found something there but i dont know if it's up to date.

You can click an action bar slot

mouseBox(actionbar.getSlotBox(1), MOUSE_LEFT);

Or you can type '1' using typeSend(text: string; pressEnter: boolean = true);

To type 1 and not press enter:

typeSend('1', false)

To type 1 and press enter:

typeSend('1', true)

but you will see pressEnter is actually true by default, so if you leave that parameter blank, it will resort to the default. So to press enter after typing you could simply:

typeSend('1')


I hope to finish the other sections sometime! You should open the include files in C:/simba/includes/srl6/lib/ and have a look at the function list on the left to see what's available.

tulpiuka
10-04-2014, 12:58 PM
procedure Spellcast; // Presses 1 to cast spell
begin
KeyDown(31);
wait(RandomRange(30, 100));
KeyUp(31);
end

I ended up finding this. (it's most human like key press?) The problem is the script does one loop (sometimes fails) then the second one comes and 100% fail. I assume it presses up and down while the bank is open or actionbar isn't loaded. Added a waitRandom but it didn't help.

Probably found the problem. Gonna try something.

GodMatic
10-09-2014, 01:01 AM
very in depth guide I like it, very easy to understand

IROC-Z
10-15-2014, 05:49 PM
For minimap.setAngle(45) can it be set to a range of angles? For example having it turn to an angle between 40 and 50 with a gaussian distribution or an normal distribution. I want to detect the vines in the Karamja Dungeon, so a west angle, I think it is west ha, would be best but don't want it to go exactly west each time.

Olly
10-15-2014, 05:50 PM
For minimap.setAngle(45) can it be set to a range of angles? For example having it turn to an angle between 40 and 50 with a gaussian distribution or an normal distribution. I want to detect the vines in the Karamja Dungeon, so a west angle, I think it is west ha, would be best but don't want it to go exactly west each time.

Minimap.setAngle(Random(40, 50));
Minimap.setAngle(GaussRangeInt(40, 50));

IROC-Z
10-15-2014, 06:00 PM
Minimap.setAngle(Random(40, 50));
Minimap.setAngle(GaussRangeInt(40, 50));

Thanks! I figured it would be something like that, just wasn't sure where the random/gauss and parenthesis would fall.

victordono
10-23-2014, 08:33 PM
Would you use the mouseoverobject for picking up items as well ? can you write a little tutorial on looters ?

The Mayor
10-24-2014, 09:52 PM
Would you use the mouseoverobject for picking up items as well ? can you write a little tutorial on looters ?


mouseOverObject?


You could use mainScreen.findObject, the same way you find the tree.

victordono
10-24-2014, 11:18 PM
Hmm so would a looter be similar to


program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure lootItem();
var
x, y: integer; //we need to declare these variables since findObject outputs these
begin
if mainscreen.findObject(x, y, 925721, 11, ['ffigy'], MOUSE_RIGHT) then
begin
writeLn('We found an item!'); //if findObject results true, this will print
chooseOption.select(['ake']); // this will choose ‘Take’ option in chooseOptions menu
end;
end;

begin
clearDebug();
setupSRL();
lootItem();
end.

The Mayor
10-24-2014, 11:28 PM
Hmm so would a looter be similar to

program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure lootItem();
var
x, y: integer; //we need to declare these variables since findObject outputs these
begin
if mainscreen.findObject(x, y, 925721, 11, ['ffigy'], MOUSE_RIGHT) then
begin
writeLn('We found an item!'); //if findObject results true, this will print
chooseOption.select(['ake']); // this will choose ‘Take’ option in chooseOptions menu
end;
end;

begin
clearDebug();
setupSRL();
lootItem();
end.


In the most basic form, yes ;) That will work if your colour and tolerance are correct.

kozak94
11-04-2014, 03:18 AM
This is beautiful.

Trollcrank
11-07-2014, 01:00 AM
I'm starting to wonder if there should be a line, or text, separating the original tutorial from the to be added sections. It's started to go from the basics to all of the inbuilt features of the client.

Edit: I mean a more dominate line.

The Mayor
11-07-2014, 02:23 AM
I'm starting to wonder if there should be a line, or text, separating the original tutorial from the to be added sections. It's started to go from the basics to all of the inbuilt features of the client.

Edit: I mean a more dominate line.

Everything after the simba basics section is all SRL6 stuff. Everything up to the bankscreen is complete, as you can tell from the other sections being blank.

Marius90
11-10-2014, 06:07 PM
For some reason i dont know why, sometimes it jumps over this task
typeSend('1', false); it banks it again without pressing the action bar, so if it help you guys i wrote this


begin
if (tabBackpack.isFull)
then typeSend('1', false);
end;

works obviously only if what you have withdrew from the bank made the backpack full.
And another problem that i sometimes encounter is that even it is
false is still preses enter and starts typing in the chatbox until the end of times, so what i do is that i select the Emotes panel and works perfectly

SRLnoob
11-27-2014, 08:15 PM
What AIO tutorial? I can't find it to save my life.

3Garrett3
11-27-2014, 11:06 PM
What AIO tutorial? I can't find it to save my life.

https://villavu.com/forum/showthread.php?t=107757

Consider your life saved.

SRLnoob
11-28-2014, 12:43 AM
https://villavu.com/forum/showthread.php?t=107757

Consider your life saved.

Lol yeah I didn't think that was it because it says on that to go to this tutorial. I didn't make the connection that "AIO" stood for "all in one." Thanks.

MatthewDai98
12-18-2014, 05:02 AM
how can I know the coordinates of a point to click? Also, bank.open gives an error about operator missing:/

The Mayor
12-18-2014, 05:43 AM
how can I know the coordinates of a point to click? Also, bank.open gives an error about operator missing:/

I guess you forgot to read the first few sections about simba basics :(

MatthewDai98
12-19-2014, 03:48 AM
I did?:O I know the coordinates now but what about bank.open:(

Lipcot
12-19-2014, 08:49 AM
I did?:O I know the coordinates now but what about bank.open:(

you are just using bank.open ? you must do this bank.open(THE_BANK_YOU_WANT_TO_OPEN). check the documentation to know what to put within the brackets!

MatthewDai98
12-20-2014, 03:52 AM
you are just using bank.open ? you must do this bank.open(THE_BANK_YOU_WANT_TO_OPEN). check the documentation to know what to put within the brackets!

no I did
bankScreen.open(BANK_NPC_BLUE)
Error: Operator expected at line 28

The Mayor
12-20-2014, 03:57 AM
no I did
bankScreen.open(BANK_NPC_BLUE)
Error: Operator expected at line 28

It won't be that line causing the error. You would have messed something else up. Easiest way to help is for you to post your whole script in simba tags

[SIMBA] script here [./SIMBA]

MatthewDai98
12-21-2014, 06:39 PM
program script;

{$DEFINE SMART} // Always have this to load smart
{$I SRL-6/SRL.simba} // To load the SRL include files
{$I SPS/lib/SPS-RS3.Simba} // To load the SPS include files

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := '';
password := '';
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;


// main loop
procedure mainprogram();
Begin
tabBackPack.mouseSlot(1, MOUSE_LEFT);
mouse(410, 376, 30, 5, MOUSE_MOVE);
fastClick(MOUSE_LEFT);
randomRange(5500, 10500)
bankScreen.open(BANK_NPC_BLUE)
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
bankScreen.close();
end.
begin
clearDebug(); // Clear the debug box
smartEnableDrawing := true; // So we can draw on SMART
setupSRL(); // Load the SRL include files
declarePlayers(); // Set up your username/pass

if not isLoggedIn() then // If player isn't logged in then
begin
players[0].login(); // Log them in
exitSquealOfFortune(); // Exit squeal if found
minimap.setAngle(MM_DIRECTION_NORTH); // Make compass north and angle high
mainScreen.setAngle(MS_ANGLE_HIGH);
mainprogram()
end;
declareplayers()
mainprogram()
end;

Lipcot
12-21-2014, 07:16 PM
.....

well, you have some very silly errors there :p, ill mark them on red so i cant use [SIMBA]:


program script;

{$DEFINE SMART} // Always have this to load smart
{$I SRL-6/SRL.simba} // To load the SRL include files
{$I SPS/lib/SPS-RS3.Simba} // To load the SPS include files

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := '';
password := '';
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;


// main loop
procedure mainprogram();
Begin
tabBackPack.mouseSlot(1, MOUSE_LEFT);
mouse(410, 376, 30, 5, MOUSE_MOVE);
fastClick(MOUSE_LEFT);
WAIT(randomRange(5500, 10500));
bankScreen.open(BANK_NPC_BLUE);
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
bankScreen.close();
end; //semicolon here not a point.

begin
clearDebug(); // Clear the debug box
smartEnableDrawing := true; // So we can draw on SMART
setupSRL(); // Load the SRL include files
declarePlayers(); // Set up your username/pass

if not isLoggedIn() then // If player isn't logged in then
begin
players[0].login(); // Log them in
exitSquealOfFortune(); // Exit squeal if found
minimap.setAngle(MM_DIRECTION_NORTH); // Make compass north and angle high
mainScreen.setAngle(MS_ANGLE_HIGH);
mainprogram()
end;
declareplayers(); //you were missing semicolons here
mainprogram(); // same here
end;


apply these changes and it'l compile! next time try following the guide to the detail, and remeber always end lines with a semicolon! "operator" usually means you are missing a semicolon. "block" means you've messed up with begins/ends (you had put a dot instead of a semicolon).

MatthewDai98
12-21-2014, 10:22 PM
well, you have some very silly errors there :p, ill mark them on red so i cant use [SIMBA]:


program script;

{$DEFINE SMART} // Always have this to load smart
{$I SRL-6/SRL.simba} // To load the SRL include files
{$I SPS/lib/SPS-RS3.Simba} // To load the SPS include files

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := '';
password := '';
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;


// main loop
procedure mainprogram();
Begin
tabBackPack.mouseSlot(1, MOUSE_LEFT);
mouse(410, 376, 30, 5, MOUSE_MOVE);
fastClick(MOUSE_LEFT);
WAIT(randomRange(5500, 10500));
bankScreen.open(BANK_NPC_BLUE);
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
bankScreen.close();
end; //semicolon here not a point.

begin
clearDebug(); // Clear the debug box
smartEnableDrawing := true; // So we can draw on SMART
setupSRL(); // Load the SRL include files
declarePlayers(); // Set up your username/pass

if not isLoggedIn() then // If player isn't logged in then
begin
players[0].login(); // Log them in
exitSquealOfFortune(); // Exit squeal if found
minimap.setAngle(MM_DIRECTION_NORTH); // Make compass north and angle high
mainScreen.setAngle(MS_ANGLE_HIGH);
mainprogram()
end;
declareplayers(); //you were missing semicolons here
mainprogram(); // same here
end;


apply these changes and it'l compile! next time try following the guide to the detail, and remeber always end lines with a semicolon! "operator" usually means you are missing a semicolon. "block" means you've messed up with begins/ends (you had put a dot instead of a semicolon).

Thanks a lot;) It worked I'll remember to put them semicolons :p

KeepBotting
12-21-2014, 11:56 PM
Thanks a lot;) It worked I'll remember to put them semicolons :p

Adding on a bit to what undorak said,

this isn't a huge problem, just a little nit-picky thing, but exitSquealOfFortune(); should be exitTreasure();

They're one and the same, but exitSquealOfFortune() will be removed eventually

SlipperyPickle
12-23-2014, 01:41 PM
Really nice guide! Thank you very much. Trying to make my first scripts, and these guides where really helpful. Hopefully have my first script ready in a week or so. Thanks! :)

MatthewDai98
12-23-2014, 05:45 PM
Adding on a bit to what undorak said,

this isn't a huge problem, just a little nit-picky thing, but exitSquealOfFortune(); should be exitTreasure();

They're one and the same, but exitSquealOfFortune() will be removed eventually

I see thanks!:)

The Mayor
01-03-2015, 07:01 AM
Updated with a few more sections!

Taric
01-04-2015, 06:20 AM
So I have my Tpoint clicking the minimap furnace icon:


minimap.findSymbol(myPoint, MM_SYMBOL_FURNACE, minimap.getBounds());
mouse(myPoint ,MOUSE_LEFT);

Is there anyway I can add 10 to the y value of the Tpoint? Still new to this shtuff...

The Mayor
01-04-2015, 08:39 AM
So I have my Tpoint clicking the minimap furnace icon:


minimap.findSymbol(myPoint, MM_SYMBOL_FURNACE, minimap.getBounds());
mouse(myPoint ,MOUSE_LEFT);

Is there anyway I can add 10 to the y value of the Tpoint? Still new to this shtuff...

mouse(myPoint.x, myPoint.y + 10, MOUSE_MOVE)

hihihih565
01-08-2015, 08:08 PM
Hey,

I was going to PM you but I don't have enough posts to send a PM. If you could add me on Skype, that would be greatly appreciated.

The Mayor
01-17-2015, 03:44 AM
I added section 17 about working with the Grand Exchange.

Quentini
01-18-2015, 07:20 PM
Great reading all the updates. Keep it up!

Greytor
01-18-2015, 07:37 PM
Really nice guide, it is very helpful as I am making my first script, keep up the good work!

3Garrett3
01-22-2015, 04:26 PM
I added section 17 about working with the Grand Exchange.

Quick question about GE parameters:

You have options for +5/-5% in the prices. Is the "Any other number" option a designated price or can it be "+10"?

Just wondering... for reasons.

Also for simple operations, everything should be called from the main GE screen? It handles all of the GE Slot clicking and getting out of offers etc?

The Mayor
01-22-2015, 09:11 PM
Quick question about GE parameters:

You have options for +5/-5% in the prices. Is the "Any other number" option a designated price or can it be "+10"?

Just wondering... for reasons.

Also for simple operations, everything should be called from the main GE screen? It handles all of the GE Slot clicking and getting out of offers etc?

Any other number as in a number, not anything with '+' or '-'.

If you wanted to buy at +10% you could just do something like:


procedure buyStuff();
var
price: integer;
begin
price := grandExchange.getPrice(1234);
price += round(price * 0.1);
grandExchange.buyItem('Item', toStr(price), '100');
end;


You can call any function from any screen. It will return to the main summary screen if necessary.

Sajon
02-09-2015, 11:13 PM
very good thread lerning alot :P thank you so much

Tristana
02-10-2015, 01:02 AM
Ok im not sure if this question belongs here but I'm sure you can answer it anyways @ The Mayor :p. Is using DTMs for walking more accurate than SPS? . I've noticed that SPS sometimes messes up walk paths that I set.

3Garrett3
02-10-2015, 04:02 PM
Ok im not sure if this question belongs here but I'm sure you can answer it anyways @ The Mayor :p. Is using DTMs for walking more accurate than SPS? . I've noticed that SPS sometimes messes up walk paths that I set.

Except in very select areas, SPS is probably faster than DTMs. Made properly, I bet you'd probably have more "accurate" DTMs than SPS, but you should be able to walk to a given tile with the required accuracy using SPS.

The key if you're finding misclicks is to properly set the map up. I don't have the function memorized (or Simba in front of me) but if you look around the help forum and find SPS threads there should be some mentions of SPS settings.

Accuracy, Tolerance, Match Percent are the ones you're looking for. They can be changed around at will and tested until they work perfectly to whatever accuracy you need.

Tristana
02-10-2015, 11:25 PM
Except in very select areas, SPS is probably faster than DTMs. Made properly, I bet you'd probably have more "accurate" DTMs than SPS, but you should be able to walk to a given tile with the required accuracy using SPS.

The key if you're finding misclicks is to properly set the map up. I don't have the function memorized (or Simba in front of me) but if you look around the help forum and find SPS threads there should be some mentions of SPS settings.

Accuracy, Tolerance, Match Percent are the ones you're looking for. They can be changed around at will and tested until they work perfectly to whatever accuracy you need.
Ah thanks :). I'll take a look at DTMS for now.

3Garrett3
02-11-2015, 12:03 AM
Ah thanks :). I'll take a look at DTMS for now.

Sorry, to be completely explicit: I highly recommend SPS in all situations. At least try it first. It's much easier and works just as accurately in almost all situations. In the case that you need highly precise walking for some special case, try changing settings with your SPS map until you're sure that it can't be done with SPS. Then maybe try DTMs, but they're so much harder to make, maintain, troubleshoot, etc.

SirPrize
02-23-2015, 12:58 AM
This guide is beautiful, thanks for putting this together! Going to help a looot with learning

Renzanity
03-04-2015, 10:24 AM
Thanks for the wonderful intro! I've actually made a very simple alch'ing script while reading this. :p

forest
03-06-2015, 01:16 PM
i don't get why i'm getting a compilation error


program new;

begin
mouse(123, 123, MOUSE_MOVE);
end.


Error: Unknown declaration "Mouse" at line 4
Compiling failed.

e: didnt know it doesnt work outside of the smart client zzzzzzzzzzzzzzzzzzzzzzzzzz

The Mayor
03-06-2015, 08:24 PM
i don't get why i'm getting a compilation error


Error: Unknown declaration "Mouse" at line 4
Compiling failed.

e: didnt know it doesnt work outside of the smart client zzzzzzzzzzzzzzzzzzzzzzzzzz

It doesn't work, because mouse() is a function inside the SRL-6 library. You need to include the SRL-6 library in your script. Read section 2 "Mouse and Clicking Basics".

Kopa
03-22-2015, 07:23 AM
Great guide, I really enjoyed it.
But I have a quick question. If I create a combat script and I would like to bot to use momentum, how would I check if the combat mode is already set to momentum? Is that even possible?

yourule97
03-22-2015, 09:38 PM
Great guide, I really enjoyed it.
But I have a quick question. If I create a combat script and I would like to bot to use momentum, how would I check if the combat mode is already set to momentum? Is that even possible?

I didn't even know it existed because its not in the documentation, but I did some research and apparently you can do:


powersScreen.open();
if powersScreen.getCombatMode() = 3 then //Momentum's value is three
begin
//blah
end;

To set the bot to turn on momentum you can do something like:


powersScreen.setCombatMode(MODE_MOMENTUM);

Kopa
03-22-2015, 09:46 PM
I didn't even know it existed because its not in the documentation, but I did some research and apparently you can do:


powersScreen.open();
if powersScreen.getCombatMode() = 3 then //Momentum's value is three
begin
//blah
end;

To set the bot to turn on momentum you can do something like:


powersScreen.setCombatMode(MODE_MOMENTUM);


Yeah I guessed that it will be the only solution.
Thanks man!

The Mayor
03-22-2015, 11:17 PM
Great guide, I really enjoyed it.
But I have a quick question. If I create a combat script and I would like to bot to use momentum, how would I check if the combat mode is already set to momentum? Is that even possible?

When you setCombatMode(), it checks that it's not already on the selected combat mode before clicking it.

Kopa
03-22-2015, 11:45 PM
When you setCombatMode(), it checks that it's not already on the selected combat mode before clicking it.

Oh, that's great, thank you very much!
But it has to open the combat settings to check it, right? I haven't made a test yet, as I'm still searching around and learning.

The Mayor
03-22-2015, 11:53 PM
Oh, that's great, thank you very much!
But it has to open the combat settings to check it, right? I haven't made a test yet, as I'm still searching around and learning.

Yes it does have to open it. I don't think there is another way to check what mode you are on?

osoad1
03-24-2015, 12:04 AM
Thanks for the guide

forest
03-29-2015, 01:41 AM
Does bankScreen.open(BANK_NPC_BLUE); still work for V West banks? I tried executing the same code you provided but it doesn't open the bank screen for me. Do I have to hardcode opening banks or is there an easier solution? Thanks

drag2270
04-08-2015, 07:25 PM
I have a question. What if i want to make a if statement? Like i have one procedure that can run if somthing happens

like if my character logs out i log it back in using that procedure and it continues doing whatever its doing

KeepBotting
04-08-2015, 07:50 PM
I have a question. What if i want to make a if statement? Like i have one procedure that can run if somthing happens

like if my character logs out i log it back in using that procedure and it continues doing whatever its doing


if not (isLoggedIn()) then
begin
players[currentPlayer].login();
recoverFromLogout(); //This would ideally be a routine that opens
//the backpack, sets the camera, normal stuff
//that you'd do upon logging in to prepare for
//the script's run.
end;

drag2270
04-13-2015, 01:50 AM
Ok lets take this to a different siutation and not with logs-outs what if my character is in wildy killing revs, what if it gets lured to another spot how can i take it back to revs? like what would be the lines of code.

Camel
04-13-2015, 02:05 AM
Ok lets take this to a different siutation and not with logs-outs what if my character is in wildy killing revs, what if it gets lured to another spot how can i take it back to revs? like what would be the lines of code.

It would likely involve SPS. If not it would require some clever solution.

No one will write the code for you, I would suggest reading this https://villavu.com/forum/showthread.php?t=107757 guide to learn about SPS and more advanced scripting... Which doing something like fighting revs will require.

KeepBotting
04-13-2015, 07:15 AM
Ok lets take this to a different siutation and not with logs-outs what if my character is in wildy killing revs, what if it gets lured to another spot how can i take it back to revs? like what would be the lines of code.

I agree with what Camel said. However I'll point you to this thread (https://villavu.com/forum/showthread.php?t=111226), where a member was helped with location checking. The same concept can be used to accomplish your goal.

UrbanSmoke
04-21-2015, 12:05 AM
Great tutorial, may I suggest recording yourself making a new script from start to finish? That would be incredibly informative.

The Mayor
04-23-2015, 05:54 PM
Great tutorial, may I suggest recording yourself making a new script from start to finish? That would be incredibly informative.

I've always thought about doing that! Maybe someday when I get the time ;)

Thestroyer
07-11-2015, 05:25 AM
I hope I'm not grave digging. This is a crazy amazing guide to writing scripts for RS3. I am actually interested in writing RSPS scripts, but this still provides a great base for me to start something. This helped me understand the structure of the pascal language, which is pretty cool and resembles modern languages. Can't w8 to finish reading this guide, then your AIO, and then hopefully setting up an environment where I can run a RSPS client and bot on it :]

Ultra
08-19-2015, 04:33 PM
Sweet tutorial. Gonna help me a bunch when I am going to get back to scripting in the future :).

maxlvs
10-29-2015, 05:12 AM
program test;

procedure practiceBox();
var
settingsButton: TBox; // Declare TBox variable
begin
settingsButton := intToBox(735, 80, 750, 100);
mouseBox(settingsButton, MOUSE_LEFT);
wait(4000);
mouseBox(intToBox(630, 105, 640, 115), MOUSE_LEFT); // Notice how I made the box inside the mouseBox function
end;

begin
practiceBox();
end.


Error: Unknown declaration "mouseBox" at line 8
Compiling failed.
__________________________________________________ __________________________________________________ ________________________________
tried this too no good and i took out the MOUSE_MOVE because it will say Unknown declaration "MOUSE_MOVE"

program new;

procedure practiceMouse();
begin
movemouse(200, 200, 5, 5); <<<<< line 5
wait(3000);
movemouse(50, 50);
wait(3000);
writeLn('We just right clicked');
wait(3000);
movemouse(300, 30);
end;

begin
practiceMouse();
end

Error: Too many parameters found at line 5
Compiling failed

Incurable
10-29-2015, 05:58 AM
-snip-

Firstly, please use tags around code, like this:

[simba]YOUR CODE HERE![*simba]

Replace the asterisk (*) with a forward slash (/).

Secondly, you need to include the SRL-6 library, like so:

[simba]
program example;
{$I SRL-6/SRL.simba}

// code here

begin
// code here
end.


This is demonstrated in The Mayor's tutorial with the following snippet:


program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure practiceMouse();
begin
mouse(200, 200, MOUSE_MOVE);
wait(3000);
mouse(50, 50, MOUSE_MOVE);
wait(3000);
fastClick(MOUSE_RIGHT);
writeLn('We just right clicked');
wait(3000);
mouse(300, 30, MOUSE_MOVE);
end;

begin
clearDebug();
setupSRL();
practiceMouse();
end.


I suggest you carefully read the tutorial and follow it step by step, ensuring that your code looks just like The Mayor's code.

Good luck! :)

maxlvs
10-29-2015, 06:27 AM
that wont work

this pops up in a new tab


Error: Duplicate declaration "mbOk" at line 30
Compiling failed.


(*
Globals
=======

The globals file holds any variables used throughout multiple files in SRL.

The source for this file can be found `here <https://github.com/SRL/SRL-6/blob/master/lib/core/globals.simba>`_.

*)

{$f-}

const
VK_ENTER = {$IFDEF LINUX}10{$ELSE}VK_RETURN{$ENDIF};

(*
var MessageBox
~~~~~~~~~~~~~~

Variables that store Simba's MessageBox function parameters. Makes it easier to
use rather than just remembering values.

Example:

.. code-block:: pascal

MessageBox('Test!', 'Test', mbOkCancel);
*)
var
mbOk = 0;
mbOkCancel = 1;
mbAbortRetryIgnore = 2;
mbYesNoCancel = 3;
mbYesNo = 4;
mbCancelRetry = 5;

mrYes = 6;
mrNo = 7;

(*
var Colors
~~~~~~~~~~

Convenient colors for scripters to use. Used mainly for SMART debugging.

Example:

.. code-block:: pascal

smartImage.drawBox(minimap.getBounds(), false, clFuchsia);
*)
var
clWhite = 16777215;
clBlack = 0;
clRed = 255;
clGreen = 32768;
clBlue = 16711680;
clPurple = 8388736;
clYellow = 65535;
clAqua = 16776960;
clOrange = 26367;
clFuchsia = 16711935;
clTeal = 8421376;
clNavy = 8388608;
clGray = 8421504;
clLime = 65280;
clMaroon = 128;
clSilver = 12632256;
clPink = 11772650;

(*
Constant: Events
~~~~~~~~~~~~~~~~

Integer constants of all the events called througout SRL.

Example:

.. code-block:: pascal

SRL_Events[RS_UPDATE] := @SixHourFix;

*)
const
EVENT_COUNT = 5;
EVENT_RS_UPDATE = 0;
EVENT_LOGOUT = 1;
EVENT_LOGIN = 2;
EVENT_PLAYER_NEXT = 3;
EVENT_ANTIBAN = 4;

(*
Variable: SRL_Events
~~~~~~~~~~~~~~~~~~~~

Events that are called throuhgout SRL. These events can be set in any script
so custom procedures can be called in certain areas of SRL.

Example:

.. code-block:: pascal

SRL_Events[RS_UPDATE] := reloadCurrentClient;

*)
var
SRL_Events: array[0..(EVENT_COUNT - 1)] of procedure;



Error: Duplicate declaration "mbOk" at line 30
Compiling failed.

Clarity
10-29-2015, 07:45 AM
...

Please post your script code that creates this error.

Incurable
10-29-2015, 08:22 AM
-snip-

Again, please post the code in [simba] tags as I showed you. Also do as Clarity asked so that we can see what the problem is. :)

maxlvs
10-29-2015, 06:00 PM
see if i could talk to someone over skype there would not be such a problem i used the code that incurable posted

program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure practiceMouse();
begin
mouse(200, 200, MOUSE_MOVE);
wait(3000);
mouse(50, 50, MOUSE_MOVE);
wait(3000);
fastClick(MOUSE_RIGHT);
writeLn('We just right clicked');
wait(3000);
mouse(300, 30, MOUSE_MOVE);
end;

begin
clearDebug();
setupSRL();
practiceMouse();
end.

maxlvs
10-29-2015, 06:18 PM
see if i could talk to someone over skype there would not be such a problem i used the code that incurable posted

program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure practiceMouse();
begin
mouse(200, 200, MOUSE_MOVE);
wait(3000);
mouse(50, 50, MOUSE_MOVE);
wait(3000);
fastClick(MOUSE_RIGHT);
writeLn('We just right clicked');
wait(3000);
mouse(300, 30, MOUSE_MOVE);
end;

begin
clearDebug();
setupSRL();
practiceMouse();
end.


and most of these guides are way outdated like you cant use mouse you have to use movemouse or clickmouse and you cant use

this mouse(x, y, ranX, ranY, mouseAction); or
this mouse(100, 100, 5, 5, MOUSE_MOVE) or
this fastClick(MOUSE_LEFT); etc...

other says unknown meaning of "MOUSE_MOVE" or to many parameters and highlights both of the 5's

and the page messed up and when i clicked out of the page and i clicked back to edit my post but it posted another one

TheMilkTree
11-02-2015, 05:00 PM
Thanks for this amazing beginners guide! Really useful for someone that has never completed any coding before.

Very helpful! It's great as well that you've explained every single phrase/piece of code you've written, really helps understand this 'new language'.

However one thing I've noticed that hasn't truly been mentioned is the spacing. Is this for a visual understanding or does it have a technical purpose? Furthermore it took me a while to realise using TAB to shift the text won't work, has to actually be a space, they just move the text an equivalent distance which was originally confusing.

Lama
11-04-2015, 09:23 PM
Thanks for this amazing beginners guide! Really useful for someone that has never completed any coding before.

Very helpful! It's great as well that you've explained every single phrase/piece of code you've written, really helps understand this 'new language'.

However one thing I've noticed that hasn't truly been mentioned is the spacing. Is this for a visual understanding or does it have a technical purpose? Furthermore it took me a while to realise using TAB to shift the text won't work, has to actually be a space, they just move the text an equivalent distance which was originally confusing.

When the code is compiled, it ignores any white space entirely. It's all visual :) (you could write an entire script on one line... but... please... don't)

Bottom-line, standards and spacing and whatnot is to help readability, which is pretty crucial for us humans.

Danielius
12-30-2015, 09:12 AM
Thanks a lot Mayor, this literally saved me a couple of hours.

Gliahu
01-10-2016, 08:17 AM
thank you for this, i cant wait to start scripting

prawnqqq
11-02-2016, 01:54 PM
Looking forward to making my first script thanks for this.

TheMilkTree
11-16-2016, 06:47 PM
A lot of the OSRS guides are quite old now, so assuming you change the colours/locational stuff, how applicable is this to OS?

TheMilkTree
11-20-2016, 08:35 PM
After literally a year and a half i've finally made it through all of this guide! I'm a bit slow... Was very helpful indeed, understood so much. Thanks Mayor!

jakrz
01-15-2017, 10:04 PM
Awesome, thx a lot for this!

OSRS BOT
05-16-2017, 11:31 PM
Hi is this still relevant?

DemonShadow90
05-17-2017, 06:59 PM
Thanks for this, really helped me get up and running in the world of simba :-)

hunterofagoodtime
03-12-2018, 04:28 PM
Hi guys I can't get the findObject function to work correctly - it just doesn't find the color and that boolean keeps returning a false. I used ACA remake from here.
Here is my code:

program new;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure clickBansh();
var
x, y: integer; //we need to declare these variables since findObject outputs/requires these
begin
if mainscreen.findObject(x, y, 5467487, 11, ['anshee'], MOUSE_RIGHT) then
begin
chooseOption.select(['ttack Banshee']);
wait(randomRange(4000,8000));
clickBansh();
end;
clickBansh();
end;

begin
clearDebug();
setupSRL();
clickBansh();
end.
end.

here is the debug log:
-- TRSMainScreen.findObject(): False
-- TRSMainScreen.findObject()
---- No colors found

this repeats.


Oh yah - I wanted to use this to simply attack Banshees in the security stronghold.