Jump to content

API Question


Recommended Posts

Posted (edited)

I am having a hard time finding a way to check if the player is inside a specific area. Anyone shed of light for me?

 

Also, do someone have any good methods for walking/pathing?

 

I don't need specific code, just some simple logic on whats a good way to do it?

 

1. Checking if player is in an area:

 

Area a = new Area(1, 2, 3, 4);

Player p = myPlayer();

if(a.contains(p)) { //'contains' in the API refers to all entities - a player is a character, which is a type of entity

 //do x

}

 

 

2. Walking / pathing

getWalking().webWalk(area or position); //or use a webwalkevent if you want

webwalking figures out the pathing for you and deals with common obstacles. If you don't need to deal with obstacles, it will be less intensive to use getWalking().walk() or just a regular walkingevent. if you dont want to do either of those, use explv.github.io (website) to figure out pathing and use getWalking().walkPath(list of positions gathered from the site). 

Edited by Imateamcape
  • Like 2
Posted

This works for "your" character? Because I feel like this might looked for other players as well which wouldn't be right. Does the client refer to you as the "LocalPlayer" but the issue is in the API I can only find .getLocalPlayer. Can I turn it into a variable like you stated above?

 

myPlayer() returns your own character, yes. Never others. And yes... It returns a player, hence you can say something like:

 

Player player = myPlayer();

 

if(area.contains(player)) {

 // do something

}

 

Or if you want, you don't need to define it...

 

if(area.contains(myPlayer())) {

 // do something

}

 

same thing, really

Posted

myPlayer() returns your own character, yes. Never others. And yes... It returns a player, hence you can say something like:

 

Player player = myPlayer();

 

if(area.contains(player)) {

 // do something

}

 

Or if you want, you don't need to define it...

 

if(area.contains(myPlayer())) {

 // do something

}

 

same thing, really

 

Thanks for the help, not looking to make another Thread I only have a few more questions if you don't mind.

 

Firstly, other bot API's use "sleep" as a method to sort of pause or idle their bots. As far as I can gather is that OSBot uses "random" to do this? Am I correct?

 

Secondly, how would I go about properly interacting with items on the ground? I want my bot to search/identify a specific item on the ground, pick it up, and then bank it. I am having a hard time figuring this out for some reason.

 

Lastly, would it be ok to message you with any further questions I may have?

Posted

Thanks for the help, not looking to make another Thread I only have a few more questions if you don't mind.

 

Firstly, other bot API's use "sleep" as a method to sort of pause or idle their bots. As far as I can gather is that OSBot uses "random" to do this? Am I correct?

 

Secondly, how would I go about properly interacting with items on the ground? I want my bot to search/identify a specific item on the ground, pick it up, and then bank it. I am having a hard time figuring this out for some reason.

 

Lastly, would it be ok to message you with any further questions I may have?

 

1. random and sleep have nothing to do with each other. Script is just a type of thread - sleep stalls the thread (makes it sleep) for a random amount of time, given by an int. random returns an int, so its used to randomize the amount of time that hte bot sleeps for.

 

2. GroundItem g = groundItems.get(name / id);

g.interact("Take");

 

Explore the API a little more before making scripts. It'll help.

Posted (edited)

1. random and sleep have nothing to do with each other. Script is just a type of thread - sleep stalls the thread (makes it sleep) for a random amount of time, given by an int. random returns an int, so its used to randomize the amount of time that hte bot sleeps for.

 

2. GroundItem g = groundItems.get(name / id);

g.interact("Take");

 

Explore the API a little more before making scripts. It'll help.

 

groundItems.get(x, y) is the only "get" there is, you're probably thinking groundItems.closest(name/id).

 

@@PancakePuncher But you should read/search the API, links at the top of the page (or here: http://osbot.org/api/ )

Edited by Lemons
Posted (edited)

I have been using the API. Usually I have no problem finding the method I need to perform a task. I was just having a hard time determine which "Item" method checked against the items name. I was using poopbot API, but the community over there is rather dead it seems so I transitioned to here. The bots methods a somewhat similar though not entirely.

 

Believe me though I am not asking questions until I do my own research and testing before hand.

Edited by PancakePuncher

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