Log in

View Full Version : Creating a powerminer....



Gold
09-05-2010, 10:06 PM
From the ground up....

Now, I've looked through the noob tutorials and I don't know what it is, but they just leave me going "huh?"

So, is there anyone out there who would tutor me in how to make a powerminer, which would be from then on my script I update to give back to the SRL community (Maybe become a member and finally see those beautiful members scripts :D )

Declare players I can do, but I'm really stuck as to what to do next. Obviously it has to search around the player for an ore, and since this is just a powerminer walking wouldn't be an issue.

Later though, if this all started to make sense, my next plan would be a flax picker/spinner.

So, I have an Aim, I'll try to be on if anyone is interested in helping out.



Edit: Right now I am working on it just finding a certain ore (right now tin)

Program FindOre;

var
X,Y: Integer;

function MineOre : Boolean;
Begin
if FindOreColour Then
begin
MMouse(X, Y, 5, 5);
if WaitUpText('cks', 600) then
begin
GetMousePos(X, Y);
Mouse(X, Y, 0, 0 False);
Result:=WaitOption('ine', 600)'
end;
end;
end;

function FindOreColour : Boolean;
begin
Result:= FindColorTolerance(X, Y, 10000799, MIX1, MIY1, MIX2, MIY2, 20);
end;

begin
SetupSRL;
MineOre;
end.

And when I compile I get

[Error] (9:6): Unknown identifier 'FindOreColour' at line 8
Compiling failed.

So where do I declare FindOreColour?

JPHamlett
09-05-2010, 10:44 PM
Hey, if you want some help I'd be happy to help you out just add my MSN.

Jphamlett@live.com

Gold
09-05-2010, 11:10 PM
Alright thanks, I found my old powerminer that I'm not even sure how I got scripted.

How do I find out where to update all my terms and stuff?

Here's the miner

(Also, just someone to explain everything I wrote. I don't remember anything because in all honesty Timer did 90% of the work)

Cstrike
09-06-2010, 12:12 AM
Ill try and break this down as simple as i can :)

1) remove the quotation mark at the end of this line
Result:=WaitOption('ine', 600)'
That will screw your entire script up

2) To save lines of code, you can get rid of your function and replace
if FindOreColour Then
with
if FindColorTolerance(X, Y, 10000799, MIX1, MIY1, MIX2, MIY2, 20) Then
The reason you can replace them is because FindColorTolerance will return as true/false, so you don't need to make a whole function to do it for you

3) You're missing a comma here
Mouse(X, Y, 0, 0 False);
// Below with comma added
Mouse(X, Y, 0, 0, False);
If you want to be fancy, try this :)

Program FindOre;

var
X,Y: Integer;

function MineOre : Boolean;
Begin
if FindColorTolerance(X, Y, 10000799, MIX1, MIY1, MIX2, MIY2, 20) Then // Are you sure about a tolerance of 20? Thats pretty big! Usually 10-12 is my personal max
begin
MMouse(X, Y, 5, 5);
if WaitUpText('cks', 600) then
begin
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Result:=WaitOption('ine', 600)
end;
end;
end;

begin
SetupSRL;
ActivateClient; // Sets it so it will bring RS window to the top so you dont have to click it
MineOre;
end.

There may be more that can be fixed, but youre on the right track

Also try turning your function into a procedure for now, since you don't do anything with the result
If theres jargon, I will clarify it for you

Gold
09-06-2010, 01:36 AM
Ill try and break this down as simple as i can :)

2) To save lines of code, you can get rid of your function and replace
if FindOreColour Then
with
if FindColorTolerance(X, Y, 10000799, MIX1, MIY1, MIX2, MIY2, 20) Then
The reason you can replace them is because FindColorTolerance will return as true/false, so you don't need to make a whole function to do it for you



So what exactly am I removing?

This right: function FindOreColour : Boolean;
begin
Result:= FindColorTolerance(X, Y, 10000799, MIX1, MIY1, MIX2, MIY2, 20);
end;

