Jump to content

How to make the player stay in a area?


Recommended Posts

Posted (edited)
8 minutes ago, faruk141 said:

Hi OSbot community,

im working on my first script , which is a simple iron miner.

I have defined an area, where the player(bot) is supposed to stay, but i dont know which command makes the bot stay in that area . Can someone help me?

 

if(AREA.contains(ORE.getPosition()){

// INTERACT

}

 

 

or if you want to walk back to the area if you leave it,

 

if(!AREA.contains(myPosition())){

getWalking().webWalk(AREA.getRandomPosition());

}

Edited by Duhstin
  • Like 1
Posted
12 hours ago, Duhstin said:

 

if(AREA.contains(ORE.getPosition()){

// INTERACT

}

 

 

or if you want to walk back to the area if you leave it,

 

if(!AREA.contains(myPosition())){

getWalking().webWalk(AREA.getRandomPosition());

}

thank you very much! i used the AREA.contains(ORE) method and its working.

There was another iron ore with the same id  outside the area and because of this i needed a solution for this problem. :)

Posted
2 hours ago, faruk141 said:

thank you very much! i used the AREA.contains(ORE) method and its working.

There was another iron ore with the same id  outside the area and because of this i needed a solution for this problem. :)

Not wise to use ids for rocks, check this out

Also, though basically the same, check what Chris wrote. His snippet is basic and clean.

  • Like 1

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