SRL Archive - OSR Intermediate Scripting Tutorials

Updated Guide to Making a PowerMiner


Torrent of Flame

2008-03-23 16:36:56

Original my PLM found here: http://www.villavu.com/forum/showthread.php?t=24726


If you liked my tutorial please Rep++ or Rank The Thread. If you actually read it, please comment!


Credits to PLM for providing the outline to this tutorial.

This needed updating as there was alot of errors on that Tutorial, and I feel it is time to get a new one out there for people to use to stop people asking about obsolete items of errors they recieve.

Anyway….

Welcome to Torrent's Updated Power Miner Guide!

This Tutorial will cover:
- AntiBan
- AntiRandoms
- Mining
- FailSafes
- Constants
- Variables
- Loops
- Declare Players


To Start we should name the the program that we are going to use, calling it something significant to the program you are going to make:

program MyFirstPowerMiner;

Then you HAVE to include this part, as it controls everything that we need to use in this script (FindObjCustom, etc.)

{.include SRL/SRL.scar}

The we include our constants. Constants are basically what they say they are, something that is ALWAYS the same, like RockColours, TreeColours, SMART Worlds, etc.

const
RockColour1= 111111;
RockColour2= 222222;

These Rock Colours would be picked from the Rock You wish to mine, so Iron and Rune would be different, The example colours are obviousley false for any type of rock [Prove me wrong on that one ;) ]

Then we have to declare our variables, not variables again explain themselves, something that is a variable, can constantly change. The variables in this case are the x and the y, the co-ordinates on the game screen. It is an "integer" as they are co-ordinates, which are numerical. Tries will be explained later.

var x, y, Tries: integer;

Then we have our first procedure. I will explain the procedure after we see the overview.

procedure DeclarePlayers; 
begin

HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer:= 0

Players[0].Name := 'Username';
Players[0].Pass := 'Password';
Players[0].Nick := 'erna';
Players[0].Active := True;

end;

Procedure DeclarePlayers tells us the name of the procedure that we are using. Begin starts the procedure [Every "Begin" has an "End", Every "Repeat" has an "Until" and Every "If" has a "Then" - Follow this and it should stop "Idenfitifer Expected ;)]. How Many Players means how many players we are going to use, and Current player tells us which player to start with. Username, Password are pretty basic, but the Nickname HAS to be 3-4 letters of non-capital or without a space of your Username, like mine is. The Active = True tells us if the player is to be run in the script or not.


Now we have our next procedure, our AntiRandoms:

Procedure AntiRandoms;
begin
If(FindFight)then
RunAway('N', True,1,15000);
FindNormalRandoms;
FindLamp('Mining');
end;

And our AntiBan:

procedure AntiBan;
begin
if not LoggedIn then Exit;
case Random(30) of
1: RandomRClick;
2: HoverSkill('Woodcutting', False);
3: RandomMovement;
4: BoredHuman;
5: AlmostLogout;
6: DoEmote(400 +Random(90));
end;
end;

Im Not going to explain AntiBan or AntiRandoms, but you can find a tutorial on them found here: http://www.villavu.com/forum/showthread.php?t=27515

Now onto our actual mining procedure. This part will be merged with an explanation of Fail Safes:

procedure RockMining;
begin
if not LoggedIn then
Exit;
if (not (FindObjCustom(x, y, ['Mi', 'ne'], [RockColour1, RockColour2], 7))) then
Wait(100+random(100));
Tries := Tries + 1;
if(Tries = 20)then
begin
Logout;
Exit;
end else
if FindObjCustom(x, y, ['Min', 'ine'], [RockColour1, RockColour2], 7) then
repeat
case (Random(2)) of
1: Mouse(x, y, 4, 4,false);
ChooseOption('ine');
2: Mouse(x, y, 4, 4, True);
end;
until (InvFull)
end;

From the Start:

procedure RockMining;
begin
if not LoggedIn then
Exit;

We name our procedure, and then it begins. We have our first Fail Safe. If our character is not logged in, the script will exit.

           if (not (FindObjCustom(x, y, ['Mi', 'ne'], [RockColour1, RockColour2], 7))) then
Wait(100+random(100));
Tries := Tries + 1;
if(Tries = 20)then
begin
Logout;
Exit;
end else

Well first, if it doesnt find the Object that says "Mine" when hovered over, including a Tolerance of 7, so it can search 7 pixels either side, it will wait 0.2 seconds, add 1 to the number of tries, and try again. If it Tries 20 times with no success, it will logout your character, to stop you standing there like an idiot, and then exit the script, and Ends ELSE - IE, otherwise..

  if FindObjCustom(x, y, ['Min', 'ine'], [RockColour1, RockColour2], 7) then
repeat
case (Random(2)) of
1: Mouse(x, y, 4, 4,false);
ChooseOption('ine');
2: Mouse(x, y, 4, 4, True);
end;
until (InvFull)
end;

If it actually finds the Rock to mine, it will repeat a random of these 2, it will hover over the rock and Choose "Mine" or it will automatically click on the rock, to make it more human like. It then ends the case, and the repeat goes with the until, like I said earlier, so it will repeat mining until it has a full inventory, then ends the procedure.

Onto our final procedure before the loop, the dropping of the mined material:

Procedure DropRocks;
begin
if FindObjCustom(x, y, ['Ore'], [RockColour1, RockColour2], 7) then
DropTo(2,28);
end;

So, it begins, and if it finds the Object "Ore" with the colours you have picked (The Ore colour is generally the same as the rock colour) then it will drop ores from inventory position 2, to inventory position 28.

Now for our Loop.

We begin by setting up SRL, then repeating the Mine Procedure & Drop procedure:

begin
SetupSRL;
repeat
RockMining;
DropRocks;
AntiBan;
until (False)
end.

So it begins, sets up SRL, repeats Rock Mining, Drop Rocks and AntiBanning, until it is stopped manually.


NOTE: If someone could do the Drop procedure - Greatly appreciated.


Thanks :spongebob:

Richard

2008-03-23 17:33:03

Wow! This is a very good and detialed tut.

I repped you btw :p

PS: erma isnt 4 letters of username :)

