SRL Archive - RS3 Help

Mining Script minor Issue


Kaladin

2014-01-26 10:54:53


program VarrockMiner;
{$DEFINE SMART}
{$I SRL-6/SRL.Simba}
{$i sps/lib/sps-rs3.simba}

{-------------------------------*********************************************-------------------------------}
{-------------------------------*********************************************-------------------------------}
{-------------------------------*********************************************-------------------------------}
{-============================== Varrock Iron Mine and Bank ==============================-}
{-============================== By Agoson ==============================-}
{-============================== Version 1 ==============================-}
{-------------------------------*********************************************-------------------------------}
{-------------------------------*********************************************-------------------------------}
{-------------------------------*********************************************-------------------------------}


//INSTRUCTIONS -------------------------------------------------------------------------------\\
//Enter your nick, file and amount of ore here, start in V-east bank or by the mine. Enjoy :)
const
nick:= 'agoWin';
file:= 'default';
desiredLoads:= 120;
//--------------------------------------------------------------------------------------------\\
var
ToBank: tpointarray;
ToMine: tpointarray;
location: string;
foundore: boolean;
loads, xpPh, xP, oreXP, orePh, oresMined, oresBanked, total, rTemp, inv, invTemp, breakTime, breakIntervals: integer; //Declaring multiple vars of same type on same line


// Procedure that sets up SRL, SPS, the player and relevant vars etc.
procedure setup;

begin

total:= 0;
smartEnableDrawing := true;
setupSRL;
Players.Setup([nick], file);
CurrentPlayer := 0;
ToBank := [Point(505, 559), Point(508, 559), Point(510, 559), Point(512, 555), Point(514, 554), Point(515, 547), Point(517, 544), Point(519, 541), Point(520, 538), Point(522, 535), Point(524, 534), Point(529, 525), Point(529, 519), Point(529, 518), Point(530, 513), Point(530, 507), Point(530, 502), Point(531, 495), Point(530, 488), Point(528, 483), Point(528, 478), Point(529, 471), Point(528, 466), Point(528, 460), Point(528, 455), Point(529, 452), Point(530, 447), Point(530, 442), Point(530, 433), Point(528, 428), Point(530, 412), Point(527, 407), Point(522, 398), Point(517, 391), Point(515, 390), Point(514, 381), Point(507, 378), Point(508, 371), Point(509, 360), Point(507, 348), Point(504, 340), Point(500, 333), Point(493, 328), Point(488, 320), Point(480, 317), Point(475, 315), Point(461, 310), Point(449, 311), Point(435, 309), Point(425, 309), Point(420, 314), Point(409, 313), Point(404, 313), Point(399, 312), Point(389, 310), Point(381, 310), Point(374, 317), Point(373, 329), Point(374, 333), Point(374, 335), Point(376, 341), Point(377, 345), Point(375, 347), Point(372, 350)];
ToMine := [Point(369, 349), Point(369, 345), Point(369, 342), Point(369, 337), Point(369, 331), Point(370, 325), Point(370, 322), Point(370, 319), Point(370, 316), Point(373, 314), Point(378, 311), Point(381, 312), Point(387, 312), Point(390, 312), Point(393, 312), Point(397, 312), Point(403, 312), Point(409, 311), Point(413, 313), Point(418, 313), Point(422, 309), Point(425, 310), Point(431, 312), Point(436, 310), Point(440, 310), Point(445, 308), Point(449, 310), Point(453, 310), Point(457, 310), Point(462, 310), Point(466, 311), Point(468, 311), Point(474, 311), Point(478, 311), Point(482, 311), Point(487, 311), Point(490, 316), Point(494, 318), Point(496, 324), Point(501, 330), Point(504, 334), Point(504, 338), Point(511, 345), Point(513, 350), Point(513, 357), Point(508, 357), Point(506, 364), Point(509, 374), Point(509, 375), Point(515, 381), Point(515, 389), Point(522, 390), Point(520, 396), Point(524, 405), Point(527, 418), Point(528, 420), Point(529, 434), Point(528, 437), Point(525, 441), Point(525, 445), Point(525, 448), Point(525, 450), Point(528, 457), Point(528, 463), Point(528, 463), Point(527, 465), Point(527, 468), Point(527, 472), Point(527, 473), Point(529, 473), Point(529, 477), Point(529, 482), Point(529, 485), Point(530, 487), Point(531, 492), Point(532, 499), Point(533, 503), Point(533, 507), Point(533, 513), Point(530, 517), Point(527, 522), Point(521, 528), Point(519, 532), Point(518, 536), Point(515, 545), Point(514, 550), Point(511, 555), Point(510, 556), Point(505, 560), Point(505, 560)];
sps.setup('SPSVarrockIron', RUNESCAPE_SURFACE, 4, 600.0, 0.40);
wait(1000 + random(2000));
players[currentPlayer].login();
mainscreen.setAngle(MS_ANGLE_HIGH);
oreXP:= 27;
end;

