Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Ground items?


    crazykid080
     Share

    Recommended Posts

    Hi all, I'm starting out with scripting and I'm getting the gist of it but I'm having trouble understanding the GroundItem and GroundItem classes, I've tried searching but I didn't seem to get any results.

    My current plan is to look for ANY item on the ground and then pick it up but I'm having trouble finding items.

    What I want to do is either check an area for any item or get the closest item but I'm not sure how to do it in a decent way. My first thoughts were to define an area and iterate over each tile and see if it contains a ground item (I don't think that's a good idea but I wanted to share it), or use GroundItems.closest but that requires a filter, what filter do I use exactly? I'm seeing multiple filters but not sure what would be best.

    Link to comment
    Share on other sites

    39 minutes ago, crazykid080 said:

    Hi all, I'm starting out with scripting and I'm getting the gist of it but I'm having trouble understanding the GroundItem and GroundItem classes, I've tried searching but I didn't seem to get any results.

    My current plan is to look for ANY item on the ground and then pick it up but I'm having trouble finding items.

    What I want to do is either check an area for any item or get the closest item but I'm not sure how to do it in a decent way. My first thoughts were to define an area and iterate over each tile and see if it contains a ground item (I don't think that's a good idea but I wanted to share it), or use GroundItems.closest but that requires a filter, what filter do I use exactly? I'm seeing multiple filters but not sure what would be best.

    You can filter by whatever specifications you want. Then you need to check if its null or not. Then pick it up. Like so:

            GroundItem gi1 = GroundItems.closest(item -> item.isOnScreen() && item.getName().equals("Coins"));
            if (gi1 != null) gi1.interact("Take");

    isOnScreen only works if the camera is looking at it. If you don't want this you can take it out and it'll automatically turn your camera to get it.

    or you could do this to pickup every coin in 25 distance around your player (tiles).

            while (gi1 != null) {
                gi1 = GroundItems.closest(item -> item.isOnScreen() && item.getName().equals("Coins") && item.distance(getLocalPlayer().getTile()) < 25);
                gi1.interact("Take");
            }

     

    Edited by LordJashin32
    Link to comment
    Share on other sites

    14 minutes ago, crazykid080 said:

    Awesome, so it's just a bit of java that I didn't know about, thanks!

    If you wanna learn about filters, streams, and etc in general for java. I learned it here. Very good explanations:

     

    Edited by LordJashin32
    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.