Jump to content

Cannot instantiate type Character


Recommended Posts

Posted (edited)

Hello,

I just started scripting and taking baby steps to making a bot. However I dont know why I cannot instantiate type Character according to the OSBOT API. I know that its an abstract class so how would i go about using it syntax wise... also tried extending it in the class. Im trying to do character.isAnimation() method.

https://gyazo.com/3a7863f01f4a2a57caaf752444cb50b5

https://gyazo.com/843accad8fd0e2265226ffece7105e5c

Much help would be appreciated!

Edited by stussyboi187
Posted (edited)

As you said it is an abstract class; thus you can't instantiate it. You will need to extend it and provide a body to the abstract methods if you wish to use it. That being said, I can't see why you would need to do this, especially since you're new to scripting!

If you're looking to check if your player is animating, perhaps try something along these lines in your class which extends Script:

boolean animating = myPlayer().isAnimating();

.. or if you want the animation id:

int animationId = myPlayer().getAnimation();

Note that an id of (-1) is no animation.

GL!

Apa

Edit: Spelling

Edited by Apaec
Posted
22 minutes ago, Apaec said:

As you said it is an abstract class; thus you can't instantiate it. You will need to extend it and provide a body to the abstract methods if you wish to use it. That being said, I can't see why you would need to do this, especially since you're new to scripting!

If you're looking to check if your player is animating, perhaps try something along these lines in your class which extends Script:


boolean animating = myPlayer().isAnimating();

.. or if you want the animation id:


int animationId = myPlayer().getAnimation();

Note that an id of (-1) is no animation.

GL!

Apa

Edit: Spelling

 

Hello @Apaec thank you for the response. I will try it out and let you know how it goes. There is many classes in the api lol... any good way to sift through all the classes?

Posted
1 hour ago, stussyboi187 said:

 

Hello @Apaec thank you for the response. I will try it out and let you know how it goes. There is many classes in the api lol... any good way to sift through all the classes?

I mean it really depends on what you're looking for! Navigating javadocs takes a bit of practice - if you're looking for a specific method, you can have a look in index view, but mostly class tree view is the easiest to digest. If you're unsure about anything, don't hesitate to let me know! The more scripts you write, the more fluent you will become with both Java and the API.

Apa

  • Like 1
Posted
1 hour ago, Apaec said:

I mean it really depends on what you're looking for! Navigating javadocs takes a bit of practice - if you're looking for a specific method, you can have a look in index view, but mostly class tree view is the easiest to digest. If you're unsure about anything, don't hesitate to let me know! The more scripts you write, the more fluent you will become with both Java and the API.

Apa

Hey thanks for the support. Hopefully one day I can become like you. I will try out the tree method to search for things.

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