SRL Archive - First Scripts

one load miner


EtherFreak

2010-07-04 20:17:19

this is a simple script I have created to mine a single load of ore. I came up with it because I do not wish to have a fully automated script. it currently mines from two rocks, and terminates when done. it is crude in the fact that it uses (x,y) cordenets of the rocks, and can not tell if the rock has any ore in it (i would like to improve this so it can tell). I tried using the rock color, but had issues due to changing rock color. I also tried adding tolorences to it, but then I was clicking incorrectly, and not natural. it has random times in it to reduce a chance of ban. I basicaly wanted something so I could be watching tv, and not have to look down every two seconds to click a rock in mining. it could also be used for woodcutting, or addapted for other uses. I figured it was a good place to start, and I would love to get it so I can tell if a rock has ore in it or not.

{setup}
{find the position of the two rocks you want to mine}
{input under constant the x and y cordonets of each rock}
{the first and second time is the wait time between clicking the next rock}
{there is no anti random, and you will only get one load of ore (28 ore)}
{once you have a load of ore from the two rocks, the script will terminate}


program New;
{.Include SRL/SRL.Scar}

Const
pos1x= 270 ;
pos1y=145 ;
pos2x=225 ;
pos2y=165 ;
rtime1=6000 ;
rtime2=6000 ;
Var

xc, yc: Integer;
counter: Integer;
begin
counter:=0;
GetMousePos(xc,yc);
repeat
counter:=counter+1;
mousespeed:=(5+random(10));
MMouse(pos1x,pos1y,4,3);
Wait(random(1000)+rtime1);
GetMousePos(xc,yc);
clickmouse(xc,yc,true);
wait(random(1000)+1000);
MMouse(pos2x,pos2y,4,3);
Wait(random(500)+rtime2);
GetMousePos(xc,yc);
clickmouse(xc,yc,true);
wait(random(1000)+1000);

until(counter>=14)
end.


Narcle

2010-07-04 20:22:11

Ah simple script but good place to start. You should look into FindColorTolerance() and select a color on the rock when there is ore in it. That way it gets the Rock points for you instead of having to manually set them. Also try using WaitUpText('ine', 400) to check and make sure you'll click the rock, its a good failsafe to add.

Edit: Try playing with this to get started if you want. :)

program new;
{.include srl\srl.scar}

Const
RockColor = 0;//use color picker to get rock color

var
x, y: integer;
begin

If FindColorTolerance(x, y, RockColor, MSX1, MSY1, MSX2, MSY2, 0) then
begin
MMouse(x, y, 5, 5);
if WaitUpText('ine', 500) then
begin
GetMousePos(x, y);
Mouse(x, y, 0, 0, true);
end;
end;

end.

Be careful running it, remember the shortcut to stop the script is ctrl+alt+s

EtherFreak

2010-07-05 01:55:43

I tryed using the command "FindColorTolerance" but I found the color of the rock changes too much to use it. I was not using it with the MSX MSY, so this may have been a problem. can you explain what these relate to? The tolerance issues is why I opted for the position method. I also would like to figure out how to make it know when you have completed mining a rock. I know a good way to do this would be to register the text at the bottom that tells you what you got.

NCDS

2010-07-05 02:28:07

From: EtherFreak
I tryed using the command "FindColorTolerance" but I found the color of the rock changes too much to use it. I was not using it with the MSX MSY, so this may have been a problem. can you explain what these relate to?

'MSx1, MSy1, MSx2, MSy2' are constants that represent the coordinates of the RuneScape MainScreen. These, along with many other constants can be found in Globals.Scar/Simba in the SRL include.

From: EtherFreak

The tolerance issues is why I opted for the position method.

Try and use as low as tolerance as possible for it to still work. That will slim your chances of wrong mouse movements.

Your most likely better off using FindColorsSpiralTolerance(); for mining rocks. It has very similar parameters as FindColorsTolerance(); only it gives you the ability to specify where it starts it's search. It's the first 'x, y' parameters. I would use 'MSCx, MSCy' to be my starting point as they represent the center point of the RS Main screen. That way, you should find the closest occurrence of the color your searching for (the rock).

I would also suggest looking through WizzyPlugin.Scar/Simba located in /misc of the SRL include. It is filled with different sorting methods to help you find what you need when using functions such as FindColorsSpiralTolerance.

From: EtherFreak

I also would like to figure out how to make it know when you have completed mining a rock. I know a good way to do this would be to register the text at the bottom that tells you what you got.

