ItPoke Posted August 5, 2019 Share Posted August 5, 2019 (edited) 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 August 5, 2019 by ItPoke Examples for functions to overwrite Quote Link to comment Share on other sites More sharing options...
FrostBug Posted August 5, 2019 Share Posted August 5, 2019 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. 1 Quote Link to comment Share on other sites More sharing options...
ItPoke Posted August 5, 2019 Author Share Posted August 5, 2019 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. Quote Link to comment Share on other sites More sharing options...
FrostBug Posted August 5, 2019 Share Posted August 5, 2019 (edited) 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 August 5, 2019 by FrostBug 1 Quote Link to comment Share on other sites More sharing options...
ItPoke Posted August 5, 2019 Author Share Posted August 5, 2019 Ahhh, cool! That's a great strong push in the right direction! Thank you very much! Quote Link to comment Share on other sites More sharing options...