SRL Archive - First Scripts

First Script - Portable Forge


SlipperyPickle

2015-01-01 16:50:59

Hi,

I would like to present my first script. The goal is to create a script that supports all portables on all the main places. Just posting this to get some feedback, to improve my scripting skills.

The script doesn't have any antiban as of jet. Will be implemented.

Thanks in advance!

program scriptTemplate;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'zezima';
password := 'botting24/7';
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

procedure useBank();
var
arP: TPointArray;
ATPA: T2DPointArray;
x, y, i: integer;

begin
if not IsLoggedIn then
Exit;

if bankScreen.isOpen(BANK_CHEST_LUMBRIDGE) then
begin
writeLn('Bank already open.');
exit;
end;
bankScreen.open(BANK_CHEST_LUMBRIDGE);
Wait(gaussRangeInt(500, 1300));
exit;
end;

procedure findingForge();

var
arP, arAP: TPointArray;
x, y, i, forgeWaitCount: integer;
bushTPA: TPointArray;
ATPA: T2DPointArray;
TPA: TPointArray;
waitTimer: TTimeMarker;
b: Boolean;

begin
waitTimer.reset();
waitTimer.start();

if (bankScreen.isOpen(BANK_CHEST_LUMBRIDGE)) then
begin
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
repeat
begin
mainscreen.findObject(x, y, 1663163, 6, colorSetting(2, 0.36, 1.44), mainscreen.playerPoint, 15, 15, 15, ['orge'], 3);
WriteLn('Looking for forge:' + BoolToStr(b));
Wait(gaussRangeInt(1000, 2000));
end;
if (Length(TPA) < 2) then
begin

if isMouseOverText(['orge'], 200) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;
until (productionScreen.isOpen) or (waitTimer.getTime() > 200000);
end;
if (waitTimer.GetTime() > 200000) then
begin
WriteLn('couldn''t find portable, terminating script');
TerminateScript();
end;
end;

procedure usingForge();
var
i: integer;
begin
Wait(gaussRangeInt(700, 1100));
if (productionScreen.isOpen) then
begin
productionScreen.clickStart(true);
repeat
begin
wait(gaussRangeInt(1000, 1500));
WriteLn('waiting');
end;
until (progressScreen.isOpen = false);
wait(gaussRangeInt(500, 1000));
end;
findingForge;
end;

{Main Loop}
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();
if not isLoggedIn() then
begin
players[currentPlayer].login();
exitTreasure();
mainScreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_WEST);
end;
repeat
useBank();
findingForge();
usingForge();
until(false);
end.

SlipperyPickle

2015-01-02 06:44:26

Bump for feedback

The Mayor

2015-01-02 13:44:29

Nice work ;)

From: Suikerwafel
Bump for feedback



program scriptTemplate;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'zezima';
password := 'botting24/7';
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

procedure useBank();
var
arP: TPointArray; // You don't use any of these variables?
ATPA: T2DPointArray;
x, y, i: integer;

begin
if not IsLoggedIn then
Exit;
// The parameter for isOpen is wait time: isOpen(waitTime), isOpen(5000)
if bankScreen.isOpen(BANK_CHEST_LUMBRIDGE) then
begin
writeLn('Bank already open.');
exit;
end; // You can actually remove the block above
bankScreen.open(BANK_CHEST_LUMBRIDGE);// as bs.open() calls bs.isOpen() before looking for the bank
Wait(gaussRangeInt(500, 1300));
exit; // Why exit when you are already at the end of the procedure? You will exit anyway.
end;

procedure findingForge();

var
arP, arAP: TPointArray;
x, y, i, forgeWaitCount: integer;
bushTPA: TPointArray; // lol, spaceblow's redberry gatherer :p ?
ATPA: T2DPointArray;
TPA: TPointArray;
waitTimer: TTimeMarker;
b: Boolean;

begin // everything should be tabbed (indented )
waitTimer.reset(); // no need to reset it, since you declared it locally here (it will be 0 each time you start this procedure)
waitTimer.start();

if (bankScreen.isOpen(BANK_CHEST_LUMBRIDGE)) then // Again, the CHEST_LUMBRIDGE is actually an integer constant (10)
begin // so this is just writing isOpen(10);
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
repeat
begin // Don't need this begin..end. They should only follow a conditional if..then.. etc (it's always gonna run so no need for it)
mainscreen.findObject(x, y, 1663163, 6, colorSetting(2, 0.36, 1.44), mainscreen.playerPoint, 15, 15, 15, ['orge'], 3);
WriteLn('Looking for forge:' + BoolToStr(b)); // What is this bool for? It will always return false
Wait(gaussRangeInt(1000, 2000));
end;
if (Length(TPA) < 2) then // Your ms.findObject code above doesn't output any TPAs?
begin // Fidd object also moves/clicks the mouse, so this block is redundant

if isMouseOverText(['orge'], 200) then
begin
fastClick(MOUSE_LEFT);
break;
end;
end;
until (productionScreen.isOpen) or (waitTimer.getTime() > 200000); // You could isOpen(5000) or something
end; // to wait for up to 5sec after clicking it
if (waitTimer.GetTime() > 200000) then
begin
WriteLn('couldn''t find portable, terminating script');
TerminateScript();
end;
end;

procedure usingForge();
var
i: integer; // You don't use this
begin
Wait(gaussRangeInt(700, 1100));
if (productionScreen.isOpen) then
begin
productionScreen.clickStart(true);
repeat
begin
wait(gaussRangeInt(1000, 1500)); // messy indentation, hard to read
WriteLn('waiting');
end;
until (progressScreen.isOpen = false); // could also (not progressScreen.isOpen())
wait(gaussRangeInt(500, 1000));
end;
findingForge;
end;

