Jump to content

whoknowshonestly

Members
  • Posts

    7
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

whoknowshonestly's Achievements

Newbie

Newbie (1/10)

0

Reputation

  1. I simplified some bits of the code after logging out the problem and it seems to be working now, fingers crossed. Thanks for your help.
  2. Should it be more like (3000, 1000) instead? I'm going to give those numbers a shot and report back but if that's also a bad way to write it then let me know. Think I'm still misunderstanding sleep but other than that the code is coming together nicely.
  3. I've put up the code for both the dropping and banking bits now.
  4. Hi, I'm working on an AIO woodcutter as my first script. It chops and drops from 1-60, then banks yews at 60+. My problem is that I can't toggle shift click drop on either of my bots because the client seemingly misclicks on most of the logs and wont drop the majority of the inventory. Similarly in my banking script it sometimes talks to the banker instead of banking, and so I had to implement a workaround in case of it happening. Is this common? Is there a simple fix to this that I can check out as it would speed up my bots a decent amount. It works fine with normal dropping and the workaround but I'd love a solution to make it that bit better. Thanks in advance. EDIT TO ADD CODE: Dropping logs: private void dropWood(){ if (inventory.dropAllExcept("Bronze axe", "Steel axe", "Rune axe")){ new ConditionalSleep(100, 1000) { @Override public boolean condition() { return isInventoryEmpty(); } }.sleep(); } } Banking: private void bankWood() throws InterruptedException { if (getWalking().webWalk(Banks.GRAND_EXCHANGE)) { new ConditionalSleep(100, 1000) { @Override public boolean condition() { return isInBank(); } }.sleep(); } if (isInBank()) { if (!getBank().isOpen()) { if (getBank().open()){ new ConditionalSleep(100, 1000) { @Override public boolean condition() { return getBank().isOpen(); } }.sleep(); } } else if (getBank().isOpen()) { if (getBank().depositAllExcept("Bronze axe", "Steel axe", "Rune axe")) { new ConditionalSleep(100, 1000) { @Override public boolean condition() { return isInventoryEmpty(); } }.sleep(); } } } }
  5. Hey, thanks for taking a look. I've been trying to refactor it a bit over the last couple of days so these two bits I identified as poor and fixed them already. Can you expand on this just slightly? I definitely wasn't trying to be clever - it's my first script and I was following a tutorial where they had entered 2 values in their return. The values themselves were not even chosen for a reason other than I was playing around with them trying to get the script to stop spam clicking. I tried to find some more information on what a reasonable amount of time was for setting the OnLoop() but i've just been playing around with it really. It's currently set to (100, 200) after playing around with it last night - again not for any particular reason other than to test it. Thanks for the advice here - i'll try and avoid it in the future. I would say that I was actually encountering some issues with the inventory.dropAll() function not dropping all of the logs as it was tending to use logs on other logs and therefore skip a random amount of logs in the inventory. At the moment I have this which seems to have fixed it but again it's probably a plaster on the wound: private void dropWood(){ if (inventory.dropAllExcept("Bronze axe", "Steel axe", "Rune axe")){ new ConditionalSleep(100, 1000) { @Override public boolean condition() { return isInventoryEmpty(); } }.sleep(); } } I will fix this right now. Again thanks very much for the help, appreciate it. The code is improving every day.
  6. Just thought I should let you know I've got it working now thanks to your comment and I can see why it was getting confused. Thanks very much for the help, appreciate it.
  7. Hi, I've just recently decided to try my hand at some basic scripting. I've been following a few tutorials on the site but I can't get the Conditional Sleep to work no matter where I place it. It's an extremely basic woodcutter, here's the code: import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.utility.ConditionalSleep; import org.osbot.rs07.script.ScriptManifest; import java.util.function.BooleanSupplier; @ScriptManifest(author = "whoknowshonestly", name = "Trial Woodcutter", info = "First script - will chop trees and drop the logs", version = 0.1, logo = "https://i.imgur.com/7m1RYof.png") public final class Woodcutter extends Script { private final Area oakChoppingArea = new Area(3129, 3329, 3148, 3317); @Override public final int onLoop() throws InterruptedException { if (!oakChoppingArea.contains(myPosition())){ getWalking().webWalk(oakChoppingArea);} if (canChopTree()) { chopTree(); } else { dropWood(); } return random(1000, 2000); } private boolean canChopTree(){ Entity tree = getObjects().closest("Oak"); if (tree != null && tree.interact("Chop down") && !myPlayer().isAnimating()) { return true; } return false; } private boolean isCurrentlyChopping(){ return myPlayer().isAnimating(); } private boolean isInventoryEmpty() { return getInventory().contains(""); } private boolean inventoryContainsLogs(){ return getInventory().contains("Logs", "Oak logs", "Willow logs"); } private void chopTree(){ if (isInventoryEmpty() && !isCurrentlyChopping()){ if (getObjects().closest("Oak").interact("Chop down")) { new ConditionalSleep(10000, 10000) { @Override public boolean condition() { return inventoryContainsLogs(); } }.sleep(); } } } private void dropWood(){ inventory.dropAll(); } } class Sleep extends ConditionalSleep { private final BooleanSupplier condition; public Sleep(final BooleanSupplier condition, final int timeout) { super(timeout); this.condition = condition; } @Override public final boolean condition() throws InterruptedException { return condition.getAsBoolean(); } public static boolean sleepUntil(final BooleanSupplier condition, final int timeout) { return new Sleep(condition, timeout).sleep(); } } I have tried placing the ConditionalSleep into the OnLoop(), and moved the conditions with it but it still will always click when the random timeout expires at the end of the OnLoop(). I could get the regular sleep method to work but obviously the conditional sleep is preferable and so would appreciate it if someone could point me in the right direction.
×
×
  • Create New...