August 29, 201510 yr 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?
August 29, 201510 yr 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(); } }
August 29, 201510 yr 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.
Create an account or sign in to comment