Jump to content

Basic Script Skeleton


Divine

Recommended Posts

Download: http://uppit.com/tfpejnqlq0t1/ScriptBase.java

 

In Text:

import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;

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

@ScriptManifest(name = "Script Name", author = "Author", version = 1.0D, info = "Description goes here.")
public class ClassName extends Script {

	/*
	 * Variables
	 */

	private BufferedImage paint;
	private long startTime;

	/*
	 * Inherited Methods
	 */

	// Called at start
	public void onStart() {
		try {
			startTime = System.currentTimeMillis();
			this.paint = ImageIO.read(new URL("IMAGE URL GOES HERE."));
		} catch (Exception e) {
			// Catch
		}
	}

	// Called more than once.
	public int onLoop() {
		try {

		} catch (Exception e) {
			// Catch
		}
		return 1;
	}

	// Called at script stop
	public void onExit() {

	}

	// Called more than once, even during pause.
	public void onPaint(java.awt.Graphics g) {
		if (paint != null)
			g.drawImage(paint, 0, 0, null); //0,0 = X,Y
	}

	/*
	 * Non-Inherited Methods
	 */
	
	//Non-Inherited methods go here.

	/*
	 * Useful Methods
	 */

	//XP for level
	public int getXPForLevel(int level) {
		int points = 0;
		int output = 0;
		for (int lvl = 1; lvl <= level; lvl++) {
			points += Math.floor((double) lvl + 300.0
					* Math.pow(2.0, (double) lvl / 7.0));
			if (lvl >= level)
				return output;
			output = (int) Math.floor(points / 4);
		}
		return 0;
	}

}

onStart is called at the start of script,

onLoop is called over and over.

onExit is called on script stop.

onPaint is for the drawing.

  • Like 2
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...