Everything posted by Explv
-
My node class! everything looks clean but not start -_-
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 problems with my script
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(); } }
-
skip dialogues with spacebar
// 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); }
-
[combat]NPC filtering pls halp
Is your IDE set to use Java 8?
-
Finding the closest position in a list to my position
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();
-
Finding the closest position in a list to my position
Position closest = Arrays.stream(positions) .min((p1, p2) -> Integer.compare( myPosition().distance(p1), myPosition().distance(p2) )) .get();
-
Finding the closest position in a list to my position
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
-
Explv's AIO [13 skill AIO in 1 script]
Yes
-
Explv's AIO [13 skill AIO in 1 script]
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
-
Inventory Item Drag
@@Th3's method is the same one that I use
-
Explv's Dank GUI Tutorial
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.
- CzarRangingGuild
-
Fetch - Inventory Items List [ NOOB HELP ]
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
-
GUI Image problem
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); } }
-
Fetch - Inventory Items List [ NOOB HELP ]
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);
-
Tabs or Spaces
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.
-
GE Data (get price etc. by item name) no external libraries required
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.
- Explv's Walker
-
JavaFX
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
- JavaFX
- JavaFX
-
Script help
I c, @op have you tried using getBank().open() ?
-
Script help
Well isn't it a deposit box not a bank at the barbarian outpost?
-
Explv's AIO [13 skill AIO in 1 script]
I'll fix it when I get home, I am away on holiday at the moment.
-
Explv's AIO [13 skill AIO in 1 script]
I'll take a look at it this weekend, thanks