SRL Archive - OSR Intermediate Scripting Tutorials

how to make a simple powerminer script


solemn wishes

2006-02-16 18:12:24

-=[TUTORIAL]=-



Hello everyone, i hope this -=[TURTORIAL]=- helps you guys who are n ew to scar or dont understand some commands/procedure's, i hope to cover the following area's:


BITAMPS- How to use a simple bitmap in a mining script.
findcolorspiral- if you dont allready know how to use.
counters- how to make a simple counter.
progress reports- how to make a simple progress report.
simple commands- i am hopeing that this will help teach you some simple commands also.



OK let's begin….


BITMAPS:

A bitmap is bassicly a pitchure that scar can recconize through code, in this turtorial we are making a simple powerminer and therefor i will be creating a bitmap of the letter "M" that appears above the rock you want to be when you hover the mouse above it.


once you have cropped the image down to size it should look something like this.





know because the background color changes if you move area ect we must mkae this so scar will not look for the background color's but just focus on the letter "M"
We can acheive this by simple grabbing the fill took and filling the area around the "M" with black, your letter "M" should know be the only thing viable on your picthure and everything else black.Once you have done this your image should look exactly like this.




Know save this and in the scar window go to "script" then down to "picture to string"simple open your image know look at the bottom of the scar window and you should have something very simular to this*



Mine := BitmapFromString(17, 17, 'z78DADD94DB0' +
'A80200C407F69B38BFAA8ADFFFFA5861B44880F6952B60303D9F4' +
'A0E000AA2282874573EF18C4B2DB7D65522EF590671C6D1429B45' +
'8783F831E2DDAA225810601428B45B8545DAA76B00872BE5ADC09' +
'CC8C69B1E8FB64F7D2D5A396628F5826E62F16C3E0F016E9A9B2D' +
'C0EB16433A7EE1FBD3CA53F603900F40458C2');


copy this and know start a new scar script, create a procedure called "loadbitmaps" or watever you like and know paste your bitmap into this procedure, know you need to declair what the bitmap is, i called my bitmap "mine" so i would write:

var Mine:integer;

at the beggining of my script. You should know have something very much like this.


program powerminer;
var mine:integer;
procedure loadbitmaps;
begin
mine := BitmapFromString(17, 17, 'z78DADD94DB0' +
'A80200C407F69B38BFAA8ADFFFFA5861B44880F6952B60303D9F4' +
'A0E000AA2282874573EF18C4B2DB7D65522EF590671C6D1429B45' +
'8783F831E2DDAA225810601428B45B8545DAA76B00872BE5ADC09' +
'CC8C69B1E8FB64F7D2D5A396628F5826E62F16C3E0F016E9A9B2D' +
'C0EB16433A7EE1FBD3CA53F603900F40458C2');
end;
begin
end.


Ok let's check that its all correct so far, head off to a mining area and get the color of the rock you want to mine.


know write this:

const
rock1color=thecoloroftherock;

Ok so we know have to get scar to find that color and move the mouse, we are going to use "findcolorspiraltolerance" for this. make a new procedure and call it "mine" know put this code in it.


if(FindColorSpiralTolerance(x,y,Rock1Color,5,5,514,337,5))


IF YOU DONT UNDERSTAND THAT THIS MAY HELP





know we need to declair the variables "x and y" type this.


var x,y,mine:integer;



Ok know this is my code, i have hopfully made it clear what each function does and you should be able to understand from this how it all works:



program powerminer;
var x,y,mine:integer;

const
rock1color=9079448;


procedure minethatore;//this is a simple procedure but works
begin
if(FindColorSpiralTolerance(x,y,Rock1Color,5,5,514,337,2))then
movemousesmooth(x,y) //moves the mouse towards the color
wait(1000+500)//wait a random time
if(FindBitmapToleranceIn(mine,x,y,6,6,126,23,1))then//this is the bitmap we made earlier
begin
getmousepos(x,y) //gets the position of the mouse
clickmouse(x,y,true) // clicks the mouse at its current position
wait(3000+1000) //waits 3 seconds + 1 second
end;
end;


procedure loadbitmaps;
begin
mine := BitmapFromString(17, 17, 'z78DADD94DB0' +
'A80200C407F69B38BFAA8ADFFFFA5861B44880F6952B60303D9F4' +
'A0E000AA2282874573EF18C4B2DB7D65522EF590671C6D1429B45' +
'8783F831E2DDAA225810601428B45B8545DAA76B00872BE5ADC09' +
'CC8C69B1E8FB64F7D2D5A396628F5826E62F16C3E0F016E9A9B2D' +
'C0EB16433A7EE1FBD3CA53F603900F40458C2');
end;
begin
end.


