Jump to content

Explv

Scripter II
  • Posts

    2314
  • Joined

  • Last visited

  • Days Won

    6
  • Feedback

    100%

Everything posted by Explv

  1. I recommend you learn Java first, at least the basics. Follow some tutorials, write some programs, then come back to scripting. Things like syntax errors should be something that you can solve by yourself There are too many posts in the scripting help section where the OP has a problem that would be solved if he/she just spent some time learning Java.
  2. If you just want to walk there then the simplest method is: private final Area[] BANKS = { Banks.AL_KHARID, Banks.ARDOUGNE_NORTH }; // add the rest public void walkToClosestBank(){ getWalking().webWalk(BANKS); }
  3. Explv

    Good deal?

    Meh, would rather spend £25 to not go through a cancer website. Your money though
  4. Explv

    Good deal?

    Its like £140 on amazon, just buy it from there... https://www.amazon.co.uk/Intel-4460-Processor-3-2GHz-Cache/dp/B00JIJUBAS/ref=sr_1_1?ie=UTF8&qid=1462474440&sr=8-1&keywords=intel+i5+4460
  5. You can just do: Optional<RS2Object> closestObj = getObjects() .getAll() .stream() .min((o1, o2) -> Integer.compare( o1.getPosition().distance(myPosition()), o2.getPosition().distance(myPosition()) ));
  6. It does indeed have pointless filters, and you will also end up with NullPointerExceptions
  7. To avoid having to check the Optional etc. you could do: NPC monster = npcs.closest(n -> n.getName().equals(NAME) && AREA.contains(n) && n.getLevel() < 30);
  8. Explv

    Explv's Walker

    The issue is fixed. The script will work again when the SDN is next updated.
  9. Explv

    Explv's Walker

    Okay thanks, will fix it now.
  10. if(getGroundItems().closest("whatever") != null){ return State.PICK_UP_ITEM; } else if(getNPCs().closest(npcChompBirdAlive) != null){ return State.KILL_CHOMPY; }
  11. Explv

    Explv's Walker

    Don't you need to use shortcuts with climbing boots to get there? I would have to add quite a few things to the script to make that work.
  12. import org.osbot.rs07.api.Widgets; import org.osbot.rs07.api.filter.Filter; import org.osbot.rs07.api.ui.RS2Widget; import java.util.Optional; public class CachedWidget { private int rootID = -1, secondLevelID = -1, thirdLevelID = -1; private String[] widgetTexts; private Filter<RS2Widget> filter; public CachedWidget(final int rootID, final int secondLevelID){ this.rootID = rootID; this.secondLevelID = secondLevelID; } public CachedWidget(final int rootID, final int secondLevelID, final int thirdLevelID){ this.rootID = rootID; this.secondLevelID = secondLevelID; this.thirdLevelID = thirdLevelID; } public CachedWidget(final int rootID, final String... widgetTexts) { this.rootID = rootID; this.widgetTexts = widgetTexts; } public CachedWidget(final String... widgetTexts){ this.widgetTexts = widgetTexts; } public CachedWidget(final int rootID, final Filter<RS2Widget> filter) { this.rootID = rootID; this.filter = filter; } public CachedWidget(final Filter<RS2Widget> filter) { this.filter = filter; } public Optional<RS2Widget> getParent(final Widgets widgets) { return get(widgets).map(widget -> { if (widget.isSecondLevel()) { return widget; } return widgets.get(widget.getRootId(), widget.getSecondLevelId()); }); } public Optional<RS2Widget> get(final Widgets widgets){ if(rootID != -1 && secondLevelID != -1 && thirdLevelID != -1) { return Optional.ofNullable(widgets.get(rootID, secondLevelID, thirdLevelID)); } else if(rootID != -1 && secondLevelID != -1) { return getSecondLevelWidget(widgets); } else if (widgetTexts != null) { return getWidgetWithText(widgets); } else { return getWidgetUsingFilter(widgets); } } private Optional<RS2Widget> getSecondLevelWidget(final Widgets widgets){ RS2Widget rs2Widget = widgets.get(rootID, secondLevelID); if(rs2Widget != null && rs2Widget.isThirdLevel()){ thirdLevelID = rs2Widget.getThirdLevelId(); } return Optional.ofNullable(rs2Widget); } private Optional<RS2Widget> getWidgetWithText(final Widgets widgets){ RS2Widget rs2Widget; if (rootID != -1) { rs2Widget = widgets.getWidgetContainingText(rootID, widgetTexts); } else { rs2Widget = widgets.getWidgetContainingText(widgetTexts); } setWidgetIDs(rs2Widget); return Optional.ofNullable(rs2Widget); } private Optional<RS2Widget> getWidgetUsingFilter(final Widgets widgets) { RS2Widget rs2Widget; if (rootID != -1) { rs2Widget = widgets.singleFilter(rootID, filter); } else { rs2Widget = widgets.singleFilter(widgets.getAll(), filter); } setWidgetIDs(rs2Widget); return Optional.ofNullable(rs2Widget); } private void setWidgetIDs(final RS2Widget rs2Widget) { if (rs2Widget == null) { return; } rootID = rs2Widget.getRootId(); secondLevelID = rs2Widget.getSecondLevelId(); if (rs2Widget.isThirdLevel()) { thirdLevelID = rs2Widget.getThirdLevelId(); } } @Override public String toString() { return rootID + ", " + secondLevelID + ", " + thirdLevelID; } } Usage: private final CachedWidget exampleWidget = new CachedWidget("Blah"); public void someMethod() { exampleWidget.get(getWidgets()).ifPresent(widget -> widget.interact()); }
  13. Are you using an IDE? It should highlight any syntax errors you have
  14. Save this as a .bat file for example osbot.bat: cd C:/Users/%username% for /f "delims=" %%x in ('dir /s /od /b OSBot*.jar') do set recent=%%x java -jar "%recent%" echo %recent% pause Run the .bat file (By double clicking it) This should launch OSBot from CMD. Try to click on the launch button, copy and paste any errors that show up in CMD here. Alternatively, feel free to PM me and I can fix it for you
  15. Maybe something like this? Pseudo Code: If we are chopping a tree: If we have not found another tree: Find another tree Else if we are not hovering over the other tree: Hover over the other tree Else: Chop a tree import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "", name = "", info = "", version = 0.1, logo = "") public class WoodCutter extends Script { private enum State{ CHOPPING, HOVERING } private RS2Object currentTree; private RS2Object hoverTree; private State getState(){ if(currentTree != null && currentTree.exists() && myPlayer().isAnimating()) return State.HOVERING; return State.CHOPPING; } @Override public int onLoop() throws InterruptedException { switch (getState()){ case CHOPPING: chop(); break; case HOVERING: hoverNextTree(); break; } return random(200, 300); } private void chop(){ currentTree = getObjects().closest("Tree"); if(currentTree != null){ currentTree.interact("Chop down"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); } } private void hoverNextTree(){ if(hoverTree == null || !hoverTree.exists()) { hoverTree = getObjects().closest(obj -> obj.getName().equals("Tree") && obj != currentTree); } else if(!getMouse().isOnCursor(hoverTree)) { hoverTree.hover(); } } } That would only hover over the same tree that you are cutting (the closest one)
  16. Or you know, he could learn Java pls baws
  17. The only reason you will get that errors is because your syntax is incorrect. Doesn't necessarily mean you are missing a ; or have incorrect (). It just means your syntax is fucked Learn Java pls baws
  18. It's likely that in your use cases you will want to be using interact() on whatever you are trying to click. However if you really need to click on a x,y coordinate you will need to use the move method to move the mouse to the correct position, followed by the click method. Or use the click method with a Mouse Destination passed as a parameter. Also, I don't understand why you are trying to click on an Area? If you are trying to walk to an area / position you should use the walking methods
  19. Jesus Christ. It's not like it tells you what the error is or anything.
  20. It might work but you are still doing a lot of things incorrectly
  21. Edited from original comment. Pls learn Java. Why are you doing this in onLoop ?: switch (state) { case CHOP: new Chop(this); break; case DROP: new Drop(this); break; case IN_COMBAT: new InCombat(this); default: break; }
  22. You probably haven't initialised 'state' Programming 101 pls pls
×
×
  • Create New...