Jump to content

Overwrite API functions


ItPoke

Recommended Posts

I am looking to overwrite some of the API functions (Like world hop and break handler) to better suit scripts I make, but I can't figure out how this would be done.
I don't really know where or what to look for, so a general push in the right direction would be much appreciated! :) 

Edited by ItPoke
Examples for functions to overwrite
Link to comment
Share on other sites

Break handler isn't really an API function, but a "Random Executor" (Group of event executors that are automatically triggered by some condition; like being logged out or in a  random event). Some of these can be overridden with the RandomExecutor#overrideOSBotRandom method, providing a new implementation. The break manager can be overridden like this.

For world hopping you can create your own methods that interact with the ingame world-switcher (See FrostHopper snippet for an example), but if you're looking for logged-out world switching, you'll have to disable the login-handler by using CLI, and provide your own custom login-handler that allows it.

  • Like 1
Link to comment
Share on other sites

Great, exactly what I was looking for with the Random Executors :) 

However, with the world hopping thing, I would like to overwrite osbot API, since I also want to overwrite other API. In your world hopper you create a new class which you use. But I am going to use some osbot APIs which uses other osbot APIs that I want to overwrite, I heard this was possible. But don't really know how to overwrite the API.

Link to comment
Share on other sites

48 minutes ago, ItPoke said:

Great, exactly what I was looking for with the Random Executors :) 

However, with the world hopping thing, I would like to overwrite osbot API, since I also want to overwrite other API. In your world hopper you create a new class which you use. But I am going to use some osbot APIs which uses other osbot APIs that I want to overwrite, I heard this was possible. But don't really know how to overwrite the API.

Not sure what it is you've read (and not 100% sure what you're trying to achieve either)

You can override OSBot API to the extent of creating classes that extend some API class and override certain public or protected methods. For example you might create a class called CustomWorlds which extends the Worlds class, and proceed to override the hopToP2PWorld method. This would allow you to create an instance of your CustomWorlds class and use it to hop to p2p worlds with your overridden implementation; however when using the MethodProvider to access the worlds API, you will still receive the instance of Worlds (not CustomWorlds) managed by the client. In turn, any other OSBot API that were to access the hopToP2PWorld method would not use your overridden variant either.

EDIT:
Actually, considering that all API fields in MethodProvider are public, you could set the worlds field, of the MethodProvider held by your Script instance, to an instance of your CustomWorlds class.

Edited by FrostBug
  • Like 1
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...