Jump to content

Explv

Scripter II
  • Posts

    2314
  • Joined

  • Last visited

  • Days Won

    6
  • Feedback

    100%

Everything posted by Explv

  1. Perhaps you should take a look at the debugging console. You can find it under settings -> show logger. You can then determine your error from the output. Probably a NPE. Your logic and code structure could also use some improvement if(!myPlayer().isAnimating() && !myPlayer().isMoving()){ RS2Widget spinMenu = getWidgets().get(); // Whatever you do to get the spin menu if(spinMenu == null || !spinMenu.isVisible()){ wheel.interact("Spin"); sleep(random(700, 3000)); } else { spinMenu.interact("Make X"); } }
  2. If you have a lot of programming experience in C# you will not find the move to Java difficult at all. They are similar languages. There are still gaps in the selection of scripts that you can fill, and shitty scripts that can be improved. The API does not take a huge time commitment to understand, and there are tutorials out there to help you. It's really up to you if it is worth it
  3. See the first part of the solution i posted, and substitute "Feather" for "Bones" .
  4. private long feathersCollected; private long prevInvCount; @Override public void onStart(){ // initialise previous inventory count to current inventory count prevInvCount = getInventory().getAmount("Feather"); } @Override public int onLoop(){ long invCount = getInventory().getAmount("Feather"); // get number of feathers in inventory // If the amount of feathers has increased, add the change to total feathers collected if(invCount > prevInvCount) feathersCollected += (invCount - prevInvCount); // Update previous inventory count to current count prevInvCount = invCount; ... } (This accounts for if you are banking, or if you are disposing of the items e.g. burying bones) If you aren't banking: private long startFeatherCount; @Override public void onStart(){ startFeatherCount = getInventory().getAmount("Feather"); } private long getFeathersCollected(){ return getInventory().getAmount("Feather") - startFeatherCount; } If you want to make it so that the updating of the count is not paused by the bot's actions, you can move the code in onLoop to the onPaint method. However you should ensure that you limit the amount of times it is called per second.
  5. Explv

    Banned

    he seemed like a cool guy dickhead ftfy.
  6. You should take a look at using a state based system for your scripts. That code could potentially have some bugs in it. For example, what happens if the bank opening process gets interrupted? Your script will just walk back to the fishing spot without having retrieved a lobster pot.
  7. RS2Object closestDoor = getObjects().closest(true, obj -> obj.getName().equals("Door") && obj.hasAction("Open")); if(closestDoor != null) closestDoor.interact("Open");
  8. Try this: http://osbot.org/forum/topic/87717-fixing-osbot-not-starting/ http://osbot.org/forum/topic/87717-fixing-osbot-not-starting/ http://osbot.org/forum/topic/87717-fixing-osbot-not-starting/ http://osbot.org/forum/topic/87717-fixing-osbot-not-starting/
  9. See my updated post, there are more errors
  10. Fishing spot is an NPC. Also use the built in bank method: if(!getBank().isOpen()){ getBank().open(); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); } else if (!inventory.contains("Small fishing net")){ getBank().withdraw("Small fishing net", 1); } else { getBank().depositAllExcept("Small fishing net"); } Also in your getState() method, State.BANK will not return if you have a full inventory. You only bank when your inventory is empty. if (inventory.isEmpty() && !inventory.contains("Small fishing net")){ return State.BANK; } It should be: if (inventory.isFull() || !inventory.contains("Small fishing net")){ return State.BANK; } As a result of this, your WAIT state is redundant: private enum State { FISH, BANK } private State getState() { if (inventory.isFull() || !inventory.contains("Small fishing net")){ return State.BANK; } return State.FISH; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case FISH: NPC spot = getNpcs().closest("Fishing spot"); if (spot != null) { spot.interact("Net"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); } break; case BANK: if(!getBank().isOpen()){ getBank().open(); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); } else if (!inventory.contains("Small fishing net")){ getBank().withdraw("Small fishing net", 1); } else { getBank().depositAllExcept("Small fishing net"); } break; } return random(200, 300); } To prevent spam clicking you may then want to wrap your onLoop code with a condition, where the script does nothing if the player is animating or moving: private enum State { FISH, BANK } private State getState() { if (inventory.isFull() || !inventory.contains("Small fishing net")){ return State.BANK; } return State.FISH; } @Override public int onLoop() throws InterruptedException { if(!myPlayer().isAnimating() && !myPlayer().isMoving()){ switch (getState()) { case FISH: NPC spot = getNpcs().closest("Fishing spot"); if (spot != null) { spot.interact("Net"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); } break; case BANK: if(!getBank().isOpen()){ getBank().open(); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); } else if (!inventory.contains("Small fishing net")){ getBank().withdraw("Small fishing net", 1); } else { getBank().depositAllExcept("Small fishing net"); } break; } } return random(200, 300); } You will also need to handle the case where the bank does not contain a fishing net. You may also want to include paths to and from the bank and fishing spot: Area fishingArea = new Area(0, 0, 0, 0); // Define this Area bankArea = new Area(0, 0, 0, 0); // Define this Position[] pathToBank = new Position[]{ }; // Define this Position[] pathToSpot = new Position[]{ }; // Define this private enum State { FISH, BANK, WALK_TO_BANK, WALK_TO_SPOT } private State getState() { if (inventory.isFull() || !inventory.contains("Small fishing net")){ if(bankArea.contains(myPosition())) return State.BANK; return State.WALK_TO_BANK; } if(!fishingArea.contains(myPosition())) return State.WALK_TO_SPOT; return State.FISH; } @Override public int onLoop() throws InterruptedException { if(!myPlayer().isAnimating() && !myPlayer().isMoving()){ switch (getState()) { case FISH: NPC spot = getNpcs().closest("Fishing spot"); if (spot != null) { spot.interact("Net"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); } break; case BANK: if(!getBank().isOpen()){ getBank().open(); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); } else if (!inventory.contains("Small fishing net")){ if(getBank().contains("Small fishing net")) getBank().withdraw("Small fishing net", 1); else stop(true); } else { getBank().depositAllExcept("Small fishing net"); } break; case WALK_TO_BANK: getLocalWalker().walkPath(pathToBank); break; case WALK_TO_SPOT: getLocalWalker().walkPath(pathToSpot); break; } } return random(200, 300); }
  11. If you want to smelt a specific quantity you can do something like: // Select smelt X option for Bronze getWidgets().getWidgetContainingText("Bronze").interact("Smelt X Bronze"); // Sleep until the widget "Enter amount:" is visible (or for 5 seconds) new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { RS2Widget amountWidget = getWidgets().get(162, 32); return amountWidget != null && amountWidget.isVisible(); } }.sleep(); // Check that the widget is visible, if it is type the number 23 and enter RS2Widget amountWidget = getWidgets().get(162, 33); if(amountWidget != null && amountWidget.isVisible()) getKeyboard().typeString("23");
  12. Yes something like: RS2Widget bronzeWidget = getWidgets().getWidgetContainingText("Bronze"); if(bronzeWidget != null && bronzeWidget.isVisible()) bronzeWidget.interact("Smelt 10 Bronze");
  13. You will want to use widgets.
  14. Its unnoticeable :P And it is less convenient for the user to manually select the rocks they want to mine. Either way... both viable solutions
  15. Ok I get you now. The user selects the rock and you store it. Still... 18ms.... meh
  16. Have you not considered the case of an AIO miner where the location is not fixed? It takes far longer to record the positions of every rock in the game than it does to record 1 colour per rock. Checking "every rock in your neighborhood" takes such a short amount of time that optimising it is pointless. If you are finding a rock based on its position, you are still checking "every rock in your neighborhood" to find the object at that position. The solution I posted is a global solution, it doesn't require recording rock positions, and it doesn't require recording IDs. Just sayin'
  17. I don't really understand what you are saying... But if you think there is a better method that is as concise as this one, I would be interested to see it.
  18. This takes long? Care to elaborate?
  19. import org.osbot.rs07.api.model.Entity; public enum Rock { CLAY(new short[]{6705}), COPPER(new short[]{4645, 4510}), TIN(new short[]{53}), IRON(new short[]{2576}), SILVER(new short[]{74}), COAL(new short[]{10508}), GOLD(new short[]{8885}), MITHRIL(new short[]{-22239}), ADAMANTITE(new short[]{21662}), RUNITE(new short[]{-31437}); private short[] colours; Rock(final short[] colours) { this.colours = colours; } public boolean hasOre(final Entity rockEntity) { if (rockEntity.getDefinition() == null) { return false; } short[] colours = rockEntity.getDefinition().getModifiedModelColors(); if (colours == null) { return false; } for (short rockColour : this.colours) { for (short entityColour : colours) { if (rockColour == entityColour) { return true; } } } return false; } } Usage: RS2Object tinRock = getObjects().closest(obj -> Rock.TIN.hasOre(obj));
  20. That would be a whole lot simpler with configs. Using dialogs to determine progress seems like it could be very unreliable. Also does the log "Does this even work?" show up? You could always use the widget values e.g. getWidgets().get(int parent, int child);
  21. Try RS2Widget w = getWidgets().getWidgetContainingText("Click to continue"); if (w != null && w.isVisible()) { log("a"); w.interact(); } Just put it at the start of your onLoop. You don't really need to check if you have just retrieved a bar of bronze, you should just always check if continue needs clicking, and click it if it does. By the way a simpler way of determining if you have retrieved a bar of bronze would be to do: if(getInventory().contains("Bronze bar"))
  22. Runescape is updated at least once a week, and therefore OSBot is updated at least once a week. So not possibru
  23. Whoa GJ buddy, you're really smurt. Here have a cookie Moron :xdoge:
×
×
  • Create New...