Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Explv

Scripter II
  • Joined

  • Last visited

Everything posted by Explv

  1. You don't actually NEED the @ Override annotation, it just improves readability and helps the compiler a little bit. It would work just fine without it
  2. Your logic in general is a bit off. It should be as simple as this: If the player has the ingredients for making an uncooked pizza in their inventory: If the bank is open: Close the bank Else: Make uncooked pizzas Else if the player has uncooked pizzas in their inventory: If the bank is open: Close the bank Else If the player is at the range: Cook the pizzas Else: Walk to the range Else if the player is not at the bank: Walk to the bank Else if the bank is not open: Open the bank Else if the inventory is not empty: Deposit All Else if the player has ingredients for uncooked pizza in the bank: Withdraw the ingredients Else if the player has uncooked pizzas in the bank: Withdraw the uncooked pizzas Else: Stop the script If you really want to use states, then from the above logic you would have: BANK, MAKE_UNCOOKED, COOK_PIZZAS Your getState() method should not return null, your script should always be in some kind of state. Also try and use Conditional Sleeps where you can Hopefully this helps: private enum State { BANK, MAKE_UNCOOKED, COOK_PIZZAS } public int onLoop() throws InterruptedException { switch(getState()) { case MAKE_UNCOOKED: if(getBank() != null && getBank().isOpen()) getBank().close(); else makeUncookedPizzas(); break; case COOK_PIZZAS: if(getBank() != null && getBank().isOpen()) getBank().close(); else cookPizzas(); break; case BANK: bank(); break; } return random(100, 150); } private final State getState() { if (hasUncookedIngredients()) return State.MAKE_UNCOOKED; if (hasUncookedPizzas()) return State.COOK_PIZZAS; return State.BANK; } private final void makeUncookedPizzas() { // make the pizzas } private final void cookPizzas() { // check if at range, if not walk there // cook the pizzas } private final void bank() throws InterruptedException { if(getBank() == null) { getWalking().webWalk(bankArea); } else if(!getBank().isOpen()) { openBank(); } else if(!getInventory().isEmpty()) { getBank().depositAll(); } else if(!hasUncookedIngredients() && bankContainsUncookedIngredients()) { withdrawUncookedIngredients(); } else if(!hasUncookedPizzas() && bankContainsUncookedPizzas()) { withdrawCookedPizzas(); } else { stop(); } } private final void openBank() throws InterruptedException { if(getBank().open()) { new ConditionalSleep(5000) { public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); } }
  3. // Using Keyboard class if (getDialogues().isPendingContinuation()) { getKeyboard().typeKey((char) VK_SPACE); } // Using ClientKeyEventHandler class (presses the key instantly) if (getDialogues().isPendingContinuation()) { getBot().getKeyEventHandler().generateBotKeyEvent(KEY_TYPED, System.currentTimeMillis(), 0, VK_UNDEFINED, (char) VK_SPACE); }
  4. Is your IDE set to use Java 8?
  5. Position[] positions = { new Position(1, 2, 3), new Position(4, 5, 6) }; Position closest = Arrays.stream(positions) // Create a Stream<Position> from the Position[] positions .min( // Find the minimum in the Stream using the following Comparator<Position> (p1, p2) -> // For each two Positions in the Stream<Position> Integer.compare( // Return the Integer comparsion of myPosition().distance(p1), // The players distance to the first position myPosition().distance(p2) // And the players distance to the second position ) ) .get(); // .min() returns an Optional<Position> so we use .get() to retrieve the position Or more explicitly: Position[] positions = { new Position(1, 2, 3), new Position(4, 5, 6) }; Stream<Position> positionStream = Arrays.stream(positions); Comparator<Position> positionComparator = new Comparator<Position>() { @ Override public int compare(Position p1, Position p2) { return Integer.compare( myPosition().distance(p1), myPosition().distance(p2) ); } }; Optional<Position> positionOptional = positionStream.min(positionComparator); Position closest = positionOptional.get();
  6. Position closest = Arrays.stream(positions) .min((p1, p2) -> Integer.compare( myPosition().distance(p1), myPosition().distance(p2) )) .get();
  7. You can do: Position[] rockCrabPositions = { new Position(1, 2, 3), new Position(2, 3, 4) }; getWalking().webWalk(rockCrabPositions); Web walking will walk to the closest position in the array
  8. I'm going to have a long bug fixing session this weekend, so I hope to have these issues addressed Which fishing spot was this? I will fix it this weekend if you provide more information, thanks Addressing these this weekend. Will post again when fixed. Sorry (again) for the delay, have been extremely busy. I have free'd up the whole weekend to get all of these issues sorted. Thanks
  9. @@Th3's method is the same one that I use
  10. Yes most people do use gui builders, and I recommend using one. This tutorial is so that people understand the basics, so that they don't just use a gui builder and have no idea what any of the code it generates does.
  11. Kek
  12. Arrays.stream(getInventory().getItems()) .filter(Objects::nonNull) .distinct() .map(item -> String.format("Item: %s Amount: %d", item.getName(), getInventory().getAmount(item.getName()))) .forEach(this::log); The above is equivalent to: // Get all inventory items as an Item[] Item[] inventoryItems = getInventory().getItems(); // Create a Stream of Items from the Item[] Stream<Item> itemStream = Stream.of(inventoryItems); // Remove any Item from the Stream that is null Stream<Item> itemStreamNoNull = itemStream.filter(item -> item != null); // Get only the unique Items from the Stream Stream<Item> uniqueItems = itemStreamNoNull.distinct(); // Convert each Item to a String containing the item name & amount Stream<String> itemTexts = uniqueItems.map(item -> "Item: " + item.getName() + " Amount: " + getInventory().getAmount(item.getName())); // For each String, log it on the console itemTexts.forEach(itemText -> log(itemText)); Hope that helps
  13. You could add a JLabel with an icon set like so: JLabel jLabel = new JLabel(); try { Image image = ImageIO.read(YourClass.class.getResourceAsStream("/resources/image.png")); ImageIcon imageIcon = new ImageIcon(image); jLabel.setIcon(imageIcon); } catch (IOException e) { e.printStackTrace(); } Or you could add a custom JPanel with its paintComponent method overriden: public final class ImagePanel extends JPanel { private final BufferedImage image; public ImagePanel(final String imagePath) { image = ImageIO.read(ImagePanel.class.getResourceAsStream(imagePath)); } @[member=Override] public final void paintComponent(final Graphics g) { super.paintComponent(g); g.drawImage(image, 0, 0, image.getWidth(), image.getHeight(), null); } }
  14. Or you could do something like: Arrays.stream(getInventory().getItems()) .filter(Objects::nonNull) .distinct() .map(item -> String.format("Item: %s Amount: %d", item.getName(), getInventory().getAmount(item.getName()))) .forEach(this::log);
  15. Most editors will insert spaces when you press the tab key, if it doesn't you should set it so that it does. Tabs are generally bad in programming because different editors will insert different amounts of whitespace for a tab. So when viewing your code it can look completely different. That clip from Silicon Valley is bullshit because no one sits there pressing the space key, as their tab key inserts spaces rather than tabs.
  16. The data is retrieved in the format: {"overall":369,"buying":372,"buyingQuantity":108551,"selling":367,"sellingQuantity":121543} Using a URL such as: http://api.rsbuddy.com/grandExchange?a=guidePrice&i=1515 The following method retrieves the "overall" value: private Optional<Integer> getRSBuddyPrice(){ try { URL url = new URL("http://api.rsbuddy.com/grandExchange?a=guidePrice&i=" + id); URLConnection con = url.openConnection(); con.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36"); con.setUseCaches(true); BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream())); String json = br.readLine(); br.close(); Matcher matcher = Pattern.compile("\"overall\"\\s*:\\s*(\\d*)").matcher(json); return matcher.find() ? Optional.of(Integer.parseInt(matcher.group(1))) : Optional.empty(); } catch(Exception e){ e.printStackTrace(); } return Optional.empty(); } If you wanted to retrieve all of these data items, you can just alter this method to instead return a Map<String, Integer>, and instead of just doing: Matcher matcher = Pattern.compile("\"overall\"\\s*:\\s*(\\d*)").matcher(json); return matcher.find() ? Optional.of(Integer.parseInt(matcher.group(1))) : Optional.empty(); Which gets the "overall" value, you can do this for "buying", "selling" etc. and add it to the Map. I will write this up when I get home if you aren't sure how to do it.
  17. Explv replied to Explv's topic in Others
    You're welcome
  18. Explv replied to macalroy's topic in Scripting Help
    Just so you know, because you are running JavaFX from a Swing application you don't need to extend the application class. https://docs.oracle.com/javase/8/javafx/interoperability-tutorial/swing-fx-interoperability.htm
  19. Explv replied to macalroy's topic in Scripting Help
    your turn
  20. Explv replied to macalroy's topic in Scripting Help
    Your turn
  21. Explv replied to regnivon's topic in Scripting Help
    I c, @op have you tried using getBank().open() ?
  22. Explv replied to regnivon's topic in Scripting Help
    Well isn't it a deposit box not a bank at the barbarian outpost?
  23. I'll fix it when I get home, I am away on holiday at the moment.
  24. I'll take a look at it this weekend, thanks

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.