-
Posts
262 -
Joined
-
Last visited
-
Feedback
100%
Posts posted by Hybris
-
-
4 hours ago, Derogan said:
@Hybris Thank you, didin't see that semi-colon. I will look in to it. And try to make changes in the if statement.
Also I understand the conditional sleep with a return and a time out. As I understand this conditional sleep is executed untill a return matches the condition or timeout passes. But what wuold the interval mean. For example in the post you shared:
public static boolean sleepUntil(final BooleanSupplier condition, final int timeout, final int interval) { return new Sleep(condition, timeout, interval).sleep(); }
Np let me know what the result is
& I'm not exactly sure but I think the interval is how often it gets checked; like for example interval is 1000: the condition gets checked every second
-
On 8/11/2019 at 2:36 PM, Hybris said:
Online!
-
if (target.interact("Attack")) ;
The ";" shouldn't be there, also look into Lambda expressions for the conditional sleep: https://osbot.org/forum/topic/127193-conditional-sleep-with-lambda-expressions/
if (!myPlayer().isUnderAttack() && myPlayer().getInteracting() == null && targetTile != null)
I didn't look very well at the code but I'm pretty sure the mistake is in here.
Fixing the above mistake might fix this too, but it's probably still detecting that your player is under attack or interacting with something when it gets to this point & thus skipping the loot function. -
4 hours ago, bubbajim said:
I used double webWalking because sometimes it walks by the dark wizards so i figured if i set an intermediate point it will always stick to the Varrock west path. Also i tried using normal walk but it was really buggy for me. It would walk to a tile and just spam click it and not go to the next tile in the path i defined. I'm not sure why this is happening? Maybe i'm using it wrong?
Did you use walking.walk() or walking.walkPath()? if using the walkPath it's probably because your positions are too far apart from eachother, try to place them closer to eachother
If you don't mind performance (like you don't want to run a botfarm of them) it doesn't really matter to use the (double) webwalk but if you do it's probably better to make a solid walkPathFeel free to post a reworked version of the script below & I'll take another look at it, I'm not 100% confident in my Java skills & might not be using all the best practices so it's probably a good idea to have another pair of eyes on it.
- Hybris -
On 8/11/2019 at 2:36 PM, Hybris said:
Online!
-
On 8/11/2019 at 2:36 PM, Hybris said:
Online!
-
13 hours ago, bubbajim said:
public class BubbasBerries extends Script { @Override public int onLoop() throws InterruptedException { if (getInventory().getAmount(753) == currentInventoryCapacity + 1) { berriesCounter += 1; //Not really important but you can change this to berriesCounter++; } //Using the name instead of the ID makes it way more readable & gives the same results. Also names will (or at least should) never change. currentInventoryCapacity = getInventory().getAmount(753); //You're initializing a bunch of things although you're only using them once. Settings settings = getSettings(); //You can just use "settings.whateverFunction() or getSettings.whateverFunction(). No need to initliaze it int runEnergy = settings.getRunEnergy(); if (runEnergy > 50 && !settings.isRunning()) { settings.setRunning(true); } //You can rewrite the ENTIRE block above to this line: //if(settings.getRunEnergy() > 50 && !settings.isRunning()) settings.setRunning(true) if (getInventory().isFull()) { //double webWalking to a position? You could replace this to just webwalking to the bank area. //Also if there are no obstaclesdon't use webwalking, use the normal walk instead as it has better performance getWalking().webWalk(pathInBetween); getWalking().webWalk(pathToBank); getBank().open(); sleep(random(1500,2500)); getBank().depositAll(); //Use Lambda Expressions for conditional sleeps instead, it looks way cleaner. will link below. //Example for this one would be: Sleep.sleepUntil(() -> getInventory().isEmpty(), 10000); new ConditionalSleep(10000) { @Override public boolean condition() { return getInventory().isEmpty(); } }.sleep(); } Entity cadavaBush = getObjects().closest(23625, 23626); if (bankArea.contains(myPosition())) { //double webwalking again, any reason? getWalking().webWalk(pathInBetween); getWalking().webWalk(pathFromBank); } else if (cadavaBush != null && cadavaBush.interact("Pick-from")) { //You're only using these values once, no need to initialize them. //Use this instead: Position cadavaBushPosition = new Position(cadavaBush.getX(), cadavaBush.getY()); int cadavaBushX = cadavaBush.getX(); int cadavaBushY = cadavaBush.getY(); Position cadavaBushPosition = new Position(cadavaBushX, cadavaBushY, 0); if (cadavaBush.getId() == 23625) { //Use Lambda Expression for CS new ConditionalSleep(10000) { @Override public boolean condition() { return getObjects().closest(o -> o.getPosition().equals(cadavaBushPosition)).getId() == 23626; } }.sleep(); } else if (cadavaBush.getId() == 23626) { //Use Lambda Expression for CS new ConditionalSleep(10000) { @Override public boolean condition() { return getObjects().closest(o -> o.getPosition().equals(cadavaBushPosition)).getId() == 23627; } }.sleep(); } } else { if (endWorld == currentWorld) { currentWorld = startWorld; } currentWorld -= 1; getTabs().open(Tab.LOGOUT); getWorlds().hop(currentWorld); //Use conditional sleep, you can use 'getClient().getLoginState().equals(Client.LoginState.LOGGED_IN))' to check if you are logged in sleep(random(2000,3000)); getTabs().open(Tab.INVENTORY); new ConditionalSleep(10000) { @Override public boolean condition() { return getWorlds().getCurrentWorld() == currentWorld; } }.sleep(); } return random(300, 600); } @Override public void onPaint(Graphics2D g) { final long runTime = (System.currentTimeMillis() - startTime); String hms = String.format("%02d:%02d:%02d", TimeUnit.MILLISECONDS.toHours(runTime), TimeUnit.MILLISECONDS.toMinutes(runTime) % TimeUnit.HOURS.toMinutes(1), TimeUnit.MILLISECONDS.toSeconds(runTime) % TimeUnit.MINUTES.toSeconds(1)); Font font = new Font("Open Sans", Font.PLAIN, 12); g.setFont(font); g.setColor(Color.green); g.drawString("Time elapsed: " + hms, 15, 300); g.drawString("Berries picked: " + berriesCounter, 15, 315); } }
I added a bunch of comments that will hopefully help you on your way
- Hybris- 1
-
On 8/11/2019 at 2:36 PM, Hybris said:
Online!
-
On 8/12/2019 at 1:11 PM, Hybris said:
-
On 8/11/2019 at 2:36 PM, Hybris said:
Online!
-
On 8/8/2019 at 11:19 PM, Hybris said:
Online!
-
On 8/7/2019 at 10:10 AM, Hybris said:
Online!
-
On 8/11/2019 at 2:36 PM, Hybris said:
Online!
-
On 6/11/2019 at 12:20 AM, daddybigspec said:
doesn't need much else don't just must be made under a email that I can have acess to
Hit me up on my discord, I have a couple for sale
-
22 hours ago, Hybris said:
Online!
-
9 hours ago, Hybris said:
Online!
-
-
On 8/9/2019 at 9:11 PM, Hybris said:
Bump
-
-
-
-
-
-
Error when interacting with item in inventory
in Scripting Help
Posted
Open the inventory before trying to eat