// Procedure courtesy of Coh3n, checks for spinticket etc
procedure Find_Randoms();
var
p: TPoint;
begin
if (findSpinTicket(p)) then
begin
mouse(p, MOUSE_LEFT);
end;
end;


// Also derived from coh3ns script, an anti ban that randomly trigges each time an ore is mined
procedure minorRandomAntiBan;
begin
case Random(40) of
1: RandomRClickItem();
2: SleepAndMoveMouse(200 + Random(50));
3: ;
4: PickUpMouse;
5: ;
6: ;
7: RandomCompass(0, 90 + random(90), false);
9: ;
10: PickUpMouse;
11:;
12:;
13:MouseOffClient(Random(5));
14:;
15:MouseMovingObject();
end;
end;


// The mayor is responsible for this, searches for TPAs then moves to each one individually
function findOre: boolean;

var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
if not isLoggedIn then
exit;
if tabBackpack.count < 28 then
// color // tol //CTS, hue, sat from ACA
if findColorsSpiralTolerance(x, y, TPA, 2504288, mainScreen.getBounds(), 10, colorSetting(2, 0.08, 0.20)) then

if (Length(TPA) < 1) then // if no matching TPoints are found, exit
exit;

ATPA := TPA.toATPA(30, 30); // split our TPA into boxes of 30 x 30 pixels and put into an ATPA
ATPA.sortFromMidPoint(mainscreen.playerPoint); // sort the array from player, so closest TPA to player is first in array

for i := 0 to high(ATPA) do
begin // move move to each TPA one at a time, until we get a match
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Mine Iron ore rocks'], 200) then
begin
GetMousePos(x, y);
Mouse(point(x, y).rand(1), MOUSE_LEFT, MOUSE_HUMAN);
wait(200 + random(600));
if tabBackpack.waitForShift(4500) = true then // Waitfor inv to inc by 1
oresMined := oresMined + 1; // Increase the oresmined variable by 1
writeln(oresMined);
minorRandomAntiBan; // Call antiban
exit(true);
end;
end;
end;

// Credit to Ashaman script for the basis of this prog report
Procedure Progress;
begin
XP:= oresMined*oreXP;
xpPh:= Round(XP * (3600.0 / (GetTimeRunning / 1000.0)));
orePh:= Round((OresMined * (3600.0 / (GetTimeRunning / 1000.0))));
Writeln('~~~~~~~~~~~~ Varrock Iron Mine and Bank - Version 1 Public Release ~~~~~~~~~~~~') ;
Writeln('Time Running: ' + ToStr(TimeRunning));
Writeln('Ores Banked: ' + ToStr(oresMined));
Writeln('Ores Per Hour: ' + ToStr(orePh));
Writeln('Loads Done: ' + ToStr(loads));
Writeln('Experience Earned: ' + IntToStr(xP));
Writeln('Experience Per Hour: ' + ToStr(xpPh));
Writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
end;

// Procedure to print progress report and end script
procedure endScript;
begin
wait(randomRange(4000, 3000));
players[currentPlayer].exitToLobby();
Progress;
writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@Ending Script@~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
writeln('Thank you for using Varrock Bank and Miner, all credits to the SRL community');
terminateScript;
end;

// Function to bank
function bank : boolean;
begin
if bankscreen.open(BANK_BOOTH) then
begin
oresMined := oresMined + tabBackpack.count;
loads := loads + 1;
bankScreen.deposit([1..28]);
bankscreen.close();
Progress;
exit(true);
end else
if bankscreen.open(BANK_NPC_BLUE) then
begin
oresMined := oresMined + tabBackpack.count;
loads := loads + 1;
bankScreen.deposit([2..28]);
bankscreen.close();
Progress;
exit(true);
end else
exit(false);
end;

