Looking For Help With First Script

New to coding in general so let me start off with sorry if this is long winded. Im just trying to write a simple script for the experience but I keep running into a wall. Im trying to start by just having my script attack goblins in lumbridge then pick up the bones and finally bury them.

Following the examples given in the Scripting Overview doc Im able to attack goblins and then pick up the bones using the Pickables.getNearest example with the filter for distance. My first question is, how would I get my script to wait until Im done attacking to pick up the bones? As it is now I just use Time.sleep and wait 30-45 seconds randomly to pick up. Ive tried to use Time.sleepUntil(!local.isAnimating) but I get the red underline and ‘cannot resolve method sleepUntil(boolean)’

My next question where would I start to get my script to check my inventory for something and then interact with it? Ive looked at the docs for RSPeer but admittedly everything starts to run together for me so I have a bit of difficulty keeping my thoughts straight.

In the meantime, I think Im going to take a step back to compose myself and do a bit of reading/learning on Java in general to get a better grasp on things. I very much appreciate anyone that might take the time to read this and give any input. Thank you!

edit: spelling. wording.

If you haven’t already, I highly recommend you join the RSPeer discord. You’ll get very quick answers to any questions you might have about the API or the client. You can find a link to it here: https://discordapp.com/invite/UVp7Evz

Regarding your specific scripting questions, please refer to the JavaDocs located HERE

You cannot pass a boolean to Time.sleepUntil(), you must pass a condition (a Boolean Supplier), like so: Time.sleepUntil(() -> !localPlayer.isAnimating()). That is, sleep until the condition of “the local player is not animating” is true. You can also pass a polling interval (how often to check the condition, in milliseconds) and a threshold (total time to sleep for in milliseconds). That would look like this: Time.sleepUntil(() -> !localPlayer.isAnimating(), 1000, 10000), which would check that the player is not animating, once a second, up to 10 seconds.

As for interacting with the inventory, you’d want to use the methods located within the Inventory class. You can find that HERE. You’d probably want to start with one of the “get” methods, to find which item in particular you want to interact with, such as getFirst(). From there you can call any of the methods related to the Item class, such as Item.interact().

Being proficient with Java is an absolute must for using the RSPeer API, and that holds true for any botting client’s API that is built using Java. Like I mentioned above, I highly recommend you join the Discord if you have any further questions.

1 Like