October 11, 20187 yr Hello, not 100% scripting related but I am trying to clean up some of my code mess so I figured I should refactor it. However when I try to place my custom classes into a package the classes in the package can no longer access the OSBot api and simple stuff like logging becomes impossible. I am probably missing a config item somewhere but I can't find where, and using the search function I haven't found an answer either. Starting to wonder weither or not this is possible in the first place, basically in my main script I import WackPackage.SickClassNameHere but the SickClassNameHere can't do anything. Using Intelij 2018 CE with Linux. I configured my project like the tutorial here said (The 4 part one).
October 11, 20187 yr Author Right, spend all day messing around and looking at other code examples, you actually need to pass on the API (Script Class) and then you can use that. Because your own script extends the Script class it too extends the functions in it allowing you to use log etc. I feel really stupid.
October 11, 20187 yr 2 minutes ago, angelsdust said: Right, spend all day messing around and looking at other code examples, you actually need to pass on the API (Script Class) and then you can use that. Because your own script extends the Script class it too extends the functions in it allowing you to use log etc. I feel really stupid. Yeah, pass the script instance and use exchangeContext()
October 12, 20187 yr Author 9 hours ago, jca said: Yeah, pass the script instance and use exchangeContext() Oh, haven't seen any exchangeContext() being used in the scripts I copied it from. Thanks for the tip, according to the API documentation it's deprecated? What is it supposed to do?
October 12, 20187 yr 2 hours ago, angelsdust said: Oh, haven't seen any exchangeContext() being used in the scripts I copied it from. Thanks for the tip, according to the API documentation it's deprecated? What is it supposed to do? Correction - exchangeContext actually takes a bot instance. So from your main class you pass getBot() to your custom class when you initialise it. You have your custom class extend MethodProvider then in the initialiser call exchangeContext(Bot). This gives you access to all the methods you need. Not sure why it’s deprecated.
October 12, 20187 yr edit: nvm i'm actually not sure about wat i said, dont wane post wrong info. Edited October 12, 20187 yr by zwaffel
Create an account or sign in to comment