Vinyl Scratch
08-20-2012, 12:21 AM
Hey guys. I'm gonna teach you how to make your first Runescape script. It's going to be A very in-depth tutorial on the basic functions for scripting. We won't use TPAs, don't worry.
To start, we're going to open Simba. I'm going to help you set it up, if you haven't already.
Start by opening Simba, then go to View>Extensions. You'll get a window like this one:
http://puu.sh/WVEg
You're going to double click Assosiate.sex, Extension.sex, and SRL.sex. (Someone correct me if I'm wrong, please. )
Anyway.. Your window'll look like this:
http://puu.sh/WVMi
Does it look like that? [y/n]
Non-Retorical.
Good. Now, close that, and Simba.
Now, go to tools>update.
Click force update, just to make sure.
then close Simba again.
y we cloz Simba so much?
So that it "refreshes" Simba.
ohkee.
So.. You SHOULD have something like this:
{$DEFINE SMART}
{$I SRL/SRL.Simba}
Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
WorldInfo := [27, 42, 45, 46, 48, 52, 59, 70, 72, 78, 79, 87, 104, 115, 117];
BoxRewards := ['XP','xp','lamp'];
LampSkill := Skill_Slayer;
Active := True;
end;
end;
begin
{$IFDEF SMART}
{$IFDEF SIMBAMAJOR980}
Smart_Server := 72;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ELSE}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}
{$ENDIF}
DeclarePlayers;
SetupSRL;
end.
If not, then it'll be:
program new;
begin
end.
I'm going to explain from top to bottom what everything is.
Starting with the program new;
This tell the interpreter, in this case, Simba, that it's a program. The "new" is the name of the program. you have to have the semicolon to signify the end of that line. k. That's done.
Now, for the weird curly-bracketed stuff.
{$DEFINE smart}
That's to get SMART to open. (Simba Minimizing Autoing Thing, as I like to call it.)
{$i SRL/SRL.simba}
This? This is for including SRL. (Simba Resorce Library, as I also like to call it.)
You need this to script.. unless you want to write all of your own functions. I would stick to using this, though. Now, you have all of this in your script. Wat do? Well, you need a main loop!
wat be a main l00p?
It's what makes the script run. You don't have it, and your procedures in it, your script won't work. You'll either get errors, or your script won't do anything.
Well, your main loop looks like this: begin
end.
Now, you know what it does. Wanna make it work? Type "writeln('Does it work?');" into it, and click run. (the green button!)
You'll see your text pop up in the debug box. Happy? Good.
Take that out. You don't need it anymore.
Now, go to the space between the main loop and your weird curly bracketed thing.
Type "procedure". It'll look like this:
procedure
Did it look like that?
Good.
Now, type a name for it.
Since this is going to be a 2 procedure script, you can name it what you like. I'm going to name it "attack" because we're going to make it attack something. In this tutorial, Goblins. Ok, you have a name, right?
Good, good.
Now, you're going to want to add a variable.
type "var"
You'll see it get big and black.
var
See?
Good. Now, press enter. Then either press Tab once, or space twice. This is called indention. You use this to have good standards in coding, and so your code is readable.
Now, type "x, y: Integer;"
It'll show up like this:
var
x,y: Integer;
This is declaring x, and y, as an integer. Now, an integer holds a number. You need to assign those variables to a number. Now, you aren't going to go x:= 83;
y:= 94;
because those are static. We need them to be assigned by a function.
anyway... after that, press enter, and the backspace button. Now, type begin.
It'll get Big and black.
Like this:
begin
k? good.
So, we're going to use an if...then statement. What this does is says, If I find the object, then go to the next line.
So, what we're going to do is type if FindObjCustom(x, y, ['uptext', 'uptext'], [color, color, color], 7); then
See there?
Get the uptext, which, in this case would be 'ttack', 'oblin'
Then your color. Pick a color from the goblin.
That 7? That's the tolerance. You use tolerance to keep to that color, and only go out a certain amount of shades.
Now, what to do if it finds it.
press enter.
type begin
press space two times.
then, we're going to use a case ... of statement
So, you're code'll look like this:
Ok, I'm going to use Simba tags from here on out, because It's getting annoying doing all of the different color tags.
case Random(2) of
0: begin
MMouse(x, y, 3, 3); //this moves the mouse to the coord, with a randomness of 3 on both the x, and y axises.
Clickmouse2(true); //left clicks the mouse
end; //ends the begin statement that you started.
1: begin
MMouse(x, y, 3, 3);
Clickmouse2(false); //right clicks the mouse.
WaitOptionMulti(['ttack', 'oblin'], 300); waits for the option menu to show up, and then clicks.
end; //ends the begin statement.
end; //you have to end the case statement, too.
to make sure you don't get lost, this is what your script should look like so far:
{$DEFINE SMART}
{$I SRL/SRL.Simba}
Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
WorldInfo := [27, 42, 45, 46, 48, 52, 59, 70, 72, 78, 79, 87, 104, 115, 117];
BoxRewards := ['XP','xp','lamp'];
LampSkill := Skill_Slayer;
Active := True;
end;
end;
procedure attack;
var
x, y: Integer;
begin
if FindObjCustom(x, y, ['ttack', 'oblin'], [5482390, 7834647, 9827484], 7) then
case Random(2) of
0: begin
MMouse(x, y, 3, 3);
Clickmouse2(true);
end;
1: begin
MMouse(x, y, 3, 3);
Clickmouse2(false);
Waitoptionmulti(['ttack', 'oblin'], 300);
end;
end;
end;
begin
end.
If your script looks like that, then you're doing good.
Now, We need to check if it's in combat, right? Yes. So, You're going to add if Didredclick then
That'll make the attack procedure look like this:
case Random(2) of
0: begin
MMouse(x, y, 3, 3);
Clickmouse2(true);
if DidRedClick then
Wait(10000);
end;
1: begin
MMouse(x, y, 3, 3);
Clickmouse2(false);
WaitOptionMulti(['ttack', 'oblin'], 300);
if DidRedClick then
Wait(10000);
end;
end;
Now, we're going to setup the main loop.
Y'know, the begin..end. thing
Well, First, you're going to add (if it isn't already there.)
begin
{$IFDEF SMART}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}
DeclarePlayers;
SetupSRL; //sets up SRL.
LogInPlayer; //Logs the player in
end.
Now, you're going to want to add your procedure into it. So, add the NAME ONLY into the main loop.
it'll look like this:
{$IFDEF SMART}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}
DeclarePlayers;
SetupSRL;
Attack;
end.
There you go. Now it'll find the goblin, and
kill it.
But it'll only kill only one.
Wha.. Why?!
Because, there's no loop.
But it's called the main loop?
Think of it as a group on friends. There's always that one who won't shutup. He's the loop inside of your friends. That's what you're creating now.
So, just put
repeat
Attack;
until(not(loggedIn);
Now it'll loop until you are logged out, then it'll terminate the script. Now, you've made your first successful script! Good Job!
To start, we're going to open Simba. I'm going to help you set it up, if you haven't already.
Start by opening Simba, then go to View>Extensions. You'll get a window like this one:
http://puu.sh/WVEg
You're going to double click Assosiate.sex, Extension.sex, and SRL.sex. (Someone correct me if I'm wrong, please. )
Anyway.. Your window'll look like this:
http://puu.sh/WVMi
Does it look like that? [y/n]
Non-Retorical.
Good. Now, close that, and Simba.
Now, go to tools>update.
Click force update, just to make sure.
then close Simba again.
y we cloz Simba so much?
So that it "refreshes" Simba.
ohkee.
So.. You SHOULD have something like this:
{$DEFINE SMART}
{$I SRL/SRL.Simba}
Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
WorldInfo := [27, 42, 45, 46, 48, 52, 59, 70, 72, 78, 79, 87, 104, 115, 117];
BoxRewards := ['XP','xp','lamp'];
LampSkill := Skill_Slayer;
Active := True;
end;
end;
begin
{$IFDEF SMART}
{$IFDEF SIMBAMAJOR980}
Smart_Server := 72;
Smart_Members := True;
Smart_Signed := True;
Smart_SuperDetail := False;
{$ELSE}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}
{$ENDIF}
DeclarePlayers;
SetupSRL;
end.
If not, then it'll be:
program new;
begin
end.
I'm going to explain from top to bottom what everything is.
Starting with the program new;
This tell the interpreter, in this case, Simba, that it's a program. The "new" is the name of the program. you have to have the semicolon to signify the end of that line. k. That's done.
Now, for the weird curly-bracketed stuff.
{$DEFINE smart}
That's to get SMART to open. (Simba Minimizing Autoing Thing, as I like to call it.)
{$i SRL/SRL.simba}
This? This is for including SRL. (Simba Resorce Library, as I also like to call it.)
You need this to script.. unless you want to write all of your own functions. I would stick to using this, though. Now, you have all of this in your script. Wat do? Well, you need a main loop!
wat be a main l00p?
It's what makes the script run. You don't have it, and your procedures in it, your script won't work. You'll either get errors, or your script won't do anything.
Well, your main loop looks like this: begin
end.
Now, you know what it does. Wanna make it work? Type "writeln('Does it work?');" into it, and click run. (the green button!)
You'll see your text pop up in the debug box. Happy? Good.
Take that out. You don't need it anymore.
Now, go to the space between the main loop and your weird curly bracketed thing.
Type "procedure". It'll look like this:
procedure
Did it look like that?
Good.
Now, type a name for it.
Since this is going to be a 2 procedure script, you can name it what you like. I'm going to name it "attack" because we're going to make it attack something. In this tutorial, Goblins. Ok, you have a name, right?
Good, good.
Now, you're going to want to add a variable.
type "var"
You'll see it get big and black.
var
See?
Good. Now, press enter. Then either press Tab once, or space twice. This is called indention. You use this to have good standards in coding, and so your code is readable.
Now, type "x, y: Integer;"
It'll show up like this:
var
x,y: Integer;
This is declaring x, and y, as an integer. Now, an integer holds a number. You need to assign those variables to a number. Now, you aren't going to go x:= 83;
y:= 94;
because those are static. We need them to be assigned by a function.
anyway... after that, press enter, and the backspace button. Now, type begin.
It'll get Big and black.
Like this:
begin
k? good.
So, we're going to use an if...then statement. What this does is says, If I find the object, then go to the next line.
So, what we're going to do is type if FindObjCustom(x, y, ['uptext', 'uptext'], [color, color, color], 7); then
See there?
Get the uptext, which, in this case would be 'ttack', 'oblin'
Then your color. Pick a color from the goblin.
That 7? That's the tolerance. You use tolerance to keep to that color, and only go out a certain amount of shades.
Now, what to do if it finds it.
press enter.
type begin
press space two times.
then, we're going to use a case ... of statement
So, you're code'll look like this:
Ok, I'm going to use Simba tags from here on out, because It's getting annoying doing all of the different color tags.
case Random(2) of
0: begin
MMouse(x, y, 3, 3); //this moves the mouse to the coord, with a randomness of 3 on both the x, and y axises.
Clickmouse2(true); //left clicks the mouse
end; //ends the begin statement that you started.
1: begin
MMouse(x, y, 3, 3);
Clickmouse2(false); //right clicks the mouse.
WaitOptionMulti(['ttack', 'oblin'], 300); waits for the option menu to show up, and then clicks.
end; //ends the begin statement.
end; //you have to end the case statement, too.
to make sure you don't get lost, this is what your script should look like so far:
{$DEFINE SMART}
{$I SRL/SRL.Simba}
Procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
WorldInfo := [27, 42, 45, 46, 48, 52, 59, 70, 72, 78, 79, 87, 104, 115, 117];
BoxRewards := ['XP','xp','lamp'];
LampSkill := Skill_Slayer;
Active := True;
end;
end;
procedure attack;
var
x, y: Integer;
begin
if FindObjCustom(x, y, ['ttack', 'oblin'], [5482390, 7834647, 9827484], 7) then
case Random(2) of
0: begin
MMouse(x, y, 3, 3);
Clickmouse2(true);
end;
1: begin
MMouse(x, y, 3, 3);
Clickmouse2(false);
Waitoptionmulti(['ttack', 'oblin'], 300);
end;
end;
end;
begin
end.
If your script looks like that, then you're doing good.
Now, We need to check if it's in combat, right? Yes. So, You're going to add if Didredclick then
That'll make the attack procedure look like this:
case Random(2) of
0: begin
MMouse(x, y, 3, 3);
Clickmouse2(true);
if DidRedClick then
Wait(10000);
end;
1: begin
MMouse(x, y, 3, 3);
Clickmouse2(false);
WaitOptionMulti(['ttack', 'oblin'], 300);
if DidRedClick then
Wait(10000);
end;
end;
Now, we're going to setup the main loop.
Y'know, the begin..end. thing
Well, First, you're going to add (if it isn't already there.)
begin
{$IFDEF SMART}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}
DeclarePlayers;
SetupSRL; //sets up SRL.
LogInPlayer; //Logs the player in
end.
Now, you're going to want to add your procedure into it. So, add the NAME ONLY into the main loop.
it'll look like this:
{$IFDEF SMART}
SRL_SixHourFix := True;
Smart_FixSpeed := True;
{$ENDIF}
DeclarePlayers;
SetupSRL;
Attack;
end.
There you go. Now it'll find the goblin, and
kill it.
But it'll only kill only one.
Wha.. Why?!
Because, there's no loop.
But it's called the main loop?
Think of it as a group on friends. There's always that one who won't shutup. He's the loop inside of your friends. That's what you're creating now.
So, just put
repeat
Attack;
until(not(loggedIn);
Now it'll loop until you are logged out, then it'll terminate the script. Now, you've made your first successful script! Good Job!