Cazax

2008-03-23 17:53:07

Nice one ;) keep posting tuts.

Torrent of Flame

2008-03-23 18:26:45

Thanks guys :D

Just an example Dude ;) Ill edit it now

faster789

2008-03-23 18:55:43

repped! love this tut!

P1nky

2008-03-23 20:15:40

NEWBIE SCRIPTERS! use this! really helpful detail!!!!

good job bro

hessels92

2008-03-23 20:21:36

yea nice work mate. very good :D

Codester93

2008-03-23 20:30:17

Nice tut, i looked at your anti ban/random one. Both are excellent. Keep of the good work. :)

thanx
Codester93

Torrent of Flame

2008-03-24 06:15:11

Thanks Guys :D

Richard

2008-03-24 08:10:22

I think that this should get stickied, a helpful and very detailed tut

Torrent of Flame

2008-03-24 08:14:26

:D Would be nice =]

Gabe

2008-03-24 10:18:30

Thanks! My first ever script that actually works. :P +repped!

Torrent of Flame

2008-03-24 10:39:41

No problem dude :D

Pwnt by Pwnt

2008-03-26 17:04:05

making a drop procedure atm, I'll post it soon :) great tuts btw (even tho I just changed em a little and didn't read a thing ;))

program MyFirstPowerMiner;
{.include SRL/SRL.scar}

var x, y, Tries: integer;

const
RockColour1= 111111;
RockColour2= 222222;

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

Players[0].Name := 'Username';
Players[0].Pass := 'Password';
Players[0].Nick := 'erna';
Players[0].Active := True;
end;

Procedure AntiRandoms;
begin
If(FindFight)then
RunAway('N', True,1,15000);
FindNormalRandoms;
FindLamp('Mining');
end;

procedure AntiBan;
begin
if not LoggedIn then Exit;
case Random(30) of
1: RandomRClick;
2: HoverSkill('Woodcutting', False);
3: RandomMovement;
4: BoredHuman;
5: AlmostLogout;
6: DoEmote(400 +Random(90));
end;
end;

procedure RockMining;
begin
if not LoggedIn then
Exit;
if (not (FindObjCustom(x, y, ['Mi', 'ne'], [RockColour1, RockColour2], 7))) then
Wait(100+random(100));
Tries := Tries + 1;
if(Tries = 20)then
begin
Logout;
Exit;
end else
if FindObjCustom(x, y, ['Min', 'ine'], [RockColour1, RockColour2], 7) then
repeat
case (Random(2)) of
0: begin
Mouse(x, y, 4, 4,false);
ChooseOption('ine');
end;
1: Mouse(x, y, 4, 4, True);
end;
until (InvFull)
end;

