SRL Archive - First Scripts

My first PowerMiner


Kold

2007-12-30 18:27:38

When I first came here, I didn't expect I'd be writing scripts but I now realize that leeching is really "asshatty" and so I decided to read some tutorials and try to make my own script.

Now, I haven't tested the following script because I'm 95% sure that it won't work. I'm also sure that I messed up somewhere in the script and it won't compile correctly. Therefore, I'm accepting ANY help or advice to try to make it better in hopes of me learning to become a better scripter.

Perhaps I've gone beyond my limitations by making it do up to 6 different rocks (Tin, Copper, Iron, Coal, Mithril, Admantine) but I tried it.

This is my powerminer. There are no AntiRandoms, no Multiplayer, no AutoLogin, nothing special. The only thing I hope this will do is go up to a rock and mine it. Then when the inventory is full, I hope it will drop all the rocks.

You will need ScarScape in order to use this which can be found here:
http://freewebs.com/jk2fakefiles/ScarScape/Run.Html - Credits to JuKKa.

VERSION 1.0
program KoldPowerMiner;

{ Instructions
1. You MUST use ScarScape for this script to work. Normal
RuneScape will NOT work.
You may find ScarScape at the following website:
http://freewebs.com/jk2fakefiles/ScarScape/Run.Html - Credits to JuKKa
2. You must have a pickaxe equipped.
3. You must be near the rocks you wish to mine.
4. You must start with an empty inventory.

THIS SCRIPT ONLY WORKS WITH OLD ROCKS!
NEW ROCKS DO NOT WORK IN THIS SCRIPT! }


const
HowManyLoads = 10; //How many loads (full inventories) you wish your player to mine before the script stops.
WaitPerRock = 5000; //The time to wait while mining a rock. (1000 = 1 second)
Version = '1.0'; //This is just for me. This won't affect the mining procedure. Please Don't change it.
RockToMine = ''; //What rock would you like to mine? Choose from below.
Tin = 8553100; //DON'T EDIT!
Copper = 4153733; //DON'T EDIT!
Iron = 2305610; //DON'T EDIT!
Coal = 3163461; //DON'T EDIT!
Mithril = 5979710; //DON'T EDIT!
Admantine = 5992795; //DON'T EDIT!

var
x,y: Integer;

Procedure MiningRocks;
begin
repeat
if(FindColorTolerance(x, y, RockToMine, 0, 0, 700, 500, 4))then
begin
Mouse(x, y, 0, 0, true);
Wait(WaitPerRock + Random(1000));
end else
Writeln('Could not find specified rock.')
Wait(200 + Random(50));
until(InvFull)
end;

Procedure Drop;
begin
DropToPosition(1, 28);
HowManyLoads:=HowManyLoads + 1;
end;

Procedure Thanks;
begin
ClearDebug;

Writeln('Thanks for using KoldPowerMiner V. ' + Version +);
end.

VERSION 1.1
{                                  Instructions
1. You MUST use ScarScape for this script to work. Normal
RuneScape will NOT work.
You may find ScarScape at the following website:
http://freewebs.com/jk2fakefiles/ScarScape/Run.Html - Credits to JuKKa
2. You must have a pickaxe equipped.
3. You must be near the rocks you wish to mine.
4. You must start with an empty inventory.

THIS SCRIPT ONLY WORKS WITH OLD ROCKS!
NEW ROCKS DO NOT WORK IN THIS SCRIPT! }


const
HowManyLoads = 10; //How many loads (full inventories) you wish your player to mine before the script stops.
WaitPerRock = 5000; //The time to wait while mining a rock. (1000 = 1 second)
Version = '1.0'; //This is just for me. This won't affect the mining procedure. Please Don't change it.
RockToMine = ''; //What rock would you like to mine? Choose from below.
Tin = 8553100; //DON'T EDIT!
Copper = 4153733; //DON'T EDIT!
Iron = 2305610; //DON'T EDIT!
Coal = 3163461; //DON'T EDIT!
Mithril = 5979710; //DON'T EDIT!
Admantine = 5992795; //DON'T EDIT!

var
x,y: Integer;
LoadsDone: Integer;

Procedure MiningRocks;
begin
repeat
if(FindColorTolerance(x, y, RockToMine, 0, 0, 700, 500, 4))then
begin
Mouse(x, y, 0, 0, true);
Wait(WaitPerRock + Random(1000));
end else
Writeln('Could not find specified rock.')
Wait(200 + Random(50));
until(InvFull)
end;

Procedure Drop;
begin
DropToPosition(1, 28);
LoadsDone:= LoadsDone+ 1;
end;

begin
repeat
MiningRocks;
Drop;
until(LoadsDone > LoadsToDo);

Procedure Thanks;
begin
ClearDebug;
Writeln('Thanks for using KoldPowerMiner V. ' + Version +);
end;

begin
Thanks;
end.

Once again, thanks for any help. It's greatly appreciated and necessary.

A G E N T

2007-12-30 22:23:56

Good work for a first try :)

The first thing you need to understand is that a script isn't just made from procedures; they are the building blocks of the script, but you need a "Main Line" to put them together.

For your script, a very simple, basic example would be:


begin
repeat
MiningRocks;
Drop;
until(false);

However, this could be improved by using the HowManyLoads constant. You can implement this by adding this to your variable declarations:


var
x,y: Integer;
LoadsDone : integer;

And in your drop procedure:


Procedure Drop;
begin
DropToPosition(1, 28);
LoadsDone:= LoadsDone+ 1;
end;
Using the constant would have been wrong because that would simply add to the 10 or whatever value they set. Anyway, having set this, in your "Main Line" you can use this:


begin
repeat
MiningRocks;
Drop;
until(LoadsDone > LoadsToDo);

Keep these things in mind, and keep working at this script. Congratulations on your first effort, keep it up :)

Kold

2007-12-30 23:10:12

Those are some awesome points there! Thanks. I'll implement it in the next version.

Really… Thanks.

EDIT:

New version is up.

Is that what you meant, Agent83?

Also, I'm fully aware that this isn't a script to use. It doesn't have AntiRandoms or anything. But could you tell me if this script will get me banned instantly or if it's actually a little ban-proof ie. mouse movements, exc.

Lastly, I'm getting the following error when trying to compile.

Line 52: [Error] (52:60): Type mismatch in script C:\Users\Oliver\Desktop\Kold PowerMiner V.1.1.scar

Could anybody help me fix it? I have no idea what's wrong.

John Ayy

2007-12-31 06:52:57

I ran for 15 mins, pretty good. With antirandoms you would have a l33t script here man.

n3ss3s

2007-12-31 07:11:11

John, shut up, you've been spamming all day and now lying too, the script doesn't compile.

Kold

2007-12-31 15:55:49

Well could you possibly help me fix the non-compilation? I have no idea what's wrong with it.

A G E N T

2008-01-02 19:40:18

OK, I'll edit stuff in in a minute :)

EDIT1: Your main line was in the wrong place. Fixed that.
And also, the problem is on this line:

if(FindColorTolerance(x, y, RockToMine, 0, 0, 700, 500, 4))then

You defined RockToMine as a string constant, it has to be a number. Wait while I find a workaround.

EDIT2: Just noticed another thing. At the beginning of your script, you always need to have

Program Name;
//If you want to use SRL you have to put
{.include SRL/SRL.scar}

//then at the beginning of the main line you also have to put

begin
SetUpSRL;
Script here;
end.

OK, last edit for now. :) I made a little function to get the right colour, I'm sure there's a better way but I can't seem to think of anything else right now. There was also a tiny problem in the writeln() in Thanks, I deleted the erroneous trailing + sign.


program New;
{.include SRL/SRL.scar}
{ Instructions
1. You MUST use ScarScape for this script to work. Normal
RuneScape will NOT work.
You may find ScarScape at the following website:
[url]http://freewebs.com/jk2fakefiles/ScarScape/Run.Html[/url] - Credits to JuKKa
2. You must have a pickaxe equipped.
3. You must be near the rocks you wish to mine.
4. You must start with an empty inventory.

THIS SCRIPT ONLY WORKS WITH OLD ROCKS!
NEW ROCKS DO NOT WORK IN THIS SCRIPT! }


const
HowManyLoads = 10; //How many loads (full inventories) you wish your player to mine before the script stops.
WaitPerRock = 5000; //The time to wait while mining a rock. (1000 = 1 second)
Version = '1.1'; //This is just for me. This won't affect the mining procedure. Please Don't change it.
RockToMine = 'Tin'; //What rock would you like to mine? Choose from below.

var
x,y: Integer;
LoadsDone: Integer;

function PickRockColour(Colour : string) : integer;
begin
case Colour of
'Tin' : Result := 8553100;
'Copper' : Result := 4153733;
'Iron' : Result := 2305610;
'Coal' : Result := 3163461;
'Mithril' : Result := 5979710;
'Admantine' : Result := 5992795;
end;
end;

Procedure MiningRocks;
begin
repeat
if(FindColorTolerance(x, y, PickRockColour(RockToMine), 0, 0, 700, 500, 4))then
begin
Mouse(x, y, 0, 0, true);
Wait(WaitPerRock + Random(1000));
end else
Writeln('Could not find specified rock.')
Wait(200 + Random(50));
until(InvFull)
end;

Procedure Drop;
begin
DropToPosition(1, 28);
LoadsDone:= LoadsDone+ 1;
end;

Procedure Thanks;
begin
ClearDebug;
Writeln('Thanks for using KoldPowerMiner V. ' + Version);
end;

begin
repeat
MiningRocks;
Drop;
until(LoadsDone > HowManyLoads);
Thanks;
end.

Kold

2008-01-02 21:42:49

Wow, um… Thanks a lot, Agent.

I just have one question about the resulting script. Everything else makes complete sense to me but I don't understand what the

"case Color of"

part is about. Could you somehow explain that to me? I've never seen that used before.

A G E N T

2008-01-02 21:59:41

Hm, I'll try to explain as best I can, but I find it's best to just play around with it to learn.

The basic unit is

case ... of
...
end;

Between case and of goes your selector, in this case, the selector was the input variable for the function (Colour, which in this case was a string).

Between the case declaration and the end, you have to put in stuff to do, paired with identifiers, for example:


'Tin' : Result := 8553100;

'Tin' is the identifier, and the instructions (Result:=) go after the colon. So basically, the script matches the value of the selector (Color) with an identifier within the case ('Tin'). It carries out the instructions depending on this.

If I wasn't clear, I think there are some good tuts around about cases.

Kold

2008-01-02 22:28:18

Yeah I still don't really understand. I'll look around.

However, I believe yours was one of the tuts I read back when I was a total noob at scripting so I have you to thank for a bunch of this anyways.

Also. The script now compiles but it doesn't work. So I'm at a loss. I gave it my best. As I said, I may have started too big for my capabilities. I may have to start smaller first.