Jump to content
Sebastian

Seperate classes, wat am i doing wrong?

Recommended Posts

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...