SRL Archive - First Scripts

First Script: Log Cutter (Fletching)


Adieux

2014-08-06 21:32:06

So I've known of these forums for about 2 years now, some of the scripts on here were the first I ever used to bot in Runescape.
I took a break from RS for a while and I'm back now and decided to visit this site again and actually contribute this time.
So I know this script is pretty basic and not too hard to do but im actually decently proud of it, and will be trying to make more complex and walking scripts in the future.

Thanks to The Mayor, for his amazing guide on the forums and for helping with my question last night as well as everyone else that has contributed awesome guides/help!

I am definitely open for A LOT of help as I know I need it, and I would not recommend running this for any long period of time.

Things I want to get done and would appreciate any help in or pointing me in the right direction.
1.How to implement Antiban ADDED!
2.How to make it easier for people to set up the script so that it work in different locations/different types
of items to craft
3.Pin integration…lol
4.Making fail safes ex: when you run out of logs to log you out
5.Profit calculator/exp calc/logs cut(have a basic implementation of this already)
6.Edit out the debug box so its not so ugly and cluttered with information
7.Any other ideas people have/are interested in

Right now its just set up to cut Willow logs into shieldbows(u) at edgeville bank if you have the logs in the 10th slot, they're decent exp/money. You can however just change the script to suit what items you want to craft/locations to craft. But I would love to make it easier.

Well here it is, please let me know what you think I definitely do not mind criticism
[PHP]program BitPoorFletcherV01;

{$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 := ''; //Enter Username here
password := ''; //Enter password here
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

var
depositCount: integer;

procedure openBank ();
begin
if isLoggedIn() then
begin
bankScreen.open(BANK_NPC_BLUE); //Change color or bank location here
_waitBankOrPinscreen(5000);
end;

if depositCount <1 then
if bankScreen.open(BANK_NPC_BLUE) then //Change color or bank location here
begin
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
inc(depositCount) + 1;
end;

if bankScreen.open(BANK_NPC_BLUE) then //Change color or bank location here
begin
bankScreen.withdraw(10,WITHDRAW_AMOUNT_ALL, ['']); //Change mouseover text for different logs
wait(randomRange(800,1000));
bankScreen.close
end else
writeLn('Could not find bank screen')
end;

procedure antiBan(); //Straight outta includes (imma noob)
begin
if not isLoggedIn() then
begin
writeLn('Not logged in, exiting');
end;

begin
case random(100) of
1..25: begin
writeLn('Performing AntiBan, Hovering Over Skills');
hoverRandomSkill();
end;

26..46: begin
writeLn('Performing AntiBan, Bored Human');
BoredHuman;
wait(randomRange(2000,4000));
minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);
end;

47..67: begin
writeLn('Performing AntiBan, Move Mouse Like A Downy');
smallRandomMouse();
end;

68..88: begin
writeLn('Performing AntiBan, I Fell Asleep On The Computer Oh No!');
sleepAndMoveMouse(2000 + random(3000));
end;

89..99: begin
writeLn('Performing AntiBan, Are We 99 Yet');
pickUpMouse();
end;
end;
end;
end;

procedure doWePerformAntiBan();
begin
writeLn('AntiBan or nah?');
case Random(10) of
1..6: begin
writeLn('Nah, no AntiBan');
end;

7..9: begin
writeLn('Yah, Performing AntiBan');
antiBan();
end;
end;
end;

var
CraftCount: integer;
LogsCut : integer;

function amountOfLogsCut(): string;
begin
result := 'Amount of logs cut =';
end;

procedure cutLogs ();
begin
if bankScreen.close then
begin
wait(randomRange(1000,2000));
tabBackPack.mouseSlot(randomRange(1,10), MOUSE_LEFT);

if craftCount <1 then
if toolScreen.isOpen(2000) then
begin
toolScreen.select('Knife');
inc(CraftCount) + 1;
end;
end;

if productionScreen.isOpen(3000) then
begin
productionScreen.selectBox(3); //Change to 1 for ShortBows, 2 for stocks and 3 for Shieldbows
wait(randomRange(800,1100));
productionScreen.clickStart();

if progressScreen.isOpen(2000) then
repeat
wait(randomRange(11000,16000));
doWePerformAntiBan();
until progressScreen.getButton() < 1;
end else
writeLn('Couldnt select item to craft')

if progressScreen.getButton() < 1 then
begin
LogsCut := LogsCut + 28;
writeLn('Amount of logs cut:' + intToStr(LogsCut));
inc(LogsCut) +1
end;

