Jump to content

Seperate classes, wat am i doing wrong?


Recommended Posts

Posted (edited)

Hey everyone.

 

I'm trying to use different classes for different quests. This is because i'm trying to make myself a questing script.

 

What do i do wrong? I have 2 classes. The first is ofcourse the main class, second class is "SheepShearer".

 

This is my code:

package core;
	import org.osbot.rs07.api.model.Entity;
	import org.osbot.rs07.script.Script;
	import org.osbot.rs07.script.ScriptManifest;
	import quests.SheepShearer;

import java.awt.*;

	@ScriptManifest(author = "Sebastian", info = "Quest like you've never quested before!", name = "JSQuester", version = 0, logo = "")
	public class Main extends Script {

		@[member='Override']
		public void onStart() {
			log("Started");
		}

		private enum State {
			SHEEPSHEARER, WAIT, QUESTTWO
		};

		private State getState() {
			if (myPlayer().isAnimating())
				return State.SHEEPSHEARER;
			return State.WAIT;
		}

		@[member='Override']
		public int onLoop() throws InterruptedException {
			switch (getState()) {
			case SHEEPSHEARER:
					new SheepShearer(this);
				break;
			case QUESTTWO:
				break;
			case WAIT:
				break;
			}
			return random(200, 300);
		}

		@[member='Override']
		public void onExit() {
			log("Stopped script..");
		}

		@[member='Override']
		public void onPaint(Graphics2D g) {

		}

	} 

package quests;

import org.osbot.rs07.script.Script;

public class SheepShearer {

public SheepShearer(Script Quest_SheepShearer) throws InterruptedException {
	
		Quest_SheepShearer.log("test");	
	}
}

I can't get it to log the "test". What am i doing wrong?

 

EDIT:

 

Nevermind, for some reason it works now...

[INFO][Bot #2][09/09 08:55:15 PM]: Started script : JSQuester
[INFO][Bot #2][09/09 08:55:15 PM]: test
[INFO][Bot #2][09/09 08:55:16 PM]: test
[INFO][Bot #2][09/09 08:55:16 PM]: test
[INFO][Bot #2][09/09 08:55:16 PM]: test
[INFO][Bot #2][09/09 08:55:16 PM]: test
[INFO][Bot #2][09/09 08:55:17 PM]: test
[INFO][Bot #2][09/09 08:55:17 PM]: test
[INFO][Bot #2][09/09 08:55:17 PM]: test
[INFO][Bot #2][09/09 08:55:17 PM]: test
Edited by Sebastian
Posted (edited)

Hey everyone.

 

I'm trying to use different classes for different quests. This is because i'm trying to make myself a questing script.

 

What do i do wrong? I have 2 classes. The first is ofcourse the main class, second class is "SheepShearer".

 

This is my code:

package core;
	import org.osbot.rs07.api.model.Entity;
	import org.osbot.rs07.script.Script;
	import org.osbot.rs07.script.ScriptManifest;
	import quests.SheepShearer;

import java.awt.*;

	@ScriptManifest(author = "Sebastian", info = "Quest like you've never quested before!", name = "JSQuester", version = 0, logo = "")
	public class Main extends Script {

		@[member='Override']
		public void onStart() {
			log("Started");
		}

		private enum State {
			SHEEPSHEARER, WAIT, QUESTTWO
		};

		private State getState() {
			if (myPlayer().isAnimating())
				return State.SHEEPSHEARER;
			return State.WAIT;
		}

		@[member='Override']
		public int onLoop() throws InterruptedException {
			switch (getState()) {
			case SHEEPSHEARER:
					new SheepShearer(this);
				break;
			case QUESTTWO:
				break;
			case WAIT:
				break;
			}
			return random(200, 300);
		}

		@[member='Override']
		public void onExit() {
			log("Stopped script..");
		}

		@[member='Override']
		public void onPaint(Graphics2D g) {

		}

	} 

package quests;

import org.osbot.rs07.script.Script;

public class SheepShearer {

public SheepShearer(Script Quest_SheepShearer) throws InterruptedException {
	
		Quest_SheepShearer.log("test");	
	}
}

I can't get it to log the "test". What am i doing wrong?

 

because you need to make an instance of the class for that to be executed in the onStart()

yeah it worked because you made a new instance and called the log in the constructor

Edited by Precise
Posted (edited)

because you need to make an instance of the class for that to be executed in the onStart()

 

yeah it worked because you made a new instance and called the log in the constructor

 

Thanks for your reply. For some reason it worked after i posted this thread.. I didn't change anything in the onStart() tbh.

 

 

Edited by Sebastian

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...