uyfgfarOS Posted January 10, 2017 Share Posted January 10, 2017 I've been working on a herb cleaning script for a few days, been working fine, i've not even touched the code but I noticed Jagex changed the name of "Grimy harralanders" to "Grimy Harralanders". As my initial script skeleton was just for Harralanders, so i changed it so it matched but nothing seems to be working. It won't even click through my inventory anymore. All this seems to be doing is withdrawing grimy harralanders and then opening the grand exchange, which is completely wrong as it should be cleaning the herbs first, then banking and withdrawing clean ones. here's all my code, please ignore the spacing, after copy and pasting it on here it seems like my code is everywhere. Might be my mac... import org.osbot.rs07.api.Bank.BankMode; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.script.Script; import org.osbot.rs07.api.GrandExchange; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.*; import java.util.Random; @ScriptManifest(author = "Matt", info = "Cleans Herbs", name = "Matt's Herb Cleaner", version = 0, logo = "") public class main extends Script { paint Paint; String Status = " "; @[member=Override] public void onStart() { log("Beginning of script"); } private enum State { WITHDRAW, CLEAN, WAIT } private State getState() { if (getInventory().contains("Grimy harralander")) { return State.CLEAN; } if (!getInventory().contains("Grimy harralander")) { return State.WITHDRAW; } return State.WAIT; } @[member=Override] public int onLoop() throws InterruptedException { switch (getState()) { case WITHDRAW: doBanking(); if (!getGrandExchange().isOpen()) { //Checks if ge is open sellItem(); //Process sale if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.PENDING_SALE) { //Waiting for sale }else if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.FINISHED_SALE) { grandExchange.collect(); } buyItem(); //Process Buy if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.PENDING_BUY) { //Waiting for buy }else if (grandExchange.getStatus(GrandExchange.Box.BOX_1) == GrandExchange.Status.FINISHED_BUY) { grandExchange.collect(); } } else { doBanking(); } break; case CLEAN: if (getInventory().contains("Grimy harralander")) { doCleaning(); } else { break; } case WAIT: break; } return random(200, 300); } @[member=Override] public void onExit() { log("Exit script"); } @[member=Override] public void onPaint(Graphics2D g) { } public void doCleaning() throws InterruptedException { for(int i=0;i<28;i++) { mouse.move(inventory.getMouseDestination(i)); mouse.click(false); } sleep(random(1000,2000)); if (getInventory().contains("Grimy harralander")) { inventory.getItem("Grimy harralander"); mouse.click(false); } } public boolean offerItem(String string) { for (int n = 0; n < 27; n++) { RS2Widget inventoryWidget = getWidgets().get(467, 0, n); if (getInventory().getItemInSlot(n).getName().contains(string)) { return inventoryWidget.interact("Offer"); } } return false; } public void sellItem() throws InterruptedException { if (!grandExchange.isOpen()) { //Open GE openGrandExchange(); sleep(random(500,900)); grandExchange.sellItem(256, 539, 224); sleep(random(5000,6000)); grandExchange.confirm(); } } public void buyItem() throws InterruptedException { if (!grandExchange.isOpen()) { openGrandExchange(); sleep(random(500,900)); grandExchange.buyItem(205, "Grimy harralander", 565, 224); sleep(random(5000,6000)); grandExchange.confirm(); } } public void openGrandExchange() { RS2Object geBooth = this.getObjects().closest("Grand Exchange booth"); NPC exchangeWorker = this.getNpcs().closest("Grand Exchange Clerk"); int random = new Random().nextInt(10); if (geBooth != null && random < 5) { geBooth.interact("Exchange"); new ConditionalSleep(2500, 3000) { @[member=Override] public boolean condition() { return getGrandExchange().isOpen(); } }.sleep(); } if (exchangeWorker != null && random >= 5) { exchangeWorker.interact("Exchange"); new ConditionalSleep(2500, 3000) { @[member=Override] public boolean condition() { return getGrandExchange().isOpen(); } }.sleep(); } } private void doBanking() throws InterruptedException { if(!bank.isOpen()){ Status = "Banking: Opening Bank."; NPC banker = npcs.closest("Banker"); if(banker != null) { if (banker.isOnScreen()) { Status = "Banking: Interacting Banker."; banker.interact("Bank"); sleep(random(900, 1200)); } } } else { Status = "Banking: Depositing."; if (!inventory.isEmpty()) { bank.depositAll(); } else { //Contains grimy if (bank.contains("Grimy harralander")) { if (getBank().getWithdrawMode().equals(BankMode.WITHDRAW_NOTE)) { getBank().enableMode(BankMode.WITHDRAW_ITEM); bank.withdraw("Grimy harralander", 28); } else { bank.withdraw("Grimy harralander", 28); } bank.close(); } //Doesn't contain grimy avantoes else if (!bank.contains("Grimy harralander")) { //Contains clean avantoes if (bank.contains("Harralander")) { //Withdraw 100 if (!getBank().getWithdrawMode().equals(BankMode.WITHDRAW_NOTE)) { getBank().enableMode(BankMode.WITHDRAW_NOTE); bank.withdraw("Harralander", 224); bank.withdraw("Coins", 30000); bank.close(); } //new GrandExchange instance with our script } } } sleep(random(250, 450)); } } } Quote Link to comment Share on other sites More sharing options...
PlagueDoctor Posted January 10, 2017 Share Posted January 10, 2017 (edited) In the code you've posted it still shows 'Grimy harralander' rather than 'Grimy Harralander' private void doBanking() throws InterruptedException { if(!bank.isOpen()){ Status = "Banking: Opening Bank."; NPC banker = npcs.closest("Banker"); if(banker != null) { if (banker.isOnScreen()) { Status = "Banking: Interacting Banker."; banker.interact("Bank"); sleep(random(900, 1200)); } } } else { Status = "Banking: Depositing."; if (!inventory.isEmpty()) { bank.depositAll(); } else { //Contains grimy if (bank.contains("Grimy harralander")) { if (getBank().getWithdrawMode().equals(BankMode.WITHDRAW_NOTE)) { getBank().enableMode(BankMode.WITHDRAW_ITEM); bank.withdraw("Grimy harralander", 28); } else { bank.withdraw("Grimy harralander", 28); } bank.close(); } //Doesn't contain grimy avantoes else if (!bank.contains("Grimy harralander")) { //Contains clean avantoes if (bank.contains("Harralander")) { //Withdraw 100 if (!getBank().getWithdrawMode().equals(BankMode.WITHDRAW_NOTE)) { getBank().enableMode(BankMode.WITHDRAW_NOTE); bank.withdraw("Harralander", 224); bank.withdraw("Coins", 30000); bank.close(); } //new GrandExchange instance with our script } } } sleep(random(250, 450)); } } I believe this code is causing your issue, you've written it so the withdrawing code only executes if the bank is already open. If the bank is not already open, it will open the bank and then continue on with the code in your withdraw state. Remove the else from this and it should work as intended? Edited January 10, 2017 by PlagueDoctor 1 Quote Link to comment Share on other sites More sharing options...
uyfgfarOS Posted January 10, 2017 Author Share Posted January 10, 2017 The withdrawing works fine, it takes the grimy harralanders out, closes the bank then it doesn't seem to want to change over to the Clean state, it just sits there hovering over the GE Quote Link to comment Share on other sites More sharing options...
PlagueDoctor Posted January 11, 2017 Share Posted January 11, 2017 Yeah it's getting stuck on your grand exchange code in your withdraw case. Perhaps if you move your grand exchange code into another case you can better determine which code is causing the issue. Quote Link to comment Share on other sites More sharing options...