also, after adding your fixes I got

[Error] (9:41): Unknown identifier 'MIX1' at line 8
Compiling failed.

How do I find identifiers to correct it?

Cstrike
09-06-2010, 01:58 AM
I fucked up, make sure you include srl/srl.scar


Program FindOre;
{$i SRL/SRL.scar}

var
X,Y: Integer;

function MineOre : Boolean;
Begin
if FindColorTolerance(X, Y, 10000799, MIX1, MIY1, MIX2, MIY2, 20) Then // Are you sure about a tolerance of 20? Thats pretty big! Usually 10-12 is my personal max
begin
MMouse(X, Y, 5, 5);
if WaitUpText('cks', 600) then
begin
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Result:=WaitOption('ine', 600)
end;
end;
end;

begin
SetupSRL;
ActivateClient; // Sets it so it will bring RS window to the top so you dont have to click it
MineOre;
end.

If you're using scar instead of simba this wont work

Mr. Doctor
09-06-2010, 02:11 AM
In your first example, before cstrike updated it, you got that error because the boolean you called, FindOreColour, was under the procedure it was being called by. To move up a function/procedure, do


procedure ProcedureNameHere; forward;

function FunctionNameHere; forward;

Gold
09-06-2010, 02:13 AM
Alright so it compiled,

SRL Compiled in 15 msec
Exception: Range check error at line 9
The following DTMs were not freed: [SRL - Lamp bitmap]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap]
File[C:\Users\Jackson\Simba\Includes\SRL\Logs\SRL Log 05-09-10 2.txt] has not been freed in the script, freeing it now.

I assume this is because there is only 1 function or am I wrong?

Gold
09-06-2010, 02:29 AM
So, my script is now this:

Program FindOre;
{$i SRL/SRL.scar}

var
X,Y: Integer;

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

Players[0].Name := ''; //username
Players[0].Pass := ''; //password
Players[0].Nick := ''; //3-4 letters of your username, no caps or first letter
Players[0].Active := true; //Active or not
end;

function MineOre : Boolean;
Begin
if FindColorTolerance(X, Y, 10000799, MIX1, MIY1, MIX2, MIY2, 12) then
begin
MMouse(X, Y, 5, 5);
if WaitUpText('cks', 600) then
begin
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Result:=WaitOption('ine', 600)
end;
end;
end;

begin
SetupSRL;
DeclarePlayers;
ActivateClient;
if(not(loggedin))then
Loginplayer;
MineOre;
end.

Which gets me this


Compiled succesfully in 843 ms.
SRL Compiled in 15 msec
Successfully executed.

It didn't try to mine the ore, just finished the script.

Also, just a heads up things I want to add:
Smart
Antiban
All ores up to coal
Multiplayer


So, any useful links or info on those would be amazing :D

Edit: I know why it didn't mine, it needed a repeat, and until but I don't know what to put after until

Cstrike
09-06-2010, 04:06 AM
Nice, we're getting better :)
I added a few things, and added standards. I included smart so now you can use SMART when you have declareplayers. Whenever you use declareplayers, try smart ;)

Program FindOre;
{$i SRL/SRL.scar}
{$i SRL/SRL/Misc/SMART.scar}

var
X,Y: Integer;

procedure DeclarePlayers;
begin
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := ''; //username
Players[0].Pass := ''; //password
Players[0].Nick := ''; //3-4 letters of your username, no caps or first letter
Players[0].Active := true; //Active or not
end;

procedure AntiBan;
begin
if not LoggedIn then Exit;
case Random(25) of
0: begin
BoredHuman;
Debug ('Did bored human');
end;
1: begin
RandomRClick;
writeln ('Did random right click');
end;
end;
end;

