Jump to content

Road to Scripter 1


Recommended Posts

Posted (edited)

Hello all, I've started to learn how to script and decided to document my progress here. I don't actually know if I will get Scripter 1 since I don't know the requirements, how experienced I will need to be, as well as the fact that I'd likely keep the good scripts that I write to farm myself. Regardless, here's my progress!

 

Day 0:

Spoiler

I had been learning a little bit of C# for a side project. I was using Microsoft Virtual Academy and actually highly recommend it; it's free and explained all the fundamentals very well for an absolute beginner. I stopped learning after a little while, but I came across Apac's thread on scripting for beginners, thought it looked pretty easy, and took the plunge.

Day 1:

Spoiler

I thoroughly read through Apac's guide. I learned about setting up an IDE, setting a build path, and about how to use the skeleton. After a little trial and error, along with some very nice people on the same thread, I wrote a short script that would pick up bones one at a time and bury them.


	public int onLoop() throws InterruptedException {
		if(getInventory().contains("Bones")); {
			getInventory().interact("Bury", "Bones");
		}
		
		
			{GroundItem cowbone = getGroundItems().closest("Bones");
			if (cowbone != null) {
				cowbone.interact("Take");
			}
		}
		
	
		return random(2000, 3000);
	}

I was so happy! It was so satisfying to see something that I wrote actually work, when scripting seemed so foreign just a couple days ago. However, this script is pretty suboptimal, both in terms of the script itself and in the method itself. So I went to learn some more.

Day 2:

Spoiler

Today I learned more about using the API, learned more about projects/packages/classes, and was just reading some more basic guides. I posted the script above for some advise and received some helpful tips on how to make it an actual decent script. Nothing too exciting today.

Day 3:

Spoiler

I wanted to try to make a new script; one that would actually be more useful than getting like 2k prayer xp an hour. My next project was to make a moneymaker that would pick up the raw salmon that fishers drop at barbarian village, and then bank in edgeville. I wrote up this script (By myself I might add, was pretty excited about that ?) First thing I noticed was that the formatting is a lot cleaner which is a good sign I guess.


public int onLoop() throws InterruptedException {
		Area fishingspot = new Area(3108, 3432, 3109, 3433);
		Area bank = new Area(3092, 3489, 3094, 3498);
		
		if (!getInventory().isFull()) {
			if (!fishingspot.contains(myPlayer())) {
				getWalking().webWalk(fishingspot.getRandomPosition());}
					GroundItem salmon = getGroundItems().closest("Raw Salmon");
						if (salmon != null) {
							if (!myPlayer().isAnimating() && !myPlayer().isMoving()) {
								if (getMap().canReach(salmon)) {
									salmon.interact("Take");
									sleep(random(1000, 1200));
								}
							}
						}
					}
				else getWalking().webWalk(bank.getRandomPosition());
					
				if (bank.contains(myPlayer())) {
					   RS2Object bankBooth = objects.closest("Bank booth");
					    if (bankBooth != null) {
					        if (bankBooth.interact("Bank")) {
					            while (!bank.isOpen())
					                sleep(random(500, 1000));
					            bank.depositAll();
					        }
					    }
					}
				}
		return random(200, 300);
	}

Unfortunately the script wouldn't start when trying to run it , but I ran it by Apac's thread again, asked some more questions, and got many helpful answers. One, the banking system (which I had actually copied from another post funnily enough) would not work, and I was provided with a replacement. Two, I also learned a bit about conditional sleeps, however I'm still a little confused on those so. I also learned about pseudo-code. I wished I had known about that earlier; I was scratching my head for a while trying to figure out how to make sure I didn't walk back to the barbarian fishing spot when trying to bank.

 

Day 8:

Spoiler

I've been pretty busy with school, and I've actually started scripting with another bot's api, but I can still update this with some general info. I learned a lot about how to fix all of my errors in scripts, the vast majority of them coming from using brackets and semicolons correctly with if/else statements. I wrote another script that I probably can't post here since it's in another api. It looked clean and had no errors, but when I started it up, it did something completely different than what I wanted it to. So I'll be looking at that the next few days.

 

Edited by Dark798
  • Like 3

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...