Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Buy OSRS Gold

Sell OSRS Gold
Sign in to follow this  
Lymmm

API Class Method return definition

Recommended Posts

Hi All.

I just started with creating script for OSRS yesterday. I am browsing the API docs and would like to ask where can I find the different returns definition of a method?

Example is the Player.getAnimation(), it says on the docs that it returns int but didn't mentioned what are the values it returns and definition of its values. I only know so far is -1 means player is doing nothing.

image.png.12abe0f5ff44a42a1badd594259725ae.png

 

Also, how do we write something on screen on run-time. Just like below but this only runs when script started. Would like to display some data on screen for debugging purposes.

image.png.31cf7b7612c43d92838ed721e07fa95e.png

 

Just like this one.

image.png.3e510285585d686ee17bf38bd3e0ff2f.png

 

Thanks.

Share this post


Link to post
Share on other sites
Posted (edited)
38 minutes ago, Lymmm said:

Example is the Player.getAnimation(), it says on the docs that it returns int but didn't mentioned what are the values it returns and definition of its values. I only know so far is -1 means player is doing nothing.

In the Oldschool Runescape Client, every player animation is classified by an ID (integer). This value is set by the client and used. Tribot reads this value to tell you what the animation ID is. There is no definition of its values. Any definitions that the OSRS client may have had in source code are completely erased after obfuscation and during runtime (which is where Tribot gets the values). 

 

Therefore, the only way to get the definition of an animation is to grab that value, see what it is, look at what the character is doing on screen, then define it yourself. And we aren't going to do that for every single possible animation in the game so that we can put it into the API. It's your responsibility to figure out which animations are which IDs that are pertinent to your script. For most scripts, all you really need to know is -1 is idle and not -1 is animating. The details rarely matter, and when they do, you usually only need to know a couple IDs, which is why it makes more sense to do it on a per-script basis.

 

The same goes for all game values. RSObject IDs, NPC IDs, etc. The tribot API gives you a lot of tools for reading values from the game. However, any cross-referencing to metadata needs to be done by you.

 

To do this, make sure to open the debug menu in Tribot, which will let you visualize these values in real-time.

Edited by wastedbro
  • Thanks 1

Share this post


Link to post
Share on other sites
10 hours ago, Lymmm said:

Also, how do we write something on screen on run-time. Just like below but this only runs when script started. Would like to display some data on screen for debugging purposes.

onPaint runs every few milliseconds, not just when the script starts.
If you want, for example, to display the script runtime, you can do it like this:

long runtime = super.getRunningTime();
g.drawString("Runtime: " + Timing.msToString(runtime), 380, 350)

To display script stats, like number of resources collected/used, exp/hour gained, etc, you'll have to keep track of that, and do the calculations yourself. E.g.:

int resources = ... // increase this count after some action the bot performed
g.drawString("Resources: " + resources, 380, 370);
int resourcesPerHour = (int)(resourcesCount * TimeUnit.HOURS.toMillis(1) / runtime);
g.drawString("Resources/hour: " + resourcesPerHour, 380, 390);

 

Share this post


Link to post
Share on other sites
4 hours ago, Beg said:

onPaint runs every few milliseconds, not just when the script starts.
If you want, for example, to display the script runtime, you can do it like this:

long runtime = super.getRunningTime();
g.drawString("Runtime: " + Timing.msToString(runtime), 380, 350)

To display script stats, like number of resources collected/used, exp/hour gained, etc, you'll have to keep track of that, and do the calculations yourself. E.g.:

int resources = ... // increase this count after some action the bot performed
g.drawString("Resources: " + resources, 380, 370);
int resourcesPerHour = (int)(resourcesCount * TimeUnit.HOURS.toMillis(1) / runtime);
g.drawString("Resources/hour: " + resourcesPerHour, 380, 390);

 

Be careful how many calculations you’re doing within the onPaint method. Calculations that take longer than the call rate of the method will cause a decrease in performance.

Share this post


Link to post
Share on other sites

Thank you @wastedbro you are absolutely right. Will keep that in mind.

@Beg and @Encoded thanks.

Yesterday while I researching on this, I saw this tutorial of Einstein which helped me a lot. Now for debugging purposes, I created a global string variable and updates the value on the main thread then displays this onPaint.

Thank you for the answers.

Share this post


Link to post
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.

Sign in to follow this  

  • Our picks

    • Over the past few months, I’ve been working diligently on a new project - TRiBot X. Everything has been written from the ground up, with all of the best practices of software engineering. Every aspect of TRiBot has been re-imagined to support three main goals: flexibility, useability, and reliability.
        • Like
      • 37 replies
    • Come give us feedback on the next version of TRiBot!
        • Thanks
        • Like
      • 75 replies
    • TRiBot is looking to improve a lot of its customer relationship management, customer on boarding process, customer experience, design elements, community engagement and pretty much everything else you can imagine when it comes to marketing.

      Our goal: To ensure that the marketing done TRULY reflects the experience and does not shine an inaccurate light on what TRiBot is lacking in.

      So I ask, what do you love about TRiBot and what do you hate about TRiBot? What does O S Bot, Rune M8, PowR Bot and Dre amBot do better? (yes I purposely didn't spell it right 😂).

      Love, 

      RileyZ
        • Like
      • 23 replies
    • Over the last three weeks, I've been working on upgrading our server infrastructure. It's finally ready and is now live!

      Why?

      Increased reliability - less server errors


      Increased availability - less downtime


      Increased security - keeping us and you secure


      Increased capacity - ability to serve you better


      Increased speed - less waiting for things to load


      Faster development - server and service updates will come faster


      What are the changes?

      Move from a single AWS EC2 instance to AWS ECS (Elastic Container Service)


      Distributed computing


      Load balancing


      Git management of server files and filesystem


      Redis caching


      How?

      AWS ECS (with 10 EC2 instances)


      AWS ElastiCache (Redis)


      AWS Load Balancing


      AWS EFS (Elastic file system)


      Please bare with us as I continue to tune the server for maximum performance. Slow loading speeds may occur temporarily. I thank everyone for their patience.

      Please post on this thread if you experience any issues other than slow loading times.
        • Like
      • 51 replies
    • This release will:

      Fix prayers and world hopper API (Thanks @JoeDezzy1 and @erickho123)


      Improve banking API (Thanks @Encoded)


      Adds methods for returning and using Java Lists, rather than arrays


      Slightly randomizes some hardcoded behaviour


      Removes sleeps from waitConditions; the efficiency saving potential is negligible in these use-cases, therefore cleaner code is preferable


      Other back-end improvements





      Note: If you are using LG, please restart both the RS client and TRiBot.
        • Sad
        • Haha
        • Thanks
        • Like
      • 90 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...