// Function to attempt to bank or find MM symbol if banking not possible
function tryBank : boolean;
var bs: TPoint;
begin
if (tabBackpack.count = 0) then
begin
writeln('Didnt bank because inventory is empty');
exit(false);
end else
if minimap.findSymbol(bs, MM_SYMBOL_BANK, minimap.getBounds()) then
begin
if bank then
exit(true);
end else
if tabBackpack.count > 0 then
begin
mouse(bs, MOUSE_LEFT, MOUSE_HUMAN);
bank;
end else
exit(false);
end;

// Function to walk to bank or mine depending on location
function tryWalk : boolean;
begin
if tabBackpack.count = 28 then
begin
if sps.walkPath(toBank) then
writeln('Walking path to the bank');
exit(true);
end else
if tabBackpack.count = 0 then
begin
if sps.walkPath(toMine) then
writeln('Walking path to the mine');
exit(true);
end else
exit(false);
end;

// Function to mine if possible
function tryMine(): boolean;
var
t := getSystemTime() + 60000; // maximum one minute (can change to whatever you want) used as a failsafe in case something goes wrong
begin
while ((not result) and (getSystemTime() < t)) do
begin
findOre();
result := (tabBackpack.count() = 28);
wait(100 + random(100));
end;
end;

// Main loop
procedure mainLoop;
begin
if not isLoggedIn then
begin
exit;
end else
if tabBackpack.count = 28 then
begin
tryBank;
tryWalk;
end else
tryWalk;
tryMine;
end;

begin
setup;
Find_Randoms;
repeat
mainLoop;
until loads = desiredLoads;
Progress;
TerminateScript;
end.

