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.

Drink Best Potion

Featured Replies

import org.osbot.script.Script;
import org.osbot.script.rs2.ui.Inventory;

public class Snipets {

	Script script;

	public boolean drinkBestPot(String type) throws Exception{

		Inventory inv = script.client.getInventory();
		String potName;

		if(inv.contains("Extreme "+type+" (1)"))
			potName = "Extreme "+type+" (1)";
		else
			if(inv.contains("Extreme "+type+" (2)"))
				potName = "Extreme "+type+" (2)";
			else
				if(inv.contains("Extreme "+type+" (3)"))
					potName = "Extreme "+type+" (3)";
				else
					if(inv.contains("Extreme "+type+" (4)"))
						potName = "Extreme "+type+" (4)";
					else
						if(inv.contains("Super "+type+" (1)"))
							potName = "Super "+type+" (1)";
						else
							if(inv.contains("Super "+type+" (2)"))
								potName = "Super "+type+" (2)";
							else
								if(inv.contains("Super "+type+" (3)"))
									potName = "Super "+type+" (3)";
								else
									if(inv.contains("Super "+type+" (4)"))
										potName = "Super "+type+" (4)";
									else
										if(inv.contains(type+" potion (1)"))
											potName = type+" potion (1)";
										else
											if(inv.contains(type+" potion (2)"))
												potName = type+" potion (2)";
											else
												if(inv.contains(type+" potion (3)"))
													potName = type+" potion (3)";
												else
													if(inv.contains(type+" potion (4)"))
														potName = type+" potion (4)";
													else
														return false;

		return inv.interactWithName(potName, "Drink");

	}
}

Because code optimization is for pussies...

 

 

Wow people thought I was serious dry.png

Edited by Jack

XD This made my day!

 

There are 12 selectors calling the #contains(...) method, which means there's a maximum of (12 * 28 = 336) iterations. All my fucking lel.

Edited by liverare

I really hope this is a joke.

 

You spelled snippets wrong, you have a null script instance and the code is just laughable.

 

PS: If something looks overly complicated, there's probably an easier way to do it.


if (integer(1) =!=!= -73 THEN DO) {

log("I'm incredible with scripting.");

sleep(completelyrandom.superrandom,even.(40, 69);

}

  • Author
if (integer(1) =!=!= -73 THEN DO) {
log("I'm incredible with scripting.");
sleep(completelyrandom.superrandom,even.(40, 69);
}

 

 

 

This is almost as bad as:

int j=0;
for (int i=0; i < a.length; ++i) {
    j++;
}        
System.out.println("array size=" + j);

 

 

This is the best code I've seen in months.

 

 

what the fuck

 

 

Didn't you make a thread a little bit ago asking for a project to do for scholar rank...?

 

 

I really hope this is a joke.

 

You spelled snippets wrong, you have a null script instance and the code is just laughable.

 

PS: If something looks overly complicated, there's probably an easier way to do it.

 

 

XD This made my day!

 

There are 12 selectors calling the #contains(...) method, which means there's a maximum of (12 * 28 = 336) iterations. All my fucking lel.

 

 

If

Elseleaning_tower_of_pisa_1352403.jpg

Return

This is a joke... 

 

"Because code optimization is for pussies..."

This is a joke...

"Because code optimization is for pussies..."

This is the wrong place to post jokes.

Its completely functional code tongue.png

 

No it's not. Your script instance will always be null. You'd have to instantiate the class to use it since the method is public and not static. It WOULD be perfectly functional if you passed and assigned the script instance in the class constructor.

Okay, I'll be the first to post some kind of solution...

	public static Item getBestPotion(Inventory inventory, Skill skill) {
				
		String skillToLowercase = skill.name().toLowerCase();
		
		String[] potionNames = {
			
			"Extreme " + skillToLowercase, // Extreme attack
			"Super " + skillToLowercase, // Super attack
			(skill.name().charAt(0) + skill.name().substring(1).toLowerCase()) + " potion" // Attack potion
		};
		
		return inventory.getItemForNameThatContains(potionNames);		
	}
	
	public static boolean drinkBestPotion(Inventory inventory, Skill skill) throws InterruptedException {
		
		Item bestPotion = getBestPotion(inventory, skill);
		
		return bestPotion != null && inventory.interactWithId(bestPotion.getId(), "Drink");
	}

 

Okay, I'll be the first to post some kind of solution...

	public static Item getBestPotion(Inventory inventory, Skill skill) {
				
		String skillToLowercase = skill.name().toLowerCase();
		
		String[] potionNames = {
			
			"Extreme " + skillToLowercase, // Extreme attack
			"Super " + skillToLowercase, // Super attack
			(skill.name().charAt(0) + skill.name().substring(1).toLowerCase()) + " potion" // Attack potion
		};
		
		return inventory.getItemForNameThatContains(potionNames);		
	}
	
	public static boolean drinkBestPotion(Inventory inventory, Skill skill) throws InterruptedException {
		
		Item bestPotion = getBestPotion(inventory, skill);
		
		return bestPotion != null && inventory.interactWithId(bestPotion.getId(), "Drink");
	}

 

I'll post another way in a bit.

 

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.