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.

How To Use A "state" In Java Scripts

Featured Replies

Someone asked me, so here

//Imports herepublic class ScriptName extends Script {	private static enum BotState = {		STATE_1,		STATE_2,		STATE_3,		STATE_4,		STATE_5	};	private BotState state;	public int onLoop() {		state = setState(); // Method to figure out which state the bot is in		return handleState(state);	}	/***************************************************************	*  Method BotState setState() 	*  returns ENUM - BotState	*  Use this method to calculate the state	*  Such as, if the players inventory is full	*  return BotState.BANKING	****************************************************************/	private BotState setState() {		// Stuff here		return BotState.STATE_5;	}	/***************************************************************	*  Integer handleState 	*  returns integer	*  Use this method to function	*  according to which state the script is in/	*  Example: if STATE_1, RETURN 1000;   (If the bot is in state_1, wait for a second. If not, look for another	*  state.	****************************************************************/	private int handleState(BotState state) {		switch(state) {			case STATE_1:				//code				return 1000; // Wait time before next onLoop()			case STATE_2:				//code				return 710; // wait time before next onLoop()		}	}}

Edited by XenoTools

Good job, could be more details or examples. My AIO scripts use something like this but a bit different this can make the code more efficient and cleaner.

  • Author

 

Good job, could be more details or examples. My AIO scripts use something like this but a bit different this can make the code more efficient and cleaner.

 

Really isn't much to show, if you get it you get it, if you don't you don't.

It's very basic scripting and anybody who understands a hello world program using a switch would understand this. /:

EDITED with slight comment adjustments

Edited by XenoTools

  

Really isn't much to show, if you get it you get it, if you don't you don't.

It's very basic scripting and anybody who understands a hello world program using a switch would understand this. /:

EDITED with slight comment adjustments

Well not everyone knows how to use Enums, just saying anyway good job now it looks better :))

  • Author

Well not everyone knows how to use Enums, just saying anyway good job now it looks better smile.png)

For future clarification the way we are using the Enum is no different than a way you would use a String, int, long, double, var, or def.

Guest
This topic is now closed to further replies.

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.