Jump to content

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


Apaec

Recommended Posts

  • 2 months later...
13 hours ago, imachi said:

hi @Apaec ! Thanks for the guide. This has probably asked before, but when developing the script, do i have to close out OSBot and relog in to build the project and see the changes made? 

Nope - you should be fine just overriding the JAR in the scripts directory. No need to restart OSBot.

Link to comment
Share on other sites

  • 3 months later...

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

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!

Link to comment
Share on other sites

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!

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.
Note: Your post will require moderator approval before it will be visible.

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