![](https://osbot.org/forum/uploads/set_resources_22/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
![](https://osbot.org/forum/uploads/set_resources_22/84c1e40ea0e759e3f1505eb1788ddf3c_default_photo.png)
Jebemvammater
-
Posts
12 -
Joined
-
Last visited
-
Feedback
0%
Posts posted by Jebemvammater
-
-
4 hours ago, Nbacon said:
Becuse walking is not an animation.
if ( !myPlayer().isMoving() && tree != null && tree.interact("Chop down")) {
Thanks a lot, Nbacon - I inserted that condition in my code above, but the thing was still spamclicking.
I looked at the thread you referenced, and the video in there.
Tried the Lambda thing from Explv's thread below - bot is still clicking on trees more than once ... I really don't seem to understand it.
Entity tree = getObjects().closest("Tree"); if (tree != null && tree.interact("Chop down") && !myPlayer().isMoving()) { Sleep.sleepUntil(() -> !myPlayer().isAnimating(), 5000); }
Could you tell me what's wrong in my understanding of the code:
1) Defines the object tree as closest tree to the player
2) The if statement works both to initiate the chopping, but also starts the sleep if the tree exists, if the interaction returned a true (so this means my player started chopping already or is this from the point that it clicked once?) and if my player is not moving
3) The sleep runs for either 5s or until my played has stopped chopping
Really would appreciate any help on this - I've actually read through all threads on sleep on here and have a science degree but seems I'm a brainlet for scripting
-
This thread is perfect for me - a complete noob who doesn't even get conditional sleep. Can someone tell me why the script below leads to my account spam-clicking trees while running towards them, and only starts sleeping only I'm chopping? How should conditional sleeps be initiated and stopped?
package core; import java.awt.Graphics2D; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.util.function.BooleanSupplier; @ScriptManifest(author = "You", info = "My first script", name = "Tree chopper", version = 0, logo = "") public class Console extends Script { @Override public void onStart() { log("Let's get started!"); } @Override public int onLoop() throws InterruptedException { Entity tree = getObjects().closest("Tree"); if (tree != null && tree.interact("Chop down")) { new ConditionalSleep(2000) { @Override public boolean condition() throws InterruptedException { return !myPlayer().isAnimating(); } }.sleep(); } return 500; } @Override public void onExit() { log("This is a wood chopper!"); } @Override public void onPaint(Graphics2D g) { } }
6 hours ago, Wolk said:Just a scenario:
Let's say you are fletching logs. You implement a conditional sleep to check if your inventory doesn't contain anymore logs, or you're not animating anymore. When the conditional sleep has been met, you add a random sleep because it's not human-like to instantly bank for new logs, all the time. This is because humans tend to AFK fletching and it can be a couple of seconds before the human notices the inventory with logs has been fully fletched.
How would a method for this look like (in code)? What are the arguments to start/stop the sleeps?
Thanks a lot mates
-
Could I get a trial please?
-
Perfect BlastFurnace, please! Thank you very much!
-
Yikes missed the trial - it's just 24h after you granting it, correct?
Could I get another one?
-
Could I get a trial please? Thanks!
-
Could I have a trial please?
-
Could I have a trial please?
-
-
Tried with avantoe and ranarr
-
Just logs out when trying to make unfinished potions (set to until running out of supplies, even though supplies are in the bank)
Conditional Sleep
in Scripting Help
Posted
Thanks a lot for taking the time, my dude. I think I'm slowly getting there - but shouldn't it be
myPlayer().isAnimating() && myPlayer().isMoving() && tree != null && tree.interact("Chop down"))
so without the !negation - i.e. if
character is going to sleep? I don't really understand now why I had the !myPlayer().isAnimating and !myPlayer().isMoving() to start with (because I want to start checking the sleep if I am walking/interacting, not if I'm not?)
But now I don't understand the sequence anymore - why do it in this sequence and not other way around?
Anyways - employing the line above signifiantly reduced the clicking - but at times, it clicks on the tree again just after having finished to walk to it but prior to starting the chopping animination. Is there any way to limit the tree.interact to just once before checking sleep conditions?
Or can I increase the "return" value at the end of my entire onLoop function, so it runs "slower" i.e. less clicking?
Sry I have two science degrees but never had any programming apart from 1 course for C++ that I forgot entirely.
Thanks a lot for your help