This constantly and randomly (as far as I can see) does this: – TRSGameTabs.openTab(2)
—- Opening tab via gametab navigation bar
– TRSGameTabs.openTab(2): result = False
– chooseOption._select(

Which when banking seems to cause issues, as well as slowing the whole script down (Random waits when it shouldn't be waiting to my eyes.

Any idea?

Thanks.

EDIT: Definitely related to openTab, is that part of an SRL function I'm using perhaps?
It clicks on the inventory while the bank is open, i BELIEVE it is trying to click the Equipped_Inv tab, for what reason? No clue :D

The Mayor

2014-01-26 14:39:58

@agoson




program VarrockMiner;
{$DEFINE SMART}
{$I SRL-6/SRL.Simba}
{$i sps/lib/sps-rs3.simba}

{-------------------------------*********************************************-------------------------------}
{-------------------------------*********************************************-------------------------------}
{-------------------------------*********************************************-------------------------------}
{-============================== Varrock Iron Mine and Bank ==============================-}
{-============================== By Agoson ==============================-}
{-============================== Version 1 ==============================-}
{-------------------------------*********************************************-------------------------------}
{-------------------------------*********************************************-------------------------------}
{-------------------------------*********************************************-------------------------------}


//INSTRUCTIONS -------------------------------------------------------------------------------\\
//Enter your nick, file and amount of ore here, start in V-east bank or by the mine. Enjoy :)
const
nick:= 'agoWin';
file:= 'default';
desiredLoads:= 120;
//--------------------------------------------------------------------------------------------\\
var
ToBank: tpointarray;
ToMine: tpointarray; // same line here too
location: string;
foundore: boolean;
loads, xpPh, xP, oreXP, orePh, oresMined, oresBanked, total, rTemp, inv, invTemp, breakTime, breakIntervals: integer; //Declaring multiple vars of same type on same line


// Procedure that sets up SRL, SPS, the player and relevant vars etc.
procedure setup;

begin // indent (tab) between begin and end
total:= 0;
smartEnableDrawing := true;
setupSRL;
Players.Setup([nick], file);
CurrentPlayer := 0;
ToBank := [Point(505, 559), Point(508, 559), Point(510, 559), Point(512, 555), Point(514, 554), Point(515, 547), Point(517, 544), Point(519, 541), Point(520, 538), Point(522, 535), Point(524, 534), Point(529, 525), Point(529, 519), Point(529, 518), Point(530, 513), Point(530, 507), Point(530, 502), Point(531, 495), Point(530, 488), Point(528, 483), Point(528, 478), Point(529, 471), Point(528, 466), Point(528, 460), Point(528, 455), Point(529, 452), Point(530, 447), Point(530, 442), Point(530, 433), Point(528, 428), Point(530, 412), Point(527, 407), Point(522, 398), Point(517, 391), Point(515, 390), Point(514, 381), Point(507, 378), Point(508, 371), Point(509, 360), Point(507, 348), Point(504, 340), Point(500, 333), Point(493, 328), Point(488, 320), Point(480, 317), Point(475, 315), Point(461, 310), Point(449, 311), Point(435, 309), Point(425, 309), Point(420, 314), Point(409, 313), Point(404, 313), Point(399, 312), Point(389, 310), Point(381, 310), Point(374, 317), Point(373, 329), Point(374, 333), Point(374, 335), Point(376, 341), Point(377, 345), Point(375, 347), Point(372, 350)];
ToMine := [Point(369, 349), Point(369, 345), Point(369, 342), Point(369, 337), Point(369, 331), Point(370, 325), Point(370, 322), Point(370, 319), Point(370, 316), Point(373, 314), Point(378, 311), Point(381, 312), Point(387, 312), Point(390, 312), Point(393, 312), Point(397, 312), Point(403, 312), Point(409, 311), Point(413, 313), Point(418, 313), Point(422, 309), Point(425, 310), Point(431, 312), Point(436, 310), Point(440, 310), Point(445, 308), Point(449, 310), Point(453, 310), Point(457, 310), Point(462, 310), Point(466, 311), Point(468, 311), Point(474, 311), Point(478, 311), Point(482, 311), Point(487, 311), Point(490, 316), Point(494, 318), Point(496, 324), Point(501, 330), Point(504, 334), Point(504, 338), Point(511, 345), Point(513, 350), Point(513, 357), Point(508, 357), Point(506, 364), Point(509, 374), Point(509, 375), Point(515, 381), Point(515, 389), Point(522, 390), Point(520, 396), Point(524, 405), Point(527, 418), Point(528, 420), Point(529, 434), Point(528, 437), Point(525, 441), Point(525, 445), Point(525, 448), Point(525, 450), Point(528, 457), Point(528, 463), Point(528, 463), Point(527, 465), Point(527, 468), Point(527, 472), Point(527, 473), Point(529, 473), Point(529, 477), Point(529, 482), Point(529, 485), Point(530, 487), Point(531, 492), Point(532, 499), Point(533, 503), Point(533, 507), Point(533, 513), Point(530, 517), Point(527, 522), Point(521, 528), Point(519, 532), Point(518, 536), Point(515, 545), Point(514, 550), Point(511, 555), Point(510, 556), Point(505, 560), Point(505, 560)];
sps.setup('SPSVarrockIron', RUNESCAPE_SURFACE, 4, 600.0, 0.40);
wait(1000 + random(2000)); // no need for this
players[currentPlayer].login();
mainscreen.setAngle(MS_ANGLE_HIGH);
oreXP:= 27;
end;

// Procedure courtesy of Coh3n, checks for spinticket etc
procedure Find_Randoms();
var
p: TPoint;
begin
if (findSpinTicket(p)) then
begin
mouse(p, MOUSE_LEFT); // no need for begin and end here...only 1 statement after then
end;
end;


// Also derived from coh3ns script, an anti ban that randomly trigges each time an ore is mined
procedure minorRandomAntiBan;
begin
case Random(40) of
1: RandomRClickItem();
2: SleepAndMoveMouse(200 + Random(50));
3: ; // no need for blanks, just delete the whole line, taking up space
4: PickUpMouse;
5: ;
6: ;
7: RandomCompass(0, 90 + random(90), false);
9: ;
10: PickUpMouse;
11:;
12:;
13:MouseOffClient(Random(5));
14:;
15:MouseMovingObject();
end;
end;


// The mayor is responsible for this, searches for TPAs then moves to each one individually
function findOre: boolean;

var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
if not isLoggedIn then
exit;
if tabBackpack.count < 28 then
// color // tol //CTS, hue, sat from ACA
if findColorsSpiralTolerance(x, y, TPA, 2504288, mainScreen.getBounds(), 10, colorSetting(2, 0.08, 0.20)) then

if (Length(TPA) < 1) then // if no matching TPoints are found, exit
exit;

ATPA := TPA.toATPA(30, 30); // split our TPA into boxes of 30 x 30 pixels and put into an ATPA
ATPA.sortFromMidPoint(mainscreen.playerPoint); // sort the array from player, so closest TPA to player is first in array

for i := 0 to high(ATPA) do
begin // move move to each TPA one at a time, until we get a match
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Mine Iron ore rocks'], 200) then
begin
GetMousePos(x, y);
Mouse(point(x, y).rand(1), MOUSE_LEFT, MOUSE_HUMAN);
wait(200 + random(600));
if tabBackpack.waitForShift(4500) = true then // no need for '= true' it already does that
oresMined := oresMined + 1; // or you can go inc(oresMined)
writeln(oresMined);
minorRandomAntiBan;
exit(true);
end;
end;
end;

// Credit to Ashaman script for the basis of this prog report
Procedure Progress;
begin
XP:= oresMined*oreXP;
xpPh:= Round(XP * (3600.0 / (GetTimeRunning / 1000.0)));
orePh:= Round((OresMined * (3600.0 / (GetTimeRunning / 1000.0))));
Writeln('~~~~~~~~~~~~ Varrock Iron Mine and Bank - Version 1 Public Release ~~~~~~~~~~~~') ;
Writeln('Time Running: ' + ToStr(TimeRunning));
Writeln('Ores Banked: ' + ToStr(oresMined));
Writeln('Ores Per Hour: ' + ToStr(orePh));
Writeln('Loads Done: ' + ToStr(loads));
Writeln('Experience Earned: ' + IntToStr(xP));
Writeln('Experience Per Hour: ' + ToStr(xpPh));
Writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
end;

// Procedure to print progress report and end script
procedure endScript;
begin
wait(randomRange(4000, 3000));
players[currentPlayer].exitToLobby();
Progress;
writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@Ending Script@~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
writeln('Thank you for using Varrock Bank and Miner, all credits to the SRL community');
terminateScript;
end;

// Function to bank
function bank : boolean;
begin
if bankscreen.open(BANK_BOOTH) then
begin // indent after begin // this is your problem, it's trying to count backpack items when the bankscreen is open
oresMined := oresMined + tabBackpack.count; // hmm, why even increase oresMined here, dont you do it in findOre?
loads := loads + 1;
bankScreen.deposit([1..28]); // could just use quickDeposit if depositing all, faster.
bankscreen.close();
Progress;
exit(true);
end else
if bankscreen.open(BANK_NPC_BLUE) then
begin
oresMined := oresMined + tabBackpack.count; // get rid of this too
loads := loads + 1;
bankScreen.deposit([2..28]); // why is this 2..28 when above is 1..28?
bankscreen.close();
Progress;
exit(true);
end else
exit(false);
end;

// Function to attempt to bank or find MM symbol if banking not possible
function tryBank : boolean;
var bs: TPoint;
begin
if (tabBackpack.count = 0) then
begin
writeln('Didnt bank because inventory is empty');
exit(false); //indent here pl0x
end else
if minimap.findSymbol(bs, MM_SYMBOL_BANK, minimap.getBounds()) then
begin
if bank then // indent
exit(true); // and again here (x2)
end else
if tabBackpack.count > 0 then
begin
mouse(bs, MOUSE_LEFT, MOUSE_HUMAN);
bank;
end else // undo indent
exit(false);
end;

// Function to walk to bank or mine depending on location
function tryWalk : boolean;
begin
if tabBackpack.count = 28 then // fix all then indents
begin // what if pack count is say ... 17? what will it do?
if sps.walkPath(toBank) then // maybe if tabBackpack.count < 28 then mine
writeln('Walking path to the bank');
exit(true);
end else
if tabBackpack.count = 0 then
begin
if sps.walkPath(toMine) then
writeln('Walking path to the mine');
exit(true);
end else
exit(false);
end;

// Function to mine if possible
function tryMine(): boolean;
var
t := getSystemTime() + 60000; // maximum one minute (can change to whatever you want) used as a failsafe in case something goes wrong
begin
while ((not result) and (getSystemTime() < t)) do
begin
findOre();
result := (tabBackpack.count() = 28);
wait(100 + random(100));
end;
end;

// Main loop
procedure mainLoop;
begin
if not isLoggedIn then // indents
begin
exit; // no need for begin and end here
end else
if tabBackpack.count = 28 then
begin
tryBank;
tryWalk;
end else
tryWalk;
tryMine;
end;

begin
setup; // indents
Find_Randoms;
repeat
mainLoop;
until loads = desiredLoads;
Progress;
TerminateScript;
end.

Kaladin

2014-01-26 14:49:07

From: The Mayor
@agoson
…


Thanks alot man, your a very helpful person :D

Will take a look when I come home later

EDIT: Can't +rep you lool, works like a dream and thanks for pointing out the conventions to me, it was messy and I did plan to read them in the near future xD