Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Different class

Featured Replies

I have 2 files, main file and another one that I would like imported.

 

Main file code:

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "SirSkitzo", info = "", logo = "", name = "FirstScript", version = 1)

public class test extends Script {

    public void onStart() throws InterruptedException {
        another a = new another();
        a.test();
    }

    public int onLoop() throws InterruptedException {
        return 0;
    }
}

and on the another class

import org.osbot.rs07.script.Script;

public class another {
  
	protected Script script;
	public another init(Script script){
		this.script = script;
		return this;
	}
	
	public void test() {
		script.log("A message");
	}
    
}

It doesn't work and I keep getting errors from the client. What am I doing wrong and how can I fix this?

Edited by sirskitzo

2 minutes ago, sirskitzo said:

I have 2 files, main file and another one that I would like imported.

 

Main file code:


import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "SirSkitzo", info = "", logo = "", name = "FirstScript", version = 1)

public class test extends Script {

    public void onStart() throws InterruptedException {
        another a = new another();
        a.test();
    }

    public int onLoop() throws InterruptedException {
        return 0;
    }
}

and on the another class


import org.osbot.rs07.script.Script;

public class another {
  
	protected Script script;
	public another init(Script script){
		this.script = script;
		return this;
	}
	
	public void test() {
		script.log("A message");
	}
    
}

It doesn't work and I keep getting errors from the client. What am I doing wrong and how can I fix this?

 

You didn't call init?

pass instance in the constructor of the class 

 

 

another a = new another (instance);

  • Author

@Chris Sorry for being a noob but I get an error in code now while doing this. Could you please show me how?

Looks like you are trying to create a task/node system. You should probably just work on your OOP before doing something like this. If you are not working on a task/node system, what are you actually trying to achieve?

You should probably read up on some OOP principles as Alek said but I'll post a solution.

public another init(Script script){
		this.script = script;
		return this;
	}

Change this into a constructor by removing the return type "another".

another a = new another(this);

pass an instance of your class that extends Script.

1 hour ago, Jammer said:

You should probably read up on some OOP principles as Alek said but I'll post a solution.


public another init(Script script){
		this.script = script;
		return this;
	}

Change this into a constructor by removing the return type "another".


another a = new another(this);

pass an instance of your class that extends Script.

 

That's not how you define a constructor, the constructor should have the same name as the class.

It's not:

public init(Script script) {

}

 

It's:

public another(Script script) {

}

 

@sirskitzo you should follow some Java tutorials until you understand the basics.

8 hours ago, Explv said:

That's not how you define a constructor, the constructor should have the same name as the class.

It's not:


public init(Script script) {

}

 

It's:


public another(Script script) {

}

right, forgot to say that.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.