Jump to content

Explv

Scripter II
  • Posts

    2314
  • Joined

  • Last visited

  • Days Won

    6
  • Feedback

    100%

Everything posted by Explv

  1. I have tested it on two different Windows 10 systems and it works 100% fine. But I will update it to make it harder for the user to break
  2. I have pushed a fix for this, it will be available the next time the SDN is updated.
  3. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 0 < 28
  4. Explv

    Help!

    Something like: graphics.drawPolygon(treePosition.getPolygon(getBot()))
  5. Just a heads up, you might want to ask Alek before you release, and also check that having OSBot's logo on there is ok
  6. Sorri boss, I don't follow the software development section
  7. I made this back in June http://osbot.org/forum/topic/100554-explvs-osbot-manager/ I can update it if you find any bugs / want new features
  8. Follow some Java tutorials until you have a good understanding of the language, then start writing scripts
  9. public abstract class Node { protected final MethodProvider methods; public Node(final MethodProvider methods) { this.methods = methods; } public abstract boolean validate() throws InterruptedException; public abstract void execute() throws InterruptedException; } public final class ConcreteNode extends Node { public ConcreteNode(final MethodProvider methods) { super(methods); } @ Override public final boolean validate() throws InterruptedException { return false; } @ Override public final void execute() throws InterruptedException { } } public final class NodeExecutor { private final Node[] nodes; public NodeExecutor(final Node... nodes) { this.nodes = nodes; } public final void execute() throws InterruptedException { for (final Node node : nodes) { if(node.validate()) node.execute(); } } } @ScriptManifest(author = "", name = "", info = "", logo = "", version = 0.1) public final class ExampleScript extends Script { private NodeExecutor nodeExecutor; @ Override public final void onStart() { ConcreteNode concreteNode = new ConcreteNode(this); ConcreteNode anotherConcreteNode = new ConcreteNode(this); nodeExecutor = new NodeExecutor(concreteNode, anotherConcreteNode); } @ Override public final int onLoop() throws InterruptedException { if(nodeExecutor != null) nodeExecutor.execute(); return random(100, 150); } }
  10. Well logging out is simple, you just do: getLogoutTab().logOut(); There is not, however, anything in the API for logging in. The main issue with logging back in is the automatic login event. If you start a script using a runescape account stored in the settings, whenever you logout, it will automatically try to log back into that same account. To prevent the automatic login event from triggering you can either: Login to the first account manually, then run the script, so that when you logout the login event won't be triggered (it doesn't have the account information to do it). Write your own method to disable the login event (this is a bit trickier) To log in to another account you can use: The Client class to determine when you are logged out The Client class to determine which stage of the login protocol you are at The Mouse class to click on the Existing users button The Keyboard class to enter the account details Hopefully you can figure it out from that
  11. This is also not a scripting question, close thread.
  12. Well he isn't randomizing it, he's just iterating over the inventory and dropping the items in order? And I don't think randomizing it would make any difference, and would probably be slower lol
  13. How do you know it was the built in drop method that got you banned And just so you know, all the built in method does is: Filter nameFilter = new NameFilter("Trout"); for (int slot = 0; slot < 28; slot ++) { Item itemInSlot = getInventory().getItemInSlot(slot); if(itemInSlot != null && nameFilter.match(itemInSlot)) { getInventory().interact(slot, "Drop"); sleep(gRandom(75, 25)); } } So I fail to see how what you are doing will be any different.
  14. Show us the code? And by the way for dropping you just probably just use getInventory().dropAll(itemName);
  15. In your Trading, InTrade and Wait classes you are using the Script variable 's' . This variable is never initialised. What you should be using is 'sA' which is the Script variable set in your Abstract Node class: package Scripts; import org.osbot.rs07.script.Script; public abstract class Node { protected final Script sA; // <------ You should be using this variable public Node(final Script sA){ this.sA = sA; } public String status(){ return ""; } public abstract boolean validate() throws InterruptedException; public abstract boolean execute() throws InterruptedException; } Here is an example of where you are using the wrong variable: package nodes; import org.osbot.rs07.api.Inventory; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.script.MethodProvider; import org.osbot.rs07.script.Script; import Scripts.Node; import data.Data; public class Trading extends Node{ Data c = new Data(); private Script s; // <-------- You shouldn't have another Script variable here @SuppressWarnings("unused") private Player me; @SuppressWarnings("unused") private Inventory inv; @SuppressWarnings("unused") private Data data; public Trading(Script sA) { super(sA); // <--------------- You are already setting the Script variable sA here } // ... Rest of your code }
  16. 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
  17. 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(); } }
  18. // 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); }
  19. 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();
  20. Position closest = Arrays.stream(positions) .min((p1, p2) -> Integer.compare( myPosition().distance(p1), myPosition().distance(p2) )) .get();
  21. 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
×
×
  • Create New...