Jump to content

Pick Item Up From Ground


Recommended Posts

Posted (edited)

I am learning how to script with OSBot and am having a small problem. I am writing a hunter script that catches birds currently. The part of the script to lay a bird snare works, but the issue is picking up the snare. If the snare is caught, I am trying to Check the bird snare, and then lay the snare from the inventory. If the snare fails, dismantle it and then lay it. If the snare times out, dismantle it and then lay it. I can't quite find out a way to pick up the bird snare off of the ground. I have tried GameObject because the snare counts as a GameObject. I have tried to check the tile it is on, and then if it is valid, and then convert it to string, and then check if it contains "Check" for the snare option. Nothing I am writing has worked and i've tried loads of things. Anything that points me towards the right direction is appreciated. I think i'm just over thinking it.

EDIT: So I found out how to actually pick up the bird snare, but I don't know how to set the coordinate for the tile to place it at the exact tile every time. Any help with that? 

Edited by vexumy
Posted (edited)

If you want to place it in the same tile you took it from you can store the position before you pick it up like this

GroundItem groundItem;
Position itemPosition;
groundItem = getGroundItems().closest(e -> e != null && e.getName().contains("Bird snare"));
if(groundItem != null) {
    itemPosition = groundItem.getPosition();
    groundItem.interact("Take");
}

Or you can make an array of positions around your character when the script starts and check to see if there is a snare in them with RS2Object getPosition() on nearby snares. You would also want to track which snares were yours incase someone started laying traps in your positions.

Edited by Cloxygen

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...