Everything posted by Explv
- Explv's Walker
-
Super new to Java, bot works but won't pick up items.
if(getGroundItems().closest("whatever") != null){ return State.PICK_UP_ITEM; } else if(getNPCs().closest(npcChompBirdAlive) != null){ return State.KILL_CHOMPY; }
-
[RQ]Updated video tutorial maybe?
I'll make you one boss
-
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.
-
A Better Way To Handle Widgets (CachedWidget)
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()); }
-
Errors out of know where
Are you using an IDE? It should highlight any syntax errors you have
-
Client won't let me launch after downloading Java 8
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
-
Move mouse while waiting for tasks to complete
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)
-
Error Using GUI [Client Crashing]
Or you know, he could learn Java pls baws
-
Errors out of know where
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
-
Would someone mind showing me an example of Mouse.click()?
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
-
Errors out of know where
Jesus Christ. It's not like it tells you what the error is or anything.
-
Error Using GUI [Client Crashing]
It might work but you are still doing a lot of things incorrectly
-
Error Using GUI [Client Crashing]
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; }
-
Error Using GUI [Client Crashing]
You probably haven't initialised 'state' Programming 101 pls pls
-
Error Using GUI [Client Crashing]
Well that is where your error is then.. Not the GUI. Pls learn how 2 debug pls pls
-
Error Using GUI [Client Crashing]
Probably something else in your code. You should really learn what a NullPointerException is though...
-
help,webwalk
Perhaps you should explain the issue you are having. "webWalk, black line Do not know why" doesn't make much sense. Also, please use the code formatter when submitting code. It is the button that looks like < >
-
Not Dropping All
If you want to add sleeps then you can do something like: private void dropAll(final String name) throws InterruptedException { for(final Item item : getInventory().getItems()){ if(item.getName().equals(name) && item.interact("drop")){ sleep(random(200, 300)); } } } But I am pretty sure that getInventory().dropAll(itemName) already does sleep a random amount from 25ms to 75ms in between drops.
-
Not Dropping All
1. You should use .equals() when comparing Strings. == Compares references not the values. 2. You should just use: getInventory().dropAll(itemName); 3. The animating check should not be in that method / doesn't really have any use for determining when you should drop items lol
-
Not Dropping All
Well your code doesn't make much sense... Why would you call dropAll, a function which DROPS ALL on every single Log in your inventory? It should just be: if (sI.getInventory().isFull()) { sI.getInventory().dropAll("Logs"); }
-
Need some wisdom
Why don't you just do: if(npc.getPosition().distance(myPosition()) <= 3) // if npc is less than or equal to 3 tiles away
-
Explv's AIO [13 skill AIO in 1 script]
Hmm, it's not a bad idea, I will think about implementing it. If I do, I will still keep the current tasks, but add this as a new 'custom task' type.
-
Explv's AIO [13 skill AIO in 1 script]
What other stopping conditions / goals would you want?
-
how to place a sleep when smelting?
C_O_R_R_E_C_T