jca Posted November 10, 2018 Share Posted November 10, 2018 (edited) 8 hours ago, Glaciation96 said: Brilliant! I never would have figured that out myself... Just one class in a script can extend Script? I do wonder how people would just know this... Probably a principle for when you extend anything then But that means I won't be able to use methods such as myPlayer().isAnimating() and the like from within my second class. Guess I've got to call all of that from inside my first class. Thanks! And yes, bad habit, it's good practice to keep checking my code frequently. That's why you've got handy methods like exchangeContext(). Basically you can extend MethodProvider from your second class then when you initialise it from your main class run secondClass.exchangeContext(getBot()); or alternatively pass the bot instance (getBot()) to your second class from the main class and run the exchangeContext(bot) method in the second class' constructor. Edited November 11, 2018 by jca 1 Quote Link to comment Share on other sites More sharing options...
Glaciation96 Posted November 11, 2018 Share Posted November 11, 2018 (edited) 2 hours ago, jca said: That's why you've got handy methods like exchangeContext(). Basically you can extend MethodProvider from your second class then when you initialise it from your main class run exchangeContext(SecondClass); or alternatively pass the script instance (this) to your second class from the main class and run the exchangeContext method in the second class' constructor. Cheers man! very helpful. I'll definitely look into that. Trying to successfully achieve this check through multithreading has been a rocky road lol, but really wanna understand/learn this. EDIT: Damn, I'm not getting any results for exchangeContext(). Is there another term for this method I can search up instead? Edited November 11, 2018 by Glaciation96 Quote Link to comment Share on other sites More sharing options...
jca Posted November 11, 2018 Share Posted November 11, 2018 (edited) 4 hours ago, Glaciation96 said: Cheers man! very helpful. I'll definitely look into that. Trying to successfully achieve this check through multithreading has been a rocky road lol, but really wanna understand/learn this. EDIT: Damn, I'm not getting any results for exchangeContext(). Is there another term for this method I can search up instead? Check the API docs for the ref to exchangeContext() or do a quick Google search, there’s a lot of info around. I’ve updated my original answer to demonstrate the call - I wrote it too quickly before and made a mistake, sorry! The code should work now. Edited November 11, 2018 by jca 1 Quote Link to comment Share on other sites More sharing options...
Glaciation96 Posted November 11, 2018 Share Posted November 11, 2018 (edited) 10 hours ago, jca said: Check the API docs for the ref to exchangeContext() or do a quick Google search, there’s a lot of info around. I’ve updated my original answer to demonstrate the call - I wrote it too quickly before and made a mistake, sorry! The code should work now. Sorry, I initially thought exchangeContext() was a java method not associated with botting! I managed to research into and understand how to implement it as you've suggested. But exchangeContext() has been deprecated, so no Javadoc could be found. Is there a new or updated approach? I was hoping suppressing the warnings would be a magical way out lol. Thanks! EDIT: Oh wow, even with the line going straight through, the variables still works. Just looks ugly. Thanks for the help, exchangeContext() is a life saver Edited November 11, 2018 by Glaciation96 Quote Link to comment Share on other sites More sharing options...
jca Posted November 11, 2018 Share Posted November 11, 2018 1 hour ago, Glaciation96 said: Sorry, I initially thought exchangeContext() was a java method not associated with botting! I managed to research into and understand how to implement it as you've suggested. But exchangeContext() has been deprecated, so no Javadoc could be found. Is there a new or updated approach? I was hoping suppressing the warnings would be a magical way out lol. Thanks! EDIT: Also, I've seen from Explv that it's marked for internal use only, but still fine to use? How do I make it so it's "fine to use"? There is a horizontal line going straight through 'exchangeContext(getBot)' It’s fine, a horizontal line through the method is a notification to you that it is deprecated rather than an error that will stop it compiling. So you can use it as normal, as far as I’m aware it is the best practice. 1 Quote Link to comment Share on other sites More sharing options...
Apaec Posted November 11, 2018 Author Share Posted November 11, 2018 2 hours ago, Glaciation96 said: Sorry, I initially thought exchangeContext() was a java method not associated with botting! I managed to research into and understand how to implement it as you've suggested. But exchangeContext() has been deprecated, so no Javadoc could be found. Is there a new or updated approach? I was hoping suppressing the warnings would be a magical way out lol. Thanks! EDIT: Oh wow, even with the line going straight through, the variables still works. Just looks ugly. Thanks for the help, exchangeContext() is a life saver I'd personally avoid using deprecated methods as they may be removed altogether in future builds. There are other ways to achieve what you're looking for without exchangeContext, for example you can pass a MethodProvider or Bot instance to the new class via the constructor 2 Quote Link to comment Share on other sites More sharing options...
Toomanytimes Posted November 20, 2018 Share Posted November 20, 2018 In the Setting up part, I have two issues. First when setting up a class, when i name my project and hit finish a window automatically pops up prompting me to make a module name. Then after that I have no clue how to open the class window. Second, when i get to the build path config and try to hit add external jar the button is not clickable. I do not understand why the button is not clickable. Thank you for you help. Anthony Quote Link to comment Share on other sites More sharing options...
Apaec Posted November 20, 2018 Author Share Posted November 20, 2018 8 hours ago, Toomanytimes said: In the Setting up part, I have two issues. First when setting up a class, when i name my project and hit finish a window automatically pops up prompting me to make a module name. Then after that I have no clue how to open the class window. Second, when i get to the build path config and try to hit add external jar the button is not clickable. I do not understand why the button is not clickable. Thank you for you help. Anthony Hey I don't think that the interfaces have changed from what i've specified in the guide. Are you sure you followed the steps outlined in the screenshots ? If so, maybe you could send me a couple of screenshots and I can make suggestions for what to try Apa Quote Link to comment Share on other sites More sharing options...
R I F T Posted November 24, 2018 Share Posted November 24, 2018 Great Quote Link to comment Share on other sites More sharing options...
Glaciation96 Posted December 7, 2018 Share Posted December 7, 2018 Hey there! Hope you're all doing well, but unfortunately, I am back. I'll make it quick this time around:) I'm trying to get into using Lambdas, but I'm a little confused. Is there an import which includes the Sleep method that enables the use of lambdas? I have import org.osbot.rs07.utility.ConditionalSleep; but clearly that isn't it. I just see some people using lambdas in their script, but I'm not seeing the functional interface which is required? Maybe they're not pasting the entirety of their script, but would I have to create my own interface? Just wondering if there was already an osbot import/extension for that, other than the built-in java ones. Cheers! Quote Link to comment Share on other sites More sharing options...
Apaec Posted December 8, 2018 Author Share Posted December 8, 2018 14 hours ago, Glaciation96 said: Hey there! Hope you're all doing well, but unfortunately, I am back. I'll make it quick this time around:) I'm trying to get into using Lambdas, but I'm a little confused. Is there an import which includes the Sleep method that enables the use of lambdas? I have import org.osbot.rs07.utility.ConditionalSleep; but clearly that isn't it. I just see some people using lambdas in their script, but I'm not seeing the functional interface which is required? Maybe they're not pasting the entirety of their script, but would I have to create my own interface? Just wondering if there was already an osbot import/extension for that, other than the built-in java ones. Cheers! Lambdas are a part of Java 8 so you won't be able to use them unless your script is built accordingly. Maybe this is where the issue is? Lambdas are unrelated to OSBot, so it has nothing to do with api imports Apa Quote Link to comment Share on other sites More sharing options...
Glaciation96 Posted December 9, 2018 Share Posted December 9, 2018 On 12/8/2018 at 2:09 PM, Apaec said: Lambdas are a part of Java 8 so you won't be able to use them unless your script is built accordingly. Maybe this is where the issue is? Lambdas are unrelated to OSBot, so it has nothing to do with api imports Apa Oh, I'm probably misunderstanding what imports are and how they work then lol. It's probably something to do with instantiating a class with/or an interface which enables you to use them then... The Sleep class might have it I guess, just gotta dig through the libraries. Thanks! Quote Link to comment Share on other sites More sharing options...
Mephisto Posted December 10, 2018 Share Posted December 10, 2018 Very helpfull! Thanks alot! 1 Quote Link to comment Share on other sites More sharing options...
ReaperScripts Posted December 15, 2018 Share Posted December 15, 2018 I'm missing the .setting section of the project Does anyone know how to fix this? Quote Link to comment Share on other sites More sharing options...
LostOtaku Posted December 15, 2018 Share Posted December 15, 2018 (edited) 15 hours ago, ReaperScripts said: I'm missing the .setting section of the project Does anyone know how to fix this? I had the same issue, but it seems it's not a problem at all, might just be because his pictures were created from a while back, updates may have changed it. Just try running it and it should be fine. I am confused about one thing though, why when I drop each cup of tea as it appears in my inventory it right clicks and presses drop, yet if I change that section to if (getInventory().isFull()) { //Checks if inventory is full getInventory().dropAll("Cup of Tea"); // drops all cups of tea It just shift clicks them (the more optimal setting if turned on), I was wondering how to make this the general option for even just dropping one. EDIT Sorted this out by just changing the one that drops them as soon as they appear in your inventory to also dropAll("Cup of Tea") and then it shift click drops them, I'm actually so slow lmao. I guess dropAll > drop xddd However on another note I'm trying to make a 3rd version of the tea script that banks, I've got it to locate the nearest bank and open the bank booth @Override public int onLoop() throws InterruptedException { RS2Object stall = getObjects().closest("Tea Stall"); //Checks for nearest tea stall to player location if (getInventory().isFull()) { //Checks invo for cup of tea RS2Object bank = getObjects().closest("Bank booth"); // Checks for nearest bank booth bank.interact("Bank"); //Opens the banking interface sleep(500); //if invo contains cup of tea and proceeds to drop it then after this sleeps for 0.5s } else if (stall != null && !myPlayer().isAnimating()) { //if no tea in invo checks if player is animating stall.interact("Steal-from"); // if player ins't animating steals from the stall sleep(500); //After stealing from stall sleeps for 0.5s before looping to start of script } return random(200, 300); } Just unsure how to actually either right click and deposit all the "Cup of Tea"s or how to click deposit inventory button. Any help would be greatly appreciated. (On a side note, sorry for my code not having colours in here, I'm not sure how to do that, I just copy and pasted it) Edited December 15, 2018 by LostOtaku Quote Link to comment Share on other sites More sharing options...