Jump to content

A Beginners Guide to Writing OSBot Scripts (where to get started!) by Apaec


Recommended Posts

  • 3 months later...
Posted

Hey, great guide, im just curious if the script manifest has changed since this tutorial was created? because i cant seem to get OSbot to recognize the custom script. I havent changed much past the original script but i exported just to make sure it worked and it doesnt 😓
 

package testingBot.main;

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

@ScriptManifest(author = "xjax1", info = "Testing Script", name = "testbot", version = 1, logo = "")
public class Main extends Script {

	@Override
	public void onStart() {
		log("Starting Up");
	}

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

	@Override
	public void onExit() {
		log("Exiting");
	}
}

As you can see, not many changes, but it still wont load, i have made sure(multiple times) its exported as a JAR and in the right file, and have restarted and re-installed OSbot quite a few times. is there any possible fix for this? or does OSbot just not like my pc script for some reason?

Posted

Hmm. Totally new to programming so I'll have a few questions. FI copied and pasted in the backbone, and already got a lot of red lines. Here's what the console reads.

Error: Unable to initialize main class core.Main in module TeaThiever2
Caused by: java.lang.NoClassDefFoundError: Graphics2D

Got the OSBot jar file in the referenced libraries - Looks like I have a new edition of Eclipse since this tutorial was made though, so I exported it under ClassPath.

First red line and error is appearing at this code line: import java.awt.Graphics2D;

Any idea on the issue?

  • 1 month later...
  • 3 weeks later...
  • 1 month later...
  • 2 weeks later...
Posted

I recently got into scripting and im having some difficulties searching for stuff i need in the api, i know what i need but i have trouble finding what is the right method to use and how to use it. For example the myPlayer method, there's no way i would know that i need to do !myPlayer instead of myPlayer. Also if i find a method, i dont know what do i have to import in order to use it. Sorry for the noob question but essencially if i know how to search the api, i would script much faster since i have some programming knowledge already. Thanks!

Posted
29 minutes ago, badjie said:

I recently got into scripting and im having some difficulties searching for stuff i need in the api, i know what i need but i have trouble finding what is the right method to use and how to use it. For example the myPlayer method, there's no way i would know that i need to do !myPlayer instead of myPlayer. Also if i find a method, i dont know what do i have to import in order to use it. Sorry for the noob question but essencially if i know how to search the api, i would script much faster since i have some programming knowledge already. Thanks!

APIs can take a bit of scavenging to find what you need. Useful links are the alphabetical 'index' at the top of the docs, when you are looking for a method but don't know which class it might belong to. Also, the '!' is a negation operator, i.e., if you take something that evaluates to true and negate it with a '!', the result will be false (just thought i'd clear that up as that's unrelated to the OSBot API).

It just takes a bit of practice to learn where most things are, as with all APIs. I'd suggest asking for help on specifics when you get stuck (perhaps in the OSBot discord).

Good luck!

Posted
On 8/15/2014 at 9:51 AM, Apaec said:

RS2Object stall = getObjects().closest("Tea Stall"); if (stall != null && !myPlayer().isAnimating()) { stall.interact("Steal-from"); } // ...

So here the !myPlayer().isAnimating() part is basically saying if my player is NOT(negating with !) in the middle of an animation?

Posted (edited)
1 hour ago, badjie said:

what is the "." just before "closest" doing? i also didnt find anything on the api so im assuming its a language thing

Its a java thing.  I personaly suck at explaining things. So here some link. I would recommend watching a crash coruse on java over the next few days.

  1. https://www.freecodecamp.org/news/java-getters-and-setters/#:~:text=Getters and setters are used,as accessors and mutators%2C respectively.
  2. https://www.tutorialspoint.com/java/java_inheritance.htm
  3. https://www.tutorialspoint.com/java/java_object_classes.htm 

 

 

Edited by Nbacon
  • Like 1

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