Jump to content

Cannot instantiate type Character


stussyboi187

Recommended Posts

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

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

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?

Link to comment
Share on other sites

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

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.

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