{Main Loop}
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();
if not isLoggedIn() then // I'd put this block inside the repeat loop below
begin // so it will check if you're logged out each loop
players[currentPlayer].login();
exitTreasure();
mainScreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_WEST);
end;
repeat
useBank();
findingForge();
usingForge();
until(false);
end.

SlipperyPickle

2015-01-02 13:59:08

Thank you for the feedback! Nice you took the effort to help me! :) I have to admit the code is a bit messy. And I used many scripts as example, that's the reason for some of the useless variables :p Will use your feedback and report back ;)

Thanks!

Taric

2015-01-05 17:02:35

From one noob working with portables to another, good job!

Idk what the mo' betterer simba scripters use for failsafes, but one of the ways I make sure my script opens up the bank and selects the proper preset is by doing:
repeat
bankScreen.open(BANK_CHEST_SHANTAY);
wait(randomRange(600, 800));
until(bankScreen.isOpen());
repeat
if (bankPreset > 1) then //I let mah users choose which bank preset they wanna use.
begin
bankScreen.clickButton(BANK_BUTTON_PRESET_2);
end else
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
wait(randomRange(600, 800));
until not(bankScreen.isOpen());

Also, I laughed at the zezima pun. :p

SlipperyPickle

2015-01-05 17:05:53

From: pizzapants
From one noob working with portables to another, good job!

Idk what the mo' betterer simba scripters use for failsafes, but one of the ways I make sure my script opens up the bank and selects the proper preset is by doing:
repeat
bankScreen.open(BANK_CHEST_SHANTAY);
wait(randomRange(600, 800));
until(bankScreen.isOpen());
repeat
if (bankPreset > 1) then //I let mah users choose which bank preset they wanna use.
begin
bankScreen.clickButton(BANK_BUTTON_PRESET_2);
end else
bankScreen.clickButton(BANK_BUTTON_PRESET_1);
wait(randomRange(600, 800));
until not(bankScreen.isOpen());

Also, I laughed at the zezima pun. :p


Yeah, stupid, accidentally left my username and pass in the script ;)

But thanks for the feedback! :D

SlipperyPickle

2015-01-19 11:24:57

Update
Updated my script. It now runs much better.

ToDo:
- Fix the problem where it sometimes banks twice;
- Fancy paint;
- AIO portable script;
- More banking spots.

program scriptTemplate;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

const
bankPreset := 1;
WhichOres := 5;
// 1 = Bronze
// 2 = Blurite
// 3 = Iron
// 4 = Silver
// 5 = Steel
// 6 = Gold
// 7 = Perfect gold
// 8 = Mith
// 9 = Addy
// 15 = Rune


procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := '';
password := '';
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

procedure antiBan();
var
i: Integer;

begin
if not isLoggedIn() then
exit;

if i < 41 then
begin
case i of
0..9: mouseMovingObject();
10..20: sleepAndMoveMouse(500);
21..30: sleepAndMoveMouse(randomRange(100, 900));
31..39: begin
mouseOffClient(random(4));
wait(randomRange(1000, 5000));
end;
40..41: begin
mouseOffClient(random(4));
wait(randomRange(5000, 10000));
end;
end;
end;
end;

procedure useBank();
begin
if not IsLoggedIn then
Exit;

if bankScreen.isOpen then
exit;

bankScreen.open(BANK_CHEST_LUMBRIDGE);
Wait(gaussRangeInt(700, 1100));
end;

procedure usePreset();
begin
if bankScreen.isOpen(5000) then
bankScreen.clickButton(BANK_BUTTON_PRESET_1)
else
useBank
end;

procedure findingForge();
var
x, y: integer;
waitTimer: TTimeMarker;

begin
waitTimer.start();

if (not tabBackpack.isFull()) and (not tabBackpack.isFull()) and (not tabBackpack.isFull()) then
useBank;

if bankScreen.isOpen then
usePreset;

repeat
mainscreen.findObject(x, y, 1663163, 6, colorSetting(2, 0.36, 1.44), mainscreen.playerPoint, 15, 15, 15, ['orge'], 3);

if isMouseOverText(['orge'], 200) then
begin
fastClick(MOUSE_LEFT);
break;
end;
until (productionScreen.isOpen(5000)) or (waitTimer.getTime() > 200000);

if (waitTimer.GetTime() > 200000) then
begin
WriteLn('couldn''t find portable, terminating script');
TerminateScript();
end;
end;

procedure usingForge();
begin

Wait(gaussRangeInt(700, 1100));
if (productionScreen.isOpen(500)) then
productionScreen.selectBox(WhichOres);
productionScreen.clickStart(true);
end;

procedure waitingForge();
begin
Wait(gaussRangeInt(1000, 1100));
if(not progressScreen.isOpen()) then
exit;

repeat
wait(1000);
antiBan();
writeLn('waiting');
until (not progressScreen.isOpen()) and (not progressScreen.isOpen()) and (not progressScreen.isOpen());
end;

{Main Loop}
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();
mainScreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_WEST);

repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
exitTreasure();
mainScreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_WEST);
end;

useBank();
usePreset();
findingForge();
usingForge();
waitingForge();
until(false);
end.

jarofhearts

2015-02-04 15:00:47

Congrats on the release! This looks really useful, I'll be checking it out in the future.

Hitac

2015-03-01 13:35:53

Works great!

Hitac

2015-03-14 06:41:29

Can this work with Gold casting? Forget, it works :)

General_Patrick

2015-05-11 20:55:10

This looks like a nice script. I cannot wait to try and break the script and let you know what errors i find.