if not isLoggedIn() then
exit;

if not progressScreen.getButton() < 1 then
exit;

end;

procedure depositLogs ();

const
BACKPACK_SLOT_LOW = 0;

begin
wait(randomRange(1000,2000));
bankScreen.open(BANK_NPC_BLUE); //Change color or bank location here

if bankScreen.open(BANK_NPC_BLUE) then //Change color or bank location here
begin
wait(randomRange(1000,2000));
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
wait(randomRange(1000,2000));
end;

if bankScreen.open(BANK_NPC_BLUE) then
repeat
openBank();
cutLogs();
depositLogs();
until false;
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();

if not isLoggedIn() then
begin
players[currentPlayer].login();
exitSquealOfFortune();
minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);

if isLoggedIn() then
exitSquealOfFortune();
minimap.setAngle(MM_DIRECTION_NORTH);
mainScreen.setAngle(MS_ANGLE_HIGH);

end;
openBank();
cutLogs();
depositLogs();

end[/PHP]

lanadekat

2014-08-07 07:51:01

bankScreen.open(BANK_NPC_BLUE)

doesn't work good, I have an script that needs to open the bank at the GE and it doesn't work at all :(
as long as there are no people at the bank it should work fine. but when there are more people it stops working.

colordetection works better.

Adieux

2014-08-07 15:01:36

From: lanadekat
bankScreen.open(BANK_NPC_BLUE)

doesn't work good, I have an script that needs to open the bank at the GE and it doesn't work at all :(
as long as there are no people at the bank it should work fine. but when there are more people it stops working.

colordetection works better.


That's weird, I've only tested at Edgeville bank, it is quite busy their and it works fine never had any issues.

I dont think the Grand Exchange is the best place to run a script, much more vulnerable to lag.

lanadekat

2014-08-07 16:42:24

From: luispadron
That's weird, I've only tested at Edgeville bank, it is quite busy their and it works fine never had any issues.

I dont think the Grand Exchange is the best place to run a script, much more vulnerable to lag.

It's a decent place, after bugfixing my script a long time it finnaly runs at the GE without getting stuck.
I would have taken another place , but I need the fontain. and I don't want to run everytime to the GE to buy stuff.

Adieux

2014-08-07 17:08:12

From: lanadekat
It's a decent place, after bugfixing my script a long time it finnaly runs at the GE without getting stuck.
I would have taken another place , but I need the fontain. and I don't want to run everytime to the GE to buy stuff.



Well thats good, gratz!

lanadekat

2014-08-07 17:22:57

From: luispadron
Well thats good, gratz!

maybe an extra antiban function to look at fletching xp, cus now it only looks at a random skill.
it's just a suggestion.
You script looks really nice, I hope someone can test it and post a long proggy, I'm not a member ( yet )

theorange

2014-08-07 18:31:36

Minor improvements:

Could declare global variable of what banker you're gonna be using, and then use that global variable for the 5 times you access the bankers, that way people don't have to edit 5 different lines/possibly forget to change one of them.

Also could declare global variable at the top of the script for the production so you don't have to scroll down all the way to change it for: "Change to 1 for ShortBows, 2 for stocks and 3 for Shieldbows". Then you can have it easily customizable for other optiosn if there are more options for that log.

For the failsafe of running out of logs, an option would be: Instead of putting them in slot 10, put them in quick withdraw 1 or 2, and then have it do an inventory count before it starts doing the logs, if the inventory count less than 28, quit out, as you have no more logs int the bank. This would make it easier for people to do any type of logs.

I think some public scripts have bank pin integration, you could just reuse their code for that if you wanted to, or do it yourself. Same with the basic template of the progress report, and then just add some global variables depending on what type of log they use to change the exp gained/value earned. Put a variable to update the total logs processed in the loop right after you process the logs but before you bank them.

(note: I haven't actually ran the script, the above are just observations from reading through the code)

Adieux

2014-08-07 19:42:16

From: theorange
Minor improvements:

Could declare global variable of what banker you're gonna be using, and then use that global variable for the 5 times you access the bankers, that way people don't have to edit 5 different lines/possibly forget to change one of them.

Also could declare global variable at the top of the script for the production so you don't have to scroll down all the way to change it for: "Change to 1 for ShortBows, 2 for stocks and 3 for Shieldbows". Then you can have it easily customizable for other optiosn if there are more options for that log.

For the failsafe of running out of logs, an option would be: Instead of putting them in slot 10, put them in quick withdraw 1 or 2, and then have it do an inventory count before it starts doing the logs, if the inventory count less than 28, quit out, as you have no more logs int the bank. This would make it easier for people to do any type of logs.

I think some public scripts have bank pin integration, you could just reuse their code for that if you wanted to, or do it yourself. Same with the basic template of the progress report, and then just add some global variables depending on what type of log they use to change the exp gained/value earned. Put a variable to update the total logs processed in the loop right after you process the logs but before you bank them.

(note: I haven't actually ran the script, the above are just observations from reading through the code)


To declare the global variables, I would just have to put them before any other procedure, but wouldnt this still make it difficult for people to switch the bankers? How would I add that variable and make it work with all the different lines of codes that I have to bank with a certain NPC without having to manually change it. Im using the include to bank so what would I put in for
bankScreen.open(BANK_NPC_BLUE) < what would I write in here?

Thank you very much for the suggestions, I will definitely try to implement them soon! (still very noob)

theorange

2014-08-07 19:52:55

From: luispadron
To declare the global variables, I would just have to put them before any other procedure, but wouldnt this still make it difficult for people to switch the bankers? How would I add that variable and make it work with all the different lines of codes that I have to bank with a certain NPC without having to manually change it. Im using the include to bank so what would I put in for
bankScreen.open(BANK_NPC_BLUE) < what would I write in here?

Thank you very much for the suggestions, I will definitely try to implement them soon! (still very noob)


Generally you want to avoid global variables unless you're in a situation like this, where your global variables are going to remain constant. So here it would be a nice thing to implement.

It would make it easier for people to switch bankers, as you'd have your global variable for bankers, at the top of the script, and people would simply edit that variable to be whatever banktype npc's they want. I think you can just do integers for it, look more here: docs.villavu.com/srl-6/bankscreen.html at the bottom. Then you'd use that variable in place of all the spots where you mention the banker in the script. This makes it optimal, as now you keep the same variable name for all spots you mention the banker, and only change the banker type at the top, in your global variable, ensuring that everything matches.

Definitely a good start! You might want to take a free course on codecademy (http://www.codecademy.com/en/tracks/javascript, doesn't have to be javscript, can be anything) or somewhere else to further improve your thinking on how to build a solution.

Then you can use your programming knowledge of how to build programs in combination with the simba syntax to make your desired scripts here on runescape. Of course, you can do anything you like, but learning more things never hurts.

bonsai

2014-08-07 19:55:35

From: luispadron
To declare the global variables, I would just have to put them before any other procedure, … what would I put in for
bankScreen.open(BANK_NPC_BLUE) < what would I write in here?



var bankType: integer = BANK_NPC_BLUE;
...
bankScreen.open(bankType);

Adieux

2014-08-07 21:03:04

From: bonsai

var bankType: integer = BANK_NPC_BLUE;
...
bankScreen.open(bankType);


Thanks! this works perfectly.

Adieux

2014-08-07 21:04:09

From: theorange
Generally you want to avoid global variables unless you're in a situation like this, where your global variables are going to remain constant. So here it would be a nice thing to implement.

It would make it easier for people to switch bankers, as you'd have your global variable for bankers, at the top of the script, and people would simply edit that variable to be whatever banktype npc's they want. I think you can just do integers for it, look more here: docs.villavu.com/srl-6/bankscreen.html at the bottom. Then you'd use that variable in place of all the spots where you mention the banker in the script. This makes it optimal, as now you keep the same variable name for all spots you mention the banker, and only change the banker type at the top, in your global variable, ensuring that everything matches.

Definitely a good start! You might want to take a free course on codecademy (http://www.codecademy.com/en/tracks/javascript, doesn't have to be javscript, can be anything) or somewhere else to further improve your thinking on how to build a solution.

Then you can use your programming knowledge of how to build programs in combination with the simba syntax to make your desired scripts here on runescape. Of course, you can do anything you like, but learning more things never hurts.


Thanks for the help, I am actually starting college in a couple weeks and will be majoring in Computer Science ill definitely check out that website.

theorange

2014-08-07 21:06:01

From: luispadron
Thanks for the help, I am actually starting college in a couple weeks and will be majoring in Computer Science ill definitely check out that website.


Nice! you're gonna be a step ahead of all your classmates, and this is going to be a great platform for you to come up with projects for yourself.