Jack Posted May 19, 2014 Posted May 19, 2014 (edited) 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 Edited May 21, 2014 by Jack
liverare Posted May 19, 2014 Posted May 19, 2014 (edited) 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 May 19, 2014 by liverare 2
Kenneh Posted May 19, 2014 Posted May 19, 2014 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. 1
Swizzbeat Posted May 19, 2014 Posted May 19, 2014 Didn't you make a thread a little bit ago asking for a project to do for scholar rank...? 3
NotoriousPP Posted May 20, 2014 Posted May 20, 2014 This is almost as bad as: int j=0; for (int i=0; i < a.length; ++i) { j++; } System.out.println("array size=" + j); 3
Guest Apogee Posted May 21, 2014 Posted May 21, 2014 if (integer(1) =!=!= -73 THEN DO) { log("I'm incredible with scripting."); sleep(completelyrandom.superrandom,even.(40, 69); }
Jack Posted May 21, 2014 Author Posted May 21, 2014 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 Else Return This is a joke... "Because code optimization is for pussies..."
Dog_ Posted May 21, 2014 Posted May 21, 2014 This is a joke... "Because code optimization is for pussies..." This is the wrong place to post jokes.
Jack Posted May 21, 2014 Author Posted May 21, 2014 This is the wrong place to post jokes. Its completely functional code :P
Kenneh Posted May 21, 2014 Posted May 21, 2014 Its completely functional code 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.
liverare Posted May 23, 2014 Posted May 23, 2014 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"); } 1
Kenneh Posted May 26, 2014 Posted May 26, 2014 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.