function MineOre : Boolean;
Begin
if not LoggedIn then exit;
if FindColorTolerance(X, Y, 10000799, MIX1, MIY1, MIX2, MIY2, 12) then
begin
writeln ('We found the color!');
MMouse(X, Y, 5, 5);
if WaitUpText('cks', 600) then
begin
writeln ('WaitUpText found!');
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Result := true;
end else writeln ('WaitUpText returned false');
end else
begin
writeln ('We did not find the color 10000799 in MIX1 to MIY2');
result := false;
end;
end;

begin
SetupSRL;
DeclarePlayers;
LogInPlayer;
ActivateClient;
MineOre;
end.

Try this and see if it works :)
If theres some random crap I added that you don't understand, I'll tell you all I know.

Gold
09-06-2010, 04:13 PM
I get what you added, it acts like a bored human with the mouse, and the occasional right click.

And it notifies the user when the ore was found or not found.

I got some weird errors when running it though.

ERROR in TMThread.LoadFile
Exception in Script: Unable to find file 'C:\Users\Jackson\Simba\Includes\SRL/SRL/Core/AntiRandoms/Leo.scar' used from 'C:\Users\Jackson\Simba\Includes\SRL/SRL.scar'

Then:

[Error] C:\Users\Jackson\Simba\Includes\SRL/SRL/Misc/SMART.scar(9:10): Duplicate identifier 'ISKEYDOWN' at line 8
Compiling failed.

Cstrike
09-06-2010, 04:31 PM
Try this, I know this compiled on my computer

program MyScript;
{$i SRL/SRL/Misc/SMART.scar}
{$i SRL/SRL.scar}

var x, y : Integer;
procedure DeclarePlayers;
begin
NumberOfPlayers(1); // How many players? 1 account = "1', 5 accounts = "5"...
CurrentPlayer := 0; // Start at player "zero" (aka player 1)
Players[0].Name := '';//Your RuneScape UserName
Players[0].Pass := '';//Your RuneScape PassWord
Players[0].Nick := ''; //3-4 letters from name
Players[0].Active:= True;
Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;

procedure Debug (s : String);
var debugOn : Boolean;
begin
debugOn := true;
if debugOn then
begin
Writeln ('DEBUG: ' + s);
end;
end;

procedure SetUpSmartStuff;
begin
Smart_Server := 9;
Smart_Members:= False;
Smart_Signed := True;
Smart_SuperDetail := False;
end;

procedure AntiBan;
begin
if not LoggedIn then Exit;
case Random(25) of
0: begin
BoredHuman;
Debug ('Did bored human');
end;
1: begin
RandomRClick;
writeln ('Did random right click');
end;
end;
end;

function MineOre : Boolean;
Begin
if not LoggedIn then exit;
if FindColorTolerance(X, Y, 10000799, MIX1, MIY1, MIX2, MIY2, 12) then
begin
writeln ('We found the color!');
MMouse(X, Y, 5, 5);
if IsUpText('cks') then
begin
writeln ('WaitUpText found!');
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Result := true;
end else writeln ('WaitUpText returned false');
end else
begin
writeln ('We did not find the color 10000799 in MIX1 to MIY2');
result := false;
end;
end;

begin
SetUpSmartStuff;
SetupSRL;
DeclarePlayers;
LogInPlayer;
MakeCompass ('n');
SetAngle (true);
SetRun (true);
if MineOre then writeln ('HELL YEAH');
end.

Gold
09-06-2010, 06:43 PM
procedure Debug (s : String);
var debugOn : Boolean;
begin
debugOn := true;
if debugOn then
begin
Writeln ('DEBUG: ' + s);
end;
end;


So this has something to do with Debug, but I don't know what it does.


function MineOre : Boolean;
Begin
if not LoggedIn then exit;
if FindColorTolerance(X, Y, 10000799, MIX1, MIY1, MIX2, MIY2, 12) then
begin
writeln ('We found the color!');
MMouse(X, Y, 5, 5);
if IsUpText('cks') then
begin
writeln ('WaitUpText found!');
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, False);
Result := true;
end else writeln ('WaitUpText returned false');
end else
begin
writeln ('We did not find the color 10000799 in MIX1 to MIY2');
result := false;
end;
end;



It couldn't find the color, so how can I add more then one color per ore so that it has a less of a chance of not finding?
begin
SetUpSmartStuff;
SetupSRL;
DeclarePlayers;
LogInPlayer;
MakeCompass ('n');
SetAngle (true);
SetRun (true);
if MineOre then writeln ('HELL YEAH');
end.

So, SetAngle (true);
MakeCompass('n')
SetRun (true);

Those are all stand alone and don't need functions?

HyperSecret
09-06-2010, 06:53 PM
procedure Debug (s : String);
var debugOn : Boolean;
begin
debugOn := true;
if debugOn then
begin
Writeln ('DEBUG: ' + s);
end;
end;


oh geez, that made me laugh!

There is no point in having debugOn variable there. You are always setting it to true so the if statement will ALWAYS evaluate to true. Might as well have just writeln('DEBUG: ' + s); in there and that is all.

People usually make the debugOn variable a constant for the user to set and then if they set it to true the user gets to see the debugging of the script.

Gold
09-06-2010, 07:03 PM
Well how do you set it as a constant?

Also, I was trying to make a DTM for a dropping function and for some reason my DTM editor wouldn't save or open dtm's, and if I closed and tried to open it again I got this error

http://img26.imageshack.us/img26/4172/accessvio.png

What's wrong with my Simba?

HyperSecret
09-06-2010, 07:08 PM
http://villavu.com/forum/showthread.php?t=4625

Take a look at this tutorial, it has been around for a long time and is very good. Look through it once and then refer to it as needed.

But you just have to declare a 'const' at the beginning followed by the variables.



program a;

const debugOn = true; //or false depending on the user preference

begin
end.

Cstrike
09-06-2010, 08:18 PM
procedure Debug (s : String);
var debugOn : Boolean;
begin
debugOn := true;
if debugOn then
begin
Writeln ('DEBUG: ' + s);
end;
end;


oh geez, that made me laugh!

There is no point in having debugOn variable there. You are always setting it to true so the if statement will ALWAYS evaluate to true. Might as well have just writeln('DEBUG: ' + s); in there and that is all.

People usually make the debugOn variable a constant for the user to set and then if they set it to true the user gets to see the debugging of the script.

I'll be honest, I did paste it from my default script (where I always leave debug to on). Though I dont understand why you'd be so critical of something that is completely vestigial here. That confuses me.



goldrush655, is all your SRL installed correctly? Im just ruling it out.

Gold
09-06-2010, 09:22 PM
Re-installed, works fine going to make a DTM now

EDIT: After I add the points I still get that error... dammit

Cstrike
09-06-2010, 09:31 PM
Ok can you paste the code? I'm actually going to try it on one of my accounts now.
Where did you plan on finding ore? Varrock? Fally south?

Gold
09-06-2010, 10:12 PM
Varrock, I was just making a DTM of the ore for a dropping function

Gold
09-10-2010, 08:06 PM
So I added:

function FindTin(var X, Y: Integer): Boolean;
var
Coal: Integer;
begin
Tin := DTMFromString('mlwAAAHicY2dgYBAHYmEgVoHS7EAsD8TSUD 4LEPMAsQIQiwCxFBCzAXFmaiqQZMKBcQNGPBgKAPuqAmc=');;
Result := FindDTM(Tin, X, Y, MIX1, MIY1, MIX2, MIY2);
FreeDTM(Tin);
end;


if (FindTin(X, Y)) then
begin
Mouse(X, Y, 3, 3, False);
Wait(200 + Random(100));
ChooseOption('Drop');
end
else
WriteLn('Did not find ore!');

So now, I can get it to find the tin, and drop but I don't know how to make sure it finds the tin and drops it all from the inventory.

So now, I need to: Learn how to check if invfull, (and not drop pick if in inventory)

And I need a better function for finding the ore, it's not working right now.