Using text is not a bad way at all. Another suggestion I have would be to count the color when you find the rock, then when that color has reduced drastically, the rock is gone.

Example of what I mean:

begin
//All your FindColorsSpiralTolerance and other part of the function up here.
OurColorCount := Length(WhateverYouNamedYourArray);
SecondVariable := OurColorCount;
while (SecondVariable > (OurColorCount / 2)) do
begin
//Whatever you want to do while your mining
end;
end;

Sorry if this is unclear, it's 2:30 a.m. and I'm quite tired. If you need help though I am free tomorrow.

EtherFreak

2010-07-05 22:32:03

Well, I played with the code you posted, but the rocks just change their color too much for the tollerence to be good. (I am mining in the dwarvin mine) Perhapse I could get scar to recognize a color difference when the rock has been mined, and when it regenerates. but finding the color of the ore changes too much.

NCDS

2010-07-05 22:34:46

From: EtherFreak
Well, I played with the code you posted, but the rocks just change their color too much for the tollerence to be good. (I am mining in the dwarvin mine) Perhapse I could get scar to recognize a color difference when the rock has been mined, and when it regenerates. but finding the color of the ore changes too much.


I assure you it is very possible as many people have done it/do it, including myself. It's really just trial and error until you get it right.

Try looking through some other people mining scripts and see if you can pick up anything from that.

i luffs yeww

2010-07-06 00:18:12

You can use ACA to find the best color. :)

nickrules

2010-07-06 12:54:40

Yeah, i would use ACA (auto-color aid). you can find it in
includes>SRL>Scripting tools
open it up (its a .exe), and press F2 to automatically find the runescape client. then, click on the little 'veins' of ore (colored parts) of the rock, several time in different spots. then click 'mark best color'. Everything on the screen highlighted in red can be found by the script. copy the color value, and the RGB tollerance value.

Tinker around with some of the options, you might be surprised at what you can do. ACA can be a very powerful tool.

Also, if you can figure out how to use CTS, set it to 2. its the most accurate (but also slower). But lets not go ahead of ourselves ;)

EtherFreak

2010-07-08 01:11:24

Well, this is my atempt at using color finding in my script, but it does not work. it will move the mouse to the uper left hand corner of the game window if the tollerence is set to a large number (<10000), and sometimes find the rock, sometimes not with it set to a small number(>20). any insight?

Program loadminer;
{.include srl\srl.scar}

Const
RockColor=1911114 ; //color picker
loadcount= 3 ; //total ore to be mined
Var
x, y: integer;
counter: Integer;
begin
counter:=0;
repeat
counter:=counter+1;
mousespeed:=(5+random(10));
begin
FindColorSpiralTolerance(x,y, RockColor, MSX1, MSY1, MSX2, MSY2,12)
wait(random(500));
MMouse(x,y,5,5);
wait(random(1000)+500);
getmousepos(x,y);
clickmouse(x,y,true);
end;
wait(5000)
until(counter>=loadcount)
end.

EtherFreak

2010-07-08 01:31:15

I found my problem. it was the tolerance issue. I was misinterpreting the tolerance off the color number. it now runs, but I feel it is not running "human" enough. it seems to find the edge of the rock, rather then the center, and i think this could raise a red flag. Now to get it to tell what rocks are full or empty, and the timing better…


Program loadminer;
{.include srl\srl.scar}

Const
RockColor=1977165 ; //color picker
loadcount= 26 ; //total ore to be mined
wtime= 9000 ; //total time to wait between mining rocks
Var
x, y: integer;
counter: Integer;
begin
counter:=0;
repeat
counter:=counter+1;
mousespeed:=(5+random(5));
begin
FindColorSpiralTolerance(x,y, RockColor, MSX1, MSY1, MSX2, MSY2,6)
wait(random(1000));
MMouse(x,y,5,5);
wait(random(1000)+500);
getmousepos(x,y);
clickmouse(x,y,true);
end;
wait(wtime);
until(counter>=loadcount)
end.

i luffs yeww

2010-07-08 02:23:22

:x Are you picking a color from the vein or from the rock? You should pick a color from the vein..

weequ

2010-07-08 09:16:54

I suggest using TPointArray and Array Of TPointArray like this:
(should find the middle of the rock)

Also if you don't understand try searching TPA guides from tutorial island section ;)


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

const
Color = 2172988;
Tolerance = 5;
MinCount = 10;//Min amouth of matched colors withing 30 * 30 area