Procedure DropRocks;
begin
if FindObjCustom(x, y, ['Ore'], [RockColour1, RockColour2], 7) then
DropAll;
end;

begin
SetupSRL;
repeat
RockMining;
DropRocks;
AntiBan;
until (False)
end.

oops, just noticed you already had a drop proc… this compiles now :)

when you did..


case (Random(2)) of
1: Mouse(x, y, 4, 4,false);
ChooseOption('ine');
2: Mouse(x, y, 4, 4, True);
end;

it should be..

case (Random(2)) of
0: begin
Mouse(x, y, 4, 4,false);
ChooseOption('ine');
end;
1: Mouse(x, y, 4, 4, True);
end;

because the first case is like another proc so you need a
begin
and an
end;
and the case's should be 0 and 1, not 1 and 2

Torrent of Flame

2008-03-29 07:10:43

Thanks for the fix Pwnt

Scaper

2008-04-03 22:48:26

wow very nuce tut man keep up the good qwork

rep++ fro u :)

time4u12

2008-04-04 00:08:37

nice tut, it looks sweet

blobmaster31

2008-04-04 02:15:59

awesome tut. I tried and it mined heaps of iron.

EvilChicken!

2008-04-04 10:08:03

From: Torrent of Flame

Now we have our next procedure, our AntiRandoms:

Procedure AntiRandoms;
begin
If(FindFight)then
RunAway('N', True,1,15000);
FindNormalRandoms;
FindLamp('Mining');
end;


Kinda wrong. FindNormalRandoms finds lamp. And even better, SRL's deafult lampskill is mining! No need for findlamp at all! If you want findlamp to be a different skill, insert this in the 'setup' part of the mainloop in the script. (The part of the mainloop that only is ran once.

LampSkill := 'LampSkill'; // Eg. LampSkill := 'Fishing';

And by the way, your mining procedure can be improved.
Add more failsafes, getmousepos and fix that case. remove randomness from mouseclicks, because you're using FindObj.

DeSnob

2008-04-05 13:09:19

does this power miner thing also apply to making an ess miner? like does most of the rules to making a power miner apply to making a ess miner?

sorry if this confused you but i wanna know how to make an ess miner so bad :)

KoKouKo

2008-04-05 13:13:38

All the same rules apply except that the colour of Essence is close to the color of the walls and surroundings you might want to look at what Wizzup? did in his miner.

Torrent of Flame

2008-04-16 15:31:01

Meh..

Bumpage

Frederick

2008-04-21 09:04:09

Very nice tutorial - and is helping me alot with creating my auto fisher.

Torrent of Flame

2008-04-21 11:35:41

WTF? Autofisher.

Its an POWER MINER. WTH MAN?

sunny

2008-04-22 06:30:16

this is a great [TUT], how do i add a progress report?

how do i fix this?
Line 77: [Error] (12731:1): Unknown identifier 'DropTo' in script C:\Program Files\SCAR 3.15\Scripts\SunnysFirstPowerMiner.scar

jarred1

2008-04-22 06:55:47

Good tut. Though it is the first I've read, explains a lot of the strange coding in SCAR. Thanks +Repped.

thebob142

2008-04-22 19:16:52

torrent i'm trying my hand at scripting again and i keep getting add comma etc.. i do what it says but got stuck on one that kept saying and comma then i did and syntax error please help

Nava2

2008-04-23 08:20:41

Here is my dropping procedure, I modelled it off of one of Hy's. PLEASE CREDIT IF USED!

{*******************************************************************************
procedure DropInv(f,l: integer);
By: Nava2-Modelled after DropeItem by Hy71194.
Description: Drops items in slots f-l.
*******************************************************************************}

procedure DropInv(f,l: integer);
var i: integer;
TMSpeed: integer;
begin
if (not (LoggedIn)) then
begin
writeln('ended at dropInv');
exit;
end;
TMSpeed:= MouseSpeed;
MouseSpeed:= 20+random(7);
GameTab(4);
if ExistsItem(i) then
for i:= f to l do
DropItem(i);
Writeln('Emptied Out Iron!')
MouseSpeed:=TMSpeed;
end;

Nava2

Jimmy5410

2008-05-12 23:50:06

Thanks for the guide, works great! =)

I.P Smasher

2008-05-13 22:28:29

Line 61: [Error] (12704:20): colon (':') expected in script ????

I.P Smasher

2008-05-13 22:42:34