Know press ctrl+alt+r and guess what!….it should work, know we need to tell scar what we want it do, firstly we want it to load the bitmaps(if it does not load the bitmaps scar will not reconise them. To get scar to load the bitmaps
simple scroll down to the bottom of our current script and write this:

begin
loadbitmaps;
end.

ok so know when you press ctrl+alt+r the bitmaps will load, know we want scar to mine the rocks until it is unable to, scroll down to the bottom of your scar script again and type this.


begin
loadbitmaps;
repeat //the repeat means for it to repeat what is bellow
minethatore
until(false)//this means until it is unable to or an error occur's
end.


now press "ctrl+alt+r" and the script will hopefully start mining! and to stop the script "ctrl+alt+s".



Know hopefully you have learnt some of the basics of scar lets go over some other thing's.


Adding a counter for example is simple but add's to a script by alot, a counter shows the ammount of times a certain procedure has been done.Let's begin by adding a simple counter to our script and then creating a full progress report for it.


go back to your var and type soemthing like this:

var rocksmined,x,y,mine:integer;


know go back to your script and type this



procedure minethatore;
begin
if(FindColorSpiralTolerance(x,y,Rock1Color,5,5,514,337,2))then
movemousesmooth(x,y)
wait(1000+500)
if(FindBitmapToleranceIn(mine,x,y,6,6,126,23,1))then
begin
getmousepos(x,y)
clickmouse(x,y,true)
wait(3000+1000)
///////////////////////////////////////
rocksmined:=rocksmined+1; //this is what we added
///////////////////////////////////////
end;
end;


know it is time to show this in a writeln form, at the end of your script you have this:

begin
loadbitmaps;
repeat
minethatore
until(false)
end.


change that to something such as this…


begin
loadbitmaps;
repeat
minethatore
writeln('<this turtorial was created by solemn wsishes >');
writeln('mined '+inttostr(rocksmined)+ ' rocks so far');
until(false)
end.


this is whoing the ammoutn of rocks it has mined, you may have noticed that once it mined a rock the counter goes +1, this is a simple function of scar but yet very inportant when creating a detailed script.


this is my final code, and your's should look about the same.



program powerminer;
var rocksmined,x,y,mine:integer;

const
rock1color=16777215;


procedure minethatore;//this is a simple procedure but works
begin
if(FindColorSpiralTolerance(x,y,Rock1Color,5,5,514,337,2))then
movemousesmooth(x,y) //moves the mouse towards the color
wait(1000+500)//wait a random time
if(FindBitmapToleranceIn(mine,x,y,6,6,126,23,1))then//this is the bitmap we made earlier
begin
getmousepos(x,y) //gets the position of the mouse
clickmouse(x,y,true) // clicks the mouse at its current position
wait(3000+1000) //waits 3 seconds + 1 second
end;
end;


procedure loadbitmaps;
begin
mine := BitmapFromString(17, 17, 'z78DADD94DB0' +
'A80200C407F69B38BFAA8ADFFFFA5861B44880F6952B60303D9F4' +
'A0E000AA2282874573EF18C4B2DB7D65522EF590671C6D1429B45' +
'8783F831E2DDAA225810601428B45B8545DAA76B00872BE5ADC09' +
'CC8C69B1E8FB64F7D2D5A396628F5826E62F16C3E0F016E9A9B2D' +
'C0EB16433A7EE1FBD3CA53F603900F40458C2');
end;
begin
loadbitmaps;
repeat
minethatore
writeln('<this turtorial was created by solemn wsishes >');
writeln('mined '+inttostr(rocksmined)+ ' rocks so far');
until(false)
end.






IF I HAVE MADE ANY CODEING ERROR'S OR WATEVER PLZ POST EM :)




copyright 2005-2006
solemn wishes
all rights reserved
error surpost pm me

ilyaostr

2006-02-21 17:40:50

i get the foloing errors


Failed when compiling
Line 13: [Error] (13:49): 'THEN' expected in script
Successfully compiled
[Runtime Error] : Exception: data error in line 24 in script


and uh..

-=[TURTORIAL]=-

lol!

cause

2006-02-28 14:25:09

thanks, this is really something i needed 2 read! :D
Unfourtantly some of your photos arent being hosted anymore.


Thanks!

Cause

The Prince of Randomness?

2006-02-28 22:34:43

Nice but its Tutorial not Turtorial..
Nice Tut anyway..

timmyboy

2006-03-13 15:29:34

Thanks alot! Now I can make(or at least try to) the scripts I want.

Jagex_Fagex

2006-03-14 02:38:50

From: ilyaostr

Failed when compiling
Line 13: [Error] (13:49): 'THEN' expected in script


at the end of line 13 it says th en change that to then :P

Phlame

2006-03-16 21:06:25

this was really helpful, it helped me understand the way the scripting methods work and basically all i need to do now is learn all the commands, and cvars etc

puj

2006-03-17 18:50:04

Thanks, this has really helped me to start making my own scripts :)

Some one

2006-03-17 20:48:32

Wow. Thank you. This is a very understandable tutorial.

Blackhat

2006-04-08 08:35:13

umm i must be wierd i put exactly like u and fixen th en to then lol
but i get this error

Runtime Error] : Exception: data error in line 24 in script
Successfully compiled
[Runtime Error] : Exception: data error in line 24 in script

line 24 if u notice i were the bitmap starts mine is identical to yours,

