SRL Archive - OSR Help

Help with mining?


ncore

2012-07-09 12:33:37

Okay, I thought creating a mining script would be simple, but nothing I am doing is working right.

If I want to mine ore, why the heck is this not working:

procedure MineGold;
var x, y: integer;
begin
FindObj(x, y, 'ine', 4637420); then
begin
ClickMouse2(mouse_left);
wait(1500+random(1000));
until (InvFull);
end;

Thanks a lot if you can help. Also, what is the code to click/right click on specific points in your inventory and other objects? thanks

Kasi

2012-07-09 12:40:52

Should be

procedure MineGold;
var
x, y: integer;
begin
Repeat
If FindObj(x, y, 'ine', 4637420, {Tol} 10) then
begin
Mouse(x, y, 5, 5, true);
wait(1500+random(1000));
end;
Until(InvFull);
End;

Anything you see in blue is a comment, you have to add a tolerance to FindObj as it is one of its parameters, also don't use clickmouse. This is a pretty basic procedure, and it should be backed up with antiban and other stuff.

Edit, didnt see the second bit you posted, Look in In inventory.simba, MouseItem(I: Integer; button: Integer) is what your looking for it should be used like so…


MouseItem(1, 1); This will cause a LeftClick at Inventory item 1 {MouseItem(1, mouse_left);}

MouseItem(1, 2); This will cause a RightClick at Inventory item 1 {MouseItem(1, mouse_right);}

MouseItem(1, 3); This will cause a move mouse to Inventory item 1 {MouseItem(1, mouse_move);}


ncore

2012-07-09 12:44:40

From: pur3b100d
Should be

procedure MineGold;
var
x, y: integer;
begin
Repeat
If FindObj(x, y, 'ine', 4637420, {Tol} 10) then
begin
Mouse(x, y, 5, 5, true);
wait(1500+random(1000));
end;
Until(InvFull);
End;

Anything you see in blue is a comment, you have to add a tolerance to FindObj as it is one of its parameters, also don't use clickmouse. This is a pretty basic procedure, and it should be backed up with antiban and other stuff.


Ok thanks. I think it read it, but i am getting an unexpected error at line 0 (?)

so thats weird. and is there a way to click specific points on your inventory or right click and select options?

Thanks

Kasi

2012-07-09 12:50:55

From: ncore
Ok thanks. I think it read it, but i am getting an unexpected error at line 0 (?)


What other code are you including in your scripting window? compiles fine for me
Edit : also look at my first post for the inventory thing

ncore

2012-07-09 13:00:55

From: pur3b100d
What other code are you including in your scripting window? compiles fine for me
Edit : also look at my first post for the inventory thing


This is the full code so far:

program GoldMiner;
{$i srl/srl.simba}
{$i SRL/SRL/misc/smart.simba}

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

with Players[0] do
begin
Name := ''; // Username
Pass := ''; // Password
Active := True; // Set to true if you want to use Player 0
end;
end;

procedure Antiban;
begin
if(not(LoggedIn))then Exit;
begin
case Random(100) of
10: RandomRClick;
30: PickUpMouse;
50: RandomMovement;
70: BoredHuman;
89: ExamineInv;
end;
end;
end;

procedure MineGold;
var
x, y: integer;
begin
Repeat
If FindObj(x, y, 'ine', 4637420, {Tol} 10) then
begin
Mouse(x, y, 5, 5, true);
wait(1500+random(1000));
end;
Until(InvFull);
End;

This is my first time scripting, I have no idea if I am doing anything right, and it is hard to look at tutorials for exactly what I am planning on doing.

And thank you for posting the clicking code, but is there any way to click on a set specific points on the screen? Like, if I wanted to go into my equipped items and use a teleportation device, how would I go about doing that?

EtherFreak

2012-07-09 13:08:28

Another issue is that you will keep clicking while mining unless you mine an ore in 1.5-2.5 seconds. Also, you need to detect when you clicked, and if someone else clicked and stole the ore from you.

Try adding this:
procedure MineGold;
var
x, y, c, k: integer;
begin
Repeat
c:=invcount+1;//plan for having one more ore in inv
If FindObj(x, y, 'ine', 4637420, {Tol} 10) then
begin
Mouse(x, y, 5, 5, true);
wait(1500+random(1000));
k:=0;
if (IsChatBoxTextBetween('swing',clblack,8,8)) then
repeat
inc(k);
wait(1000)
if k=10 then//this will asume you lost your ore to someone else, or you may have not clicked right
exit;
until invcount=c //this will tell you if you have gained an item in your inv (note you may have gotten a spin ticked or gem too!)
end;
Until(InvFull);
End;

Kasi

2012-07-09 13:09:56

From: ncore


This is my first time scripting, I have no idea if I am doing anything right, and it is hard to look at tutorials for exactly what I am planning on doing.

And thank you for posting the clicking code, but is there any way to click on a set specific points on the screen? Like, if I wanted to go into my equipped items and use a teleportation device, how would I go about doing that?


yes looking through the code, it looks fine, you need a "main loop", this normally is right at the bottom of your script and is like


Begin
// in here goes the order of what you want to do e.g...
SetupSRL; // setups all the default stuff.
DeclarePlayers; // Declares all the players ready for login

LoginPlayer; // login using the info your provided in DeclarePlayes;
MineGold; // goes to your function and does what your function says.
End. // notice the fullstop instead of semicolon, this ends your program
// it has no other code to execute.

also one other small thing, when your including smart you should always include it before SRL…like so


{$i SRL/SRL/misc/smart.simba}
{$i srl/srl.simba}
and not

{$i srl/srl.simba}
{$i SRL/SRL/misc/smart.simba}

