casual Posted August 29, 2015 Share Posted August 29, 2015 My scripts get messy, so I'd refactor functionality to custom classes. The problem is, that if these want to use osbot functionality (items, inventory, etc), they have to extend from the Script class. The Script class forces me to create onLoop, onStart and onStop. How to avoid this? Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted August 29, 2015 Share Posted August 29, 2015 Pass a Script instance to your class like so: public class myCoolClass { private Script script; public myCoolClass(Script src) { script = src; } public void myCoolMethod() { Item[] items = script.getInventory().getItems(); } } Quote Link to comment Share on other sites More sharing options...
casual Posted August 29, 2015 Author Share Posted August 29, 2015 And how to instantiate? I don't have a script variable I could pass. Quote Link to comment Share on other sites More sharing options...
liverare Posted August 29, 2015 Share Posted August 29, 2015 The script class is the script variable. Use the keyword this. But you should check out this thread for a better way of handling stuff. 1 Quote Link to comment Share on other sites More sharing options...