var
Rocks: TPointArray;
RocksT2D: T2DPointArray;
I, x, y: Integer;


begin
repeat
FindColorsSpiralTolerance(MSCX, MSCY, Rocks, Color, MSX1, MSY1, MSX2, MSY2, Tolerance);//Finds all matches of
//the color with given tolerance and saves them to TPointArray
RocksT2D := TPAtoATPAEx(Rocks, 30, 30);//Splits the TPA to boxes with
//sidelengths W and H and results them as a T2DPointArray = Array of TPointArray;
SetLength(Rocks, 0);
for I := 0 to Length(RocksT2D) - 1 do//Loops through the TPA 'boxes'
begin
if Length(RocksT2D[I]) >= MinCount then
begin
MiddleTPAEx(RocksT2D[I], x, y);//Gets the middle of a TPointArray
MouseSpeed := 12 + Random(5);
MMouse(x-2, y-2, 5, 5);
if not WaitUpTextMulti(['Mine', 'e Ro', 'cks /'], 470+Random(99)) then Continue;
GetMousePos(x, y);
Mouse(x, y, 0, 0, True);
Wait(1500+Random(1000));
Break;
end;
end;
until(InvFull);
end.

Heavenguard

2010-07-09 14:36:17

Antti thats a beautiful suggestion, but I dont think learning TPA's right now is the best thing for him. Ether, if you want to make it know if the inventory is full, there is a simple function called InvFull, but besides that…

before you make this script act more "Human-like", I think it would be best if you learned all you could from Tutorials such as Coh3n's All-In-One guide. You seem to have the grip on some procedures as well as variables. The guides will give you a much -clearer- way of making these scripts. Such as using Auto-color aid, as well as giving you the tools you need to make your script do anything you want.

You can't really make a good human like script that just mines ore by learning a couple of procedures. You make a good one by learning a little of everything, I know it sounds stupid, but its true. Everything is learned through steps, just like the basics. Go on to learning from a lot of the "All-In-One" Tutorials that gives you a overall look at scripting :D

WhoCares357 Unmatched Beginner's Guide to Scripting Scar [This was what taught me the basics of the basics of the basics, its an amazing guide. From what I see you can just skip this one though, as you look like you have a great grip on the basics already]

Coh3n's All-In-One SCAR Scripting Tutorial! [Cohen Taught me the Basics to the Advanced in an easy, follow-along way. He shows you how to make quick scripts such as powerminers and powercutters, but but he also teaches you walking, as well as other helpful tools to aid you through any script. Overall my favorite guide of all time :D i <3 Coh3n]

After finishing Coh3n's Guide, you'll pretty much understand how SRL works, and how to view all of its beautiful, well-made procedures and functions.

Naum's TPA Tutorial [After you finish and understand what Coh3n taught you, Then you should feel comfortable learning about T-Point Arrays. They pretty much combine everything you learned and act as the ultimate scripting technique]

And of course, the SRL Community is always here to aid you at any time :D

EtherFreak

2010-07-10 01:33:25

Thank you all for your help. the last code I posted mined a load, but missclicked the rock on an average of 2 times. it also clicks too close to the edge of the rock to be natural. I did set the color to the vein in the rock. I also used autocolor to find a good tolerence value of 6. all clicks where in the area of the rocks, but the tollerence in my mouse clicks resulted in the missed mouse clicks. I will look in to working through a few tutorials. I do not have a desire to make a full blown power miner, or miner baker, but rather a script that can mine one or two types of ore, and stops when full. this greatly reduces the risk of a ban due to randoms, and that the walking is a human user, and any issues from people thinking you are running a bot can be caught. I basically like watching movies and tv, and playing rs, but I hate needing to look down every couple of seconds to click a mouse on a rock. I also think there are some that are looking for a similar script.

my goals:
mine a full inventory of ore
not click anything if a random happens
be able to set several types of ores to mine, and set the priority of each one
have mouse movements similar to those of a human user.

EtherFreak

2010-07-11 00:24:19

well, in working through the tutorial that heavenguard sugjested called "Coh3n's All-In-One SCAR Scripting Tutorial!" I ran into a problem with the "isuptext('whatever')" not returning a posative result. I then searched the forms and found a test code someone sugjested on a different thread. the code is by r1ch and is:
program UpTextTest;
{.include SRL/SRL.scar}

//Press play, then put the mouse over the item/NPC with uptext: TextToCheck

const
TextToCheck = 'anker';

