Jump to content

API Question


PancakePuncher

Recommended Posts

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

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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