Jump to content

Drink Best Potion


Jack

Recommended Posts

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
Link to comment
Share on other sites

Guest Apogee


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

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

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

}

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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");
	}
  • Like 1
Link to comment
Share on other sites

 

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.

 

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