therfor yours dont work, and every one who posted that it does srry , it dont,
srry maybe it was working at time of post but now it dont :)

It is a really good tutorial anyway man

you could remove


if(FindBitmapToleranceIn(mine,x,y,6,6,126,23,1))th en//this is the bitmap we made earlier
and
loadbitmaps;
and the Mine botmap,
and the varable mine

And it will work jsut fine with out the bitmap :)

Also your end script does not have..

///////////////////////////////////////
rocksmined:=rocksmined+1; //this is what we added
///////////////////////////////////////
in it lol!!! you must of forgot it ;)
the bitmap is wrong

Blackhat

2006-04-08 08:43:34

i answerd my own question lol..

fixed it,

In above example your bitmap is on wrong lines so it wont compile,
It needs to be layed out like this, here is a working bitmap.


Mine := BitmapFromString(14, 12,
'000000000000000000000000000000000000000000000000000000' +
'000000000000000000000000000000000000FFFFFFFFFFFF000000' +
'000000000000000000FFFFFFFFFFFF000000000000000000000000' +
'000000000000FFFFFFFFFFFF000000000000000000000000FFFFFF' +
'FFFFFF000000000000000000000000000000000000FFFFFFFFFFFF' +
'FFFFFF000000000000FFFFFFFFFFFFFFFFFF000000000000000000' +
'000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF' +
'FFFFFFFFFFFF000000000000FFFFFFFFFFFF000000000000FFFFFF' +
'FFFFFF000000FFFFFFFFFFFF000000FFFFFFFFFFFF000000000000' +
'000000000000000000000000FFFFFFFFFFFF000000000000000000' +
'000000FFFFFFFFFFFF000000000000FFFFFFFFFFFF000000000000' +
'FFFFFFFFFFFF000000000000000000000000FFFFFFFFFFFF000000' +
'000000FFFFFFFFFFFF000000000000FFFFFFFFFFFF000000000000' +
'000000000000FFFFFFFFFFFF000000000000FFFFFFFFFFFF000000' +
'000000FFFFFFFFFFFF000000000000000000000000FFFFFFFFFFFF' +
'000000000000FFFFFFFFFFFF000000000000FFFFFFFFFFFF000000' +
'000000000000000000FFFFFFFFFFFF000000000000FFFFFFFFFFFF' +
'000000000000000000000000000000000000000000000000000000' +
'000000000000000000000000000000000000');


notice the actual string starts on a new line :)

phantombmx

2006-04-08 16:06:29

actually if you just do a pic to string.. it gives you the start of the string on the same line as the bitmap name.. try redoing the tutorial and see if it fixes.. that way you get it the exact way it was meant to be according to this tutorial :rolleyes:

h4ph4z4rd

2006-12-29 23:41:03

Aww, pix went off line =(

Doesn't move mouse smooth get you banned really easily?

3volution

2007-01-05 05:47:19

thanks for the tut XD

Kokosing

2007-01-06 18:47:55

thx for taking ya time writing it…
knowledge is power

Mod Mopar

2007-01-13 15:54:40

All picture links are broken :(

bell1313

2007-01-13 16:54:30

Its a bit hard to understand, without the pictures, im a bit lost. :(:(:'(

baracoudaking

2007-04-08 16:14:11

yay ill try to make an autominer ty man

Infantry001

2007-04-08 22:31:23

Just in case ur ever gunna come back ot this topic, solemn, Thanks for htis tut! It helped me become a better scripter (and to help me wirte my own script!)

ronny.m.p

2007-04-14 16:37:42

Picture links are down but if you study it hard enough you can see what he's saying!

TheSantaMan

2007-05-12 23:11:43

hey nice tut. way to make it really understand for noobs :)

randy marsh

2007-06-21 20:47:44

your images arent showng up over then that its good!
If i wanted to add a anti ban what line would i put it on?

sheetomg

2007-06-23 00:48:53

its a powerminer but it doesnt drop?

Diabloizzle

2007-07-21 16:00:36

In your programs they either don't use any procedures or don't have a main loop.

da_stu_man

2007-08-22 07:07:09

can you put these all into one script?? lmfao

valesar

2007-08-22 11:38:12

Nice Tutorial, helped me alot

I B X R

2007-09-01 12:12:21

Wo, nice, basic, but beonde what I Knew how to do.

XxChillinwithmahGnomiesxX

2008-10-05 12:03:16

nice tutorial =]

gl3nni

2008-10-10 14:37:21

Your Picture links are wrongly uploaded, nice and detailed BTW; )

illpwntunoob

2008-11-02 09:08:03

:spot: cool

only thebest

2009-02-10 01:13:06

nice auto i understanded quite well not like others

solemn wishes

2009-03-07 16:36:03

Oh gosh I just read my own tutorial, im terribly sorry about the poor quality and spelling. This was when my english wasnt that great and my typing even worste! The tutorial must be getting on a bit but the basic lesson is still there and a viable learning resource.

I'll look into fixing it up and re-creating the images. I didnt upload them wrongly they are just very old links.