Jump to content

How to make the player stay in a area?


faruk141

Recommended Posts

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

15 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());

}

Ore is a RS2Object so it's an entity. You can just use contains(ORE) in that case. 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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