begin
SetupSRL;
ActivateClient;
Wait(2500);
if IsUpText(TextToCheck) then
WriteLn('Works for me') else
WriteLn('Nope, it''s not working');
end.


any sugjestions as to why I might be having issues with this, and sugjestions on how to fix it?

Heavenguard

2010-07-13 13:02:44

UpText is pretty vital when I was scripting, i got problems as well when i was learning it. I suggest you just play around with the IsUpText function so you understand it. No need to use TextToCheck or anything =/, just a simple if IsUpText('w/e'); should work. Just keep a couple things in mind when using this function.

1. I see you understand this already, but remember: No Capital Letters. Lets say your checking the uptext of a tree. You would use IsUpText('ree') to check the uptext for a tree. Also try not to use any spaces =/ just a couple letters. Just keep trying at it.

2. Make sure your SRL or Simba or w/e they call it these days is up-to-date with its fonts :D

3. Make sure all your settings are correct, no HD mode or nuthin, just plain old script-friendly settings ;D

Hope I helped bro.

weequ

2010-07-13 14:26:50

I think you need simba or atleast scar 3.23 in order for uptexts to work (I think that 3.23 is only available through Subversion: http://freddy1990.com/svn/scarprerelease)

EtherFreak

2010-07-13 17:31:47

Well, I have a working load miner. I worked my way (brute force style) through the tutorials. I have tpa up and running. I am also using the WaitUpTextMulti to make sure I have the mouse over the rock. However, I am still sometimes clicking a dwarf, or scorpion. This would indicate an issue with the waituptext and if then statement in the script. As configured, it is set to mine a number of ore and stop, and the ore to be mined is iron. I would say the mouse movement is reasonably realistic.

program loadminerv3;
{.include SRL/SRL.scar}
{.include SRL/Srl/Misc/Debug.scar}

Const
RockColor=1977165 ; //color picker
loadcount= 28 ; //total ore to be mined
wtime= 5000 ; //total time to wait between mining rocks
//setting this too low results in clicking a rock multiple times
var
x, y: integer;
TPA:TPointArray;
ATPA:T2DPointArray;
I: Integer;
counter: Integer;


begin
counter:=0;
repeat
counter:=counter+1;
begin
mousespeed:=(5+random(5));
FindColorsTolerance(TPA, RockColor, MSX1, MSY1, MSX2, MSY2,6);
ATPA := TPAToATPAEx(TPA, 20, 20);
begin
if ( Length(ATPA)=0 ) then
repeat
wait(1000+random(2000));
FindColorsTolerance(TPA, RockColor, MSX1, MSY1, MSX2, MSY2,6);
ATPA := TPAToATPAEx(TPA, 20, 20);
until (Length(ATPA)>0)
end;
SortATPAFrom(ATPA, Point(MSCX, MSCY));
MiddleTPAEx(ATPA, x, y);
wait(50+random(500));
MMouse(x, y, 20, 20);
MMouse(x, y, 8, 8);
wait(random(500)+300);
getmousepos(x,y);
if ( WaitUpTextMulti(['Min', 'ine', 'Roc', 'ocks'], 200) ) then
wait(5);
clickmouse(x,y,true);
end;
wait(wtime+random(1000));
until(counter>=loadcount)
end.

Dynamite

2010-07-13 19:45:01

Use Mouse(X, Y, 1, 1, True)
instead of ClickMouse

EtherFreak

2010-07-13 20:22:49

Use Mouse(X, Y, 1, 1, True)
instead of ClickMouse

do I want to add the random 1 in the x and y axis? will this result in a mouse jump? Also, I am running scar 3.22, I tried 3.23 but had issues with the slr not having a few correct procedures.

EtherFreak

2010-07-22 13:28:01

I have updated myself to scar 3.23. I now have the script working quite well with iron. the uptext is now working, so there is no longer any issue with a misclick on a non rock item. I had some issues with using the invfull command. I have scar click on the inventory, and it then clicks on multiple parts of the inventory, and never goes any further.

program loadminerv3;
{.include SRL/SRL.scar}
{.include SRL/Srl/Misc/Debug.scar}

Const
RockColor=1977165 ; //color picker
loadcount= 28 ; //total ore to be mined
wtime= 6000 ; //total time to wait between mining rocks
//setting this too low results in clicking a rock multiple times
var
x, y: integer;
TPA:TPointArray;
ATPA:T2DPointArray;
I: Integer;
counter: Integer;


begin
counter:=0;
repeat
counter:=counter+1;
begin
mousespeed:=(5+random(5));
FindColorsTolerance(TPA, RockColor, MSX1, MSY1, MSX2, MSY2,6);
ATPA := TPAToATPAEx(TPA, 20, 20);
begin
if ( Length(ATPA)=0 ) then
repeat
wait(1000+random(2000));
FindColorsTolerance(TPA, RockColor, MSX1, MSY1, MSX2, MSY2,6);
ATPA := TPAToATPAEx(TPA, 20, 20);
until (Length(ATPA)>0)
end;
SortATPAFrom(ATPA, Point(MSCX, MSCY));
MiddleTPAEx(ATPA, x, y);
wait(50+random(500));
MMouse(x, y, 20, 20);
MMouse(x, y, 8, 8);
wait(random(500)+300);
getmousepos(x,y);
if ( WaitUpTextMulti(['Min', 'ine', 'Roc', 'ocks'], 200) ) then
Mouse(x,y,1,1,true)else
counter:=counter-1;
end;
wait(wtime+random(1000));
until(counter>=loadcount)
end.

Shuttleu

2010-07-22 13:32:13

well im first going to post this
program loadminerv3.1;
{.include SRL/SRL.scar}
{.include SRL/Srl/Misc/Debug.scar}

Const
RockColor=1977165 ; //color picker
loadcount= 28 ; //total ore to be mined
wtime= 6000 ; //total time to wait between mining rocks
//setting this too low results in clicking a rock multiple times

var
x, y: integer;
TPA:TPointArray;
ATPA:T2DPointArray;
I: Integer;
counter: Integer;


begin
counter:=0;
repeat
counter:=counter+1;
begin
mousespeed:=(5+random(5));
FindColorsTolerance(TPA, RockColor, MSX1, MSY1, MSX2, MSY2,6);
ATPA := TPAToATPAEx(TPA, 20, 20);
begin
if ( Length(ATPA)=0 ) then
repeat
wait(1000+random(2000));
FindColorsTolerance(TPA, RockColor, MSX1, MSY1, MSX2, MSY2,6);
ATPA := TPAToATPAEx(TPA, 20, 20);
until (Length(ATPA)>0)
end;
SortATPAFrom(ATPA, Point(MSCX, MSCY));
MiddleTPAEx(ATPA[i], x, y);
wait(50+random(500));
MMouse(x, y, 20, 20);
MMouse(x, y, 8, 8);
wait(random(500)+300);
getmousepos(x,y);
if ( WaitUpTextMulti(['Min', 'ine', 'Roc', 'ocks'], 200) ) then
Mouse(x,y,1,1,true)
else
counter:=counter-1;
end;
wait(wtime+random(1000));
until(counter>=loadcount)
end.

~shut

EDIT:
first. where is the bit that makes it click on the inventory
second. this bit Mouse(x,y,1,1,true) will always go to x, y, because if you put 1 then it will always return 0 whereas if you put 2 it will return either 0 or 1

EtherFreak

2010-07-22 14:53:53

This is the code that would mine until the invintory was full by using the invfull command. however it does not work

program loadminerv3;
{.include SRL/SRL.scar}
{.include SRL/Srl/Misc/Debug.scar}

Const
RockColor=1977165 ; //color picker
wtime= 6000 ; //total time to wait between mining rocks
//setting this too low results in clicking a rock multiple times
var
x, y: integer;
TPA:TPointArray;
ATPA:T2DPointArray;
I: Integer;

begin

repeat
begin
mousespeed:=(5+random(5));
FindColorsTolerance(TPA, RockColor, MSX1, MSY1, MSX2, MSY2,6);
ATPA := TPAToATPAEx(TPA, 20, 20);
begin
if ( Length(ATPA)=0 ) then
repeat
wait(1000+random(2000));
FindColorsTolerance(TPA, RockColor, MSX1, MSY1, MSX2, MSY2,6);
ATPA := TPAToATPAEx(TPA, 20, 20);
until (Length(ATPA)>0)
end;
SortATPAFrom(ATPA, Point(MSCX, MSCY));
MiddleTPAEx(ATPA, x, y);
wait(50+random(500));
MMouse(x, y, 20, 20);
MMouse(x, y, 8, 8);
wait(random(500)+300);
getmousepos(x,y);
if ( WaitUpTextMulti(['Min', 'ine', 'Roc', 'ocks'], 200) ) then
Mouse(x,y,1,1,true)
end;
wait(wtime+random(1000));
until(InvFull)
end.