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
  • Ground items?


    crazykid080

    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");
            }

     

    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:

     

    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • 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.