Verify 0 Share Posted May 1, 2020 Hi, newbie scripter here. I was wondering if there is any ways to get out of sleep only when the condition persists for X amount of time. For example, if sleepUntil(()->!getLocalPlayer().isAnimating(), 5000); is used, then sleep breaks every time the crafting animation stops. I would like it to stop sleeping when the player is idle for 4 seconds uninterrupted for example. Link to comment Share on other sites More sharing options...
Hashtag 8817 Share Posted May 1, 2020 Hey, to answer your question, you can do something like this to sleep until it has been 4 seconds since your character previously animated with a timeout of 30 seconds. final long[] lastAnimated = { System.currentTimeMillis() }; sleepUntil(() -> { if (getLocalPlayer().isAnimating()) lastAnimated[0] = System.currentTimeMillis(); return System.currentTimeMillis() - lastAnimated[0] >= 4000; }, 30000); However, I've hardly ever had to use anything like this. Are you sure this wouldn't be sufficient for your needs? sleepUntil(() -> getDialogues().inDialogue() || !getInventory().containsAll(REQUIRED_ITEMS_HERE), 30000); This way your script would continue either after 30 seconds or when you're in dialogue (level up, for example) or your character no longer has the required items in inventory. Link to comment Share on other sites More sharing options...
Verify 0 Author Share Posted May 2, 2020 Ty, it's exactly what I needed! I have some specific actions that can't rely on inventory checks so that's why I wanted some kind of catch all method to detect when actual clicks are needed. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.