ok nvm about that semiclolon post i fixed but for some reason my logging in messes up, i did the declare players but it just goes but before it even hits the existing user button it just sits in one spot above it and just keeps click randomely????? i did everything properly????

Zlakata

2008-05-15 08:55:35

Very good tut, good for begginers like me, it mined a invy of iron for me :)

Kalle

2008-05-15 12:08:02

I think I'm going to try this tutorial out

MetalancA

2008-06-30 23:47:01

I keep getting

"Unknown identifier 'Tries' in script"

Yet I have the latest version of SRL and scar..

Can anyone help me on this?

TheMaestro

2008-07-02 21:41:34

Great tut! Now I just need to figure out how to make my powerminer drop after it mines 2 iron. That way I drop when the other rock is refreshing and don't waste anytime dropping a full load. Continuous mining.

carlover

2008-07-02 23:58:19

Question? when you setup the SRL why dont u make it repeat the antirandoms also?

bell1313

2008-07-03 02:27:23

This is great. Just the kinda thing i was looking for!

bell1313

2008-07-03 02:32:40

From: TheMaestro
Great tut! Now I just need to figure out how to make my powerminer drop after it mines 2 iron. That way I drop when the other rock is refreshing and don't waste anytime dropping a full load. Continuous mining.


it says in the thread the dropping part. like (2,28) just change it to (2,4) should work.

EDIT: Sorry for double post!!! :(

hahicx

2008-07-03 15:50:04

Thanks for this guide. It's really helpful.

On my way to making my first script…

0wn 4 skill

2008-07-03 21:38:02

This really is an excellent guide. It would be interesting if u made something a little more advance… :D but this is very good for begginners.

I Jake I

2008-07-04 09:38:57

Nice tutorial. Didn't work for me though :(

nobody u kno

2008-07-11 20:19:15

From: I.P Smasher
Line 61: [Error] (12704:20): colon (':') expected in script ????


How do you fix that error??

spire8989

2008-07-13 05:42:17

From: nobody u kno
How do you fix that error??


Well considering it says it's expecting a colon, maybe you should put a colon on that line.

siraren3

2008-07-22 23:20:34

THank you vary much this will help me understand mining so i can do essence miner or a granite miner tyvm .

siraren3

2008-07-22 23:23:31

From: nobody u kno
How do you fix that error??


yeah just add a ; were its need for me it never goes to the exaxt spot just the right line or line above or under it wired system scar is but vary usefull and I dont think anyone should be told this when asking a Q :google: becouse it should say serach it nub that way nonone needs to use google lol

Ghostman

2008-07-26 10:00:48

Nice guide- very helpful

Wolygon

2008-07-27 23:42:29

thank you for this very good tut im only posting cuz he posted…lol its very good and i liked it =]

Minkino

2008-09-28 21:33:26

I get this error when compiling:
Line 45: [Error] (16405:4): Unknown identifier 'AlmostLogout' in script

Daniel

2008-09-28 21:35:00

From: Minkino
I get this error when compiling:
Line 45: [Error] (16405:4): Unknown identifier 'AlmostLogout' in script


AlmostLogout was an Anti-Ban procedure which was removed from SRL ;)

jcoops

2009-10-17 19:40:56

{.include SRL/SRL.scar} do i have to download something it says it doesnt exist

123ran1

2012-03-27 17:56:08

[Error] (23:6): Unknown identifier 'FindFight' at line 22
Compiling failed.

help did findfight get removed or what?

Imanoobbot

2012-03-28 08:01:56

From: Torrent of Flame



NOTE: If someone could do the Drop procedure - Greatly appreciated.


Thanks :spongebob:




Okey here is my IronPowerMiner in its version 0.1. Should be very helpful for this tutorial to make it more detailed :)

http://pastebin.com/index/SPepPSfw


Here are some threads to get how it was created. Just read it and its like step for step to a Powerminer. Dropping the ores good. Including an autocolor function and others.

http://villavu.com/forum/showthread.php?t=78312

Imanoobbot

2012-03-28 14:54:44


procedure AntiBan;
begin
if not LoggedIn then Exit;
case Random(30) of
1: RandomRClick;
2: HoverSkill('Woodcutting', False); // Put Mining in there....
3: RandomMovement;
4: BoredHuman;
5: AlmostLogout;
6: DoEmote(400 +Random(90));
end;
end;

From: Torrent of Flame
WTF? Autofisher.

Its an POWER MINER. WTH MAN?


If you change the Dtms and Colors it would be a Powerfisher ;) makes no real difference

-Imanoobbot