PDA

View Full Version : how to make a simple powerminer script



solemn wishes
02-16-2006, 11:12 PM
-=[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.

(http://imageshack.us)



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.


[img=http://img233.imageshack.us/img233/6340/bitmapturtorial22ct.png] (http://imageshack.us)

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' +
'A80200C407F69B38BFAA8ADFFFFA5861B44880F6952B60303 D9F4' +
'A0E000AA2282874573EF18C4B2DB7D65522EF590671C6D142 9B45' +
'8783F831E2DDAA225810601428B45B8545DAA76B00872BE5A DC09' +
'CC8C69B1E8FB64F7D2D5A396628F5826E62F16C3E0F016E9A 9B2D' +
'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' +
'A80200C407F69B38BFAA8ADFFFFA5861B44880F6952B60303 D9F4' +
'A0E000AA2282874573EF18C4B2DB7D65522EF590671C6D142 9B45' +
'8783F831E2DDAA225810601428B45B8545DAA76B00872BE5A DC09' +
'CC8C69B1E8FB64F7D2D5A396628F5826E62F16C3E0F016E9A 9B2D' +
'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


[IMG]http://img226.imageshack.us/img226/3596/turtorial4ip.th.png (http://img226.imageshack.us/my.php?image=turtorial4ip.png)


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))th en//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' +
'A80200C407F69B38BFAA8ADFFFFA5861B44880F6952B60303 D9F4' +
'A0E000AA2282874573EF18C4B2DB7D65522EF590671C6D142 9B45' +
'8783F831E2DDAA225810601428B45B8545DAA76B00872BE5A DC09' +
'CC8C69B1E8FB64F7D2D5A396628F5826E62F16C3E0F016E9A 9B2D' +
'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))th en
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))th en//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' +
'A80200C407F69B38BFAA8ADFFFFA5861B44880F6952B60303 D9F4' +
'A0E000AA2282874573EF18C4B2DB7D65522EF590671C6D142 9B45' +
'8783F831E2DDAA225810601428B45B8545DAA76B00872BE5A DC09' +
'CC8C69B1E8FB64F7D2D5A396628F5826E62F16C3E0F016E9A 9B2D' +
'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
02-21-2006, 10:40 PM
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
02-28-2006, 07:25 PM
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?
03-01-2006, 03:34 AM
Nice but its Tutorial not Turtorial..
Nice Tut anyway..

timmyboy
03-13-2006, 08:29 PM
Thanks alot! Now I can make(or at least try to) the scripts I want.

Jagex_Fagex
03-14-2006, 07:38 AM
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
03-17-2006, 02:06 AM
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
03-17-2006, 11:50 PM
Thanks, this has really helped me to start making my own scripts :)

Some one
03-18-2006, 01:48 AM
Wow. Thank you. This is a very understandable tutorial.

Blackhat
04-08-2006, 12:35 PM
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
04-08-2006, 12:43 PM
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,
'0000000000000000000000000000000000000000000000000 00000' +
'000000000000000000000000000000000000FFFFFFFFFFFF0 00000' +
'000000000000000000FFFFFFFFFFFF0000000000000000000 00000' +
'000000000000FFFFFFFFFFFF000000000000000000000000F FFFFF' +
'FFFFFF000000000000000000000000000000000000FFFFFFF FFFFF' +
'FFFFFF000000000000FFFFFFFFFFFFFFFFFF0000000000000 00000' +
'000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF FFFFF' +
'FFFFFFFFFFFF000000000000FFFFFFFFFFFF000000000000F FFFFF' +
'FFFFFF000000FFFFFFFFFFFF000000FFFFFFFFFFFF0000000 00000' +
'000000000000000000000000FFFFFFFFFFFF0000000000000 00000' +
'000000FFFFFFFFFFFF000000000000FFFFFFFFFFFF0000000 00000' +
'FFFFFFFFFFFF000000000000000000000000FFFFFFFFFFFF0 00000' +
'000000FFFFFFFFFFFF000000000000FFFFFFFFFFFF0000000 00000' +
'000000000000FFFFFFFFFFFF000000000000FFFFFFFFFFFF0 00000' +
'000000FFFFFFFFFFFF000000000000000000000000FFFFFFF FFFFF' +
'000000000000FFFFFFFFFFFF000000000000FFFFFFFFFFFF0 00000' +
'000000000000000000FFFFFFFFFFFF000000000000FFFFFFF FFFFF' +
'0000000000000000000000000000000000000000000000000 00000' +
'000000000000000000000000000000000000');



notice the actual string starts on a new line :)

phantombmx
04-08-2006, 08:06 PM
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
12-30-2006, 04:41 AM
Aww, pix went off line =(

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

3volution
01-05-2007, 10:47 AM
thanks for the tut XD

Kokosing
01-06-2007, 11:47 PM
thx for taking ya time writing it...
knowledge is power

Mod Mopar
01-13-2007, 08:54 PM
All picture links are broken :(

bell1313
01-13-2007, 09:54 PM
Its a bit hard to understand, without the pictures, im a bit lost. :(:(:'(

baracoudaking
04-08-2007, 08:14 PM
yay ill try to make an autominer ty man

Infantry001
04-09-2007, 02:31 AM
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
04-14-2007, 08:37 PM
Picture links are down but if you study it hard enough you can see what he's saying!

TheSantaMan
05-13-2007, 03:11 AM
hey nice tut. way to make it really understand for noobs :)

randy marsh
06-22-2007, 12:47 AM
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
06-23-2007, 04:48 AM
its a powerminer but it doesnt drop?

Diabloizzle
07-21-2007, 08:00 PM
In your programs they either don't use any procedures or don't have a main loop.

da_stu_man
08-22-2007, 11:07 AM
can you put these all into one script?? lmfao

valesar
08-22-2007, 03:38 PM
Nice Tutorial, helped me alot

I B X R
09-01-2007, 04:12 PM
Wo, nice, basic, but beonde what I Knew how to do.

XxChillinwithmahGnomiesxX
10-05-2008, 04:03 PM
nice tutorial =]

gl3nni
10-10-2008, 06:37 PM
Your Picture links are wrongly uploaded, nice and detailed BTW; )

illpwntunoob
11-02-2008, 02:08 PM
:spot: cool

only thebest
02-10-2009, 06:13 AM
nice auto i understanded quite well not like others

solemn wishes
03-07-2009, 09:36 PM
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.