Amended script so far…


program GoldMiner;
{$i SRL/SRL/misc/smart.simba}
{$i srl/srl.simba}


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

with Players[0] do
begin
Name := ''; // Username
Pass := ''; // Password
Active := True; // Set to true if you want to use Player 0
end;
end;

procedure Antiban;
begin
if(not(LoggedIn))then Exit;
begin
case Random(100) of
10: RandomRClick;
30: PickUpMouse;
50: RandomMovement;
70: BoredHuman;
89: ExamineInv;
end;
end;
end;

procedure MineGold;
var
x, y: integer;
begin
Repeat
If FindObj(x, y, 'ine', 4637420, {Tol} 10) then
begin
Mouse(x, y, 5, 5, true);
wait(1500+random(1000));
Antiban;
end;
Until(InvFull);
End;

Begin
SetupSRL;
DeclarePlayers;
LoginPlayer;
MineGold;
End.

ncore

2012-07-09 13:19:51

Thank you so much! You are a godsent lol!

It mined fine, but I will have to tweak the timing a bit to get it to mine ores properly without jumping to a new one.

And is there a way to make the game screen stop closing and reopening if i start the script with the screen already open? thanks a lot!

Kasi

2012-07-09 13:27:01

From: ncore
Thank you so much! You are a godsent lol!

It mined fine, but I will have to tweak the timing a bit to get it to mine ores properly without jumping to a new one.

And is there a way to make the game screen stop closing and reopening if i start the script with the screen already open? thanks a lot!


Yes, im guessing your talking about the smart window? it closes and opens because it's loading a different server each time your starting the script so if you keep it as the same server it shouldn't close smart everytime your restart to do this you have to add the following code to your main loop before "SetupSRL"

    
SMART_Server := 83; // change to whatever server you want but make sure its not random.
SMART_Members := True; // turn to false for non members
SMART_Signed := True;
SMART_SuperDetail := False;

Edit: also to not click other ore whilst mining your current one look at animation.simba ;)

ncore

2012-07-09 13:36:44

Thanks, so i can just paste that in above the setup?

And what I meant by clicking was not just in the inventory, but everywhere.

Like if I wanted to click a door. That, plus specifically clicking a teleportation confirmation in the clan vexillium.

I got this far, but I am not sure what to do from here:

procedure ToMine;
GameTab(Tab_Equip);
if WearingItem(5) then
begin
MouseEquippedItem('weapon', MOUSE_RIGHT);
WaitOption('eleport', 1000);

Kasi

2012-07-09 13:52:35

From: ncore
Thanks, so i can just paste that in above the setup?

your main loop should look like this

Begin
SMART_Server := 83;
SMART_Members := True;
SMART_Signed := True;
SMART_SuperDetail := False;
SetupSRL;
DeclarePlayers;
LoginPlayer;
MineGold;
End.

From: ncore

And what I meant by clicking was not just in the inventory, but everywhere.


if its in area's that don't change position then you can use Mouse() with
set coords that dont change, keeping in mind to add randomness


Mouse(87, 42, 5, 5, True);
Mouse({X-Coord}, {Y-Coord}, {+ X Randomness}, {+ Y Randomness}, {ClickType, (True), (False)});

From: ncore

Like if I wanted to click a door. That, plus specifically clicking a teleportation confirmation in the clan vexillium.


if you were to search for a door, i would use TPA Color finding to find the coord of the door and then click it using mouse().

From: ncore

I got this far, but I am not sure what to do from here:
procedure ToMine;
GameTab(Tab_Equip);
if WearingItem(5) then
begin
MouseEquippedItem('weapon', MOUSE_RIGHT);
WaitOption('eleport', 1000);


For every "begin" in a script there should be a "end", for every procedure there should be at least one begin and that begin should come straight after your Procedure line providing you dont have to declare any variables. with that knowledge your procedure should be like so…


procedure ToMine;
Begin
GameTab(Tab_Equip);
If WearingItem(5) Then
Begin
MouseEquippedItem('weapon', MOUSE_RIGHT);
WaitOption('eleport', 1000);
End;
End;

ncore

2012-07-09 14:39:02

Ok I think i fixed it. Sorry for the long response, I had to install .net framework to put this together:

procedure WalkToMine;
begin
GameTab(Tab_Equip);
if WearingItem(5) then
begin
MouseEquippedItem('weapon', MOUSE_RIGHT);
WaitOption('eleport', 1000);
begin
Mouse(87, 42, 5, 5, True);
Mouse(305, 537, 4, 2, True);
begin
SPS_Setup(RUNESCAPE_SURFACE,['9_8','8_8']);
ToMine := [Point(3737, 3520), Point(3710, 3522), Point(3683, 3511), Point(3669, 3498), Point(3648, 3484), Point(3627, 3479), Point(3605, 3478), Point(3574, 3483), Point(3570, 3492), Point(3569, 3501)];
SPS_WalkPath(ToMine);
end;
end;
end;
end;



does that look okay?

Edit: I am getting identifier expected error

Kasi

2012-07-10 08:40:18

ah, you have to include SPS.simba, do that under the SRL include right at the top, (red Writing) also where are you setting the variable ToMine, that could cause another unidentified error, one last thing being, if your script is running back and forth to the mine you have to keep in mind that you only want to load the maps once, with SPS_Setup i would put it close to your main loop somewhere after SetupSRL making sure it is only called once

ncore

2012-07-10 08:59:33

Thanks, I was able to find out that it wasn't working because I didn't input a MyPath:TPointArray; under Var

I tested out my script, and the walking to the mine is very smooth. However, getting into the mine isn't. I have not been able to open the blasted door to get in :(