Nbacon Posted July 25, 2020 Share Posted July 25, 2020 (edited) 1 hour ago, badjie said: what is the "." just before "closest" doing? i also didnt find anything on the api so im assuming its a language thing Its a java thing. I personaly suck at explaining things. So here some link. I would recommend watching a crash coruse on java over the next few days. https://www.freecodecamp.org/news/java-getters-and-setters/#:~:text=Getters and setters are used,as accessors and mutators%2C respectively. https://www.tutorialspoint.com/java/java_inheritance.htm https://www.tutorialspoint.com/java/java_object_classes.htm Edited July 25, 2020 by Nbacon 1 Quote Link to comment Share on other sites More sharing options...
badjie Posted July 25, 2020 Share Posted July 25, 2020 public int onLoop() throws InterruptedException { RS2Object stall = getObject().closest("Tea Stall"); if (getInventory().contains("Cup of Tea")) { getInventory().drop("Cup of Tea"); sleep(700); } else if (stall != null && !myPlayer().isAnimating) { stall.interact("Steal-From"); log ("Stall Here!"); sleep(700); } return random(200, 300); } So my inventory can be full and NOT have tea (just full with other items), i was thinking about doing something like if ( getInventory().isFull() AND getInventory().contains("anything other than tea") ) { getInventory().drop("a random item in my inventory") I've been looking on the API but im not sure how to check for "anything other than tea" and how to drop a random item in my inventory. Quote Link to comment Share on other sites More sharing options...
Apaec Posted July 25, 2020 Author Share Posted July 25, 2020 1 hour ago, badjie said: public int onLoop() throws InterruptedException { RS2Object stall = getObject().closest("Tea Stall"); if (getInventory().contains("Cup of Tea")) { getInventory().drop("Cup of Tea"); sleep(700); } else if (stall != null && !myPlayer().isAnimating) { stall.interact("Steal-From"); log ("Stall Here!"); sleep(700); } return random(200, 300); } So my inventory can be full and NOT have tea (just full with other items), i was thinking about doing something like if ( getInventory().isFull() AND getInventory().contains("anything other than tea") ) { getInventory().drop("a random item in my inventory") I've been looking on the API but im not sure how to check for "anything other than tea" and how to drop a random item in my inventory. Sounds like the relevant part of the API to you would be the inventory API: https://osbot.org/api/org/osbot/rs07/api/Inventory.html Something like inventory#dropAllExcept sounds about right. For example: if (getInventory().isFull()) { getInventory().dropAllExcept("Cup of Tea"); } Quote Link to comment Share on other sites More sharing options...
badjie Posted July 26, 2020 Share Posted July 26, 2020 1 hour ago, Apaec said: Sounds like the relevant part of the API to you would be the inventory API: https://osbot.org/api/org/osbot/rs07/api/Inventory.html Something like inventory#dropAllExcept sounds about right. For example: if (getInventory().isFull()) { getInventory().dropAllExcept("Cup of Tea"); } what if i dont want to drop everything, and instead just 1 thing at a time? that's my real problem cuz i can't find anything for that Quote Link to comment Share on other sites More sharing options...
Apaec Posted July 26, 2020 Author Share Posted July 26, 2020 7 hours ago, badjie said: what if i dont want to drop everything, and instead just 1 thing at a time? that's my real problem cuz i can't find anything for that Hmm, this is certainly a niche situation, but can definitely be done. Might be a little trickier though. Typically, when the players inventory is full of junk so a script cannot run, the script should either terminate and let the player know this, or do something loss-less, such as going to a bank and depositing the junk. Arbitrarily dropping items isn't a great idea in general: what is the inventory was full of godswords? Anyway, to achieve what you're looking for, the default API entries won't seem to provide this functionality. We'll have to create our own filter: (Note that I haven't tested this code and wrote it here in the reply box so there could be errors, let me know if it doesn't work!) if (getInventory().isFull()) { getInventory().dropForFilter(new Filter<Item>(){ @Override public boolean match(Item x) { return !x.getName().equals("Cup of Tea"); } }); } Quote Link to comment Share on other sites More sharing options...
badjie Posted July 26, 2020 Share Posted July 26, 2020 8 hours ago, Apaec said: Hmm, this is certainly a niche situation, but can definitely be done. Might be a little trickier though. Typically, when the players inventory is full of junk so a script cannot run, the script should either terminate and let the player know this, or do something loss-less, such as going to a bank and depositing the junk. Arbitrarily dropping items isn't a great idea in general: what is the inventory was full of godswords? Anyway, to achieve what you're looking for, the default API entries won't seem to provide this functionality. We'll have to create our own filter: (Note that I haven't tested this code and wrote it here in the reply box so there could be errors, let me know if it doesn't work!) if (getInventory().isFull()) { getInventory().dropForFilter(new Filter<Item>(){ @Override public boolean match(Item x) { return !x.getName().equals("Cup of Tea"); } }); } Oh i see what you did there! just to make sure you are basically making a filter for an item, then you create a method with the argument x, and make it return an item thats NOT x and then you pass that to the filter? i currently have no way to test it since i have a main rs account and i dont want to test it on a bot and get my ip flagged. I still need to take care of that later(prob getting a proxy). Anyways, the important thing is that i think i understood how it works. Thanks once again! 1 Quote Link to comment Share on other sites More sharing options...
Apaec Posted July 26, 2020 Author Share Posted July 26, 2020 2 hours ago, badjie said: Oh i see what you did there! just to make sure you are basically making a filter for an item, then you create a method with the argument x, and make it return an item thats NOT x and then you pass that to the filter? i currently have no way to test it since i have a main rs account and i dont want to test it on a bot and get my ip flagged. I still need to take care of that later(prob getting a proxy). Anyways, the important thing is that i think i understood how it works. Thanks once again! Yep, that's more or less what is going on. It looks a bit complicated and is certainly advanced syntax (it's an anonymous instantiation) so don't worry too much if you're not comfortable with it. Quote Link to comment Share on other sites More sharing options...
badjie Posted July 26, 2020 Share Posted July 26, 2020 23 minutes ago, Apaec said: Yep, that's more or less what is going on. It looks a bit complicated and is certainly advanced syntax (it's an anonymous instantiation) so don't worry too much if you're not comfortable with it. Just wondering do most paid scripts use advanced java knowledge (like anonymous instantiation) or can most of them be acomplished through simple use of the api capabilities? Quote Link to comment Share on other sites More sharing options...
K1ngsterZ Posted July 26, 2020 Share Posted July 26, 2020 Still one if not the best guide out here. 1 Quote Link to comment Share on other sites More sharing options...
Apaec Posted July 26, 2020 Author Share Posted July 26, 2020 2 hours ago, badjie said: Just wondering do most paid scripts use advanced java knowledge (like anonymous instantiation) or can most of them be acomplished through simple use of the api capabilities? Well, 'advanced java knowledge' isn't exactly some unattainable feat, though it does take some practice and reading some tutorials. I'd say that while most scripters with premium scripts on the market have a solid if not strong understanding of Java, and some (esp. scripter IIIs) have wider software dev/computer science knowledge too, you can certainly get a long way with just the basics. It's amazing how much you can pick up by just trying API things out, failing, and asking questions - once you've beaten the initial learning curve (which is quite steep, but don't let that put you off!), improving is much quicker and easier. Indeed, writing scripts for OSBot doesn't have to just be a fun hobby---is a great introduction to the world of programming and software development. Well worth learning! I'm always here to answer questions, programming related or otherwise. Reply here or send me a PM any time you need anything -Apa 1 Quote Link to comment Share on other sites More sharing options...
badjie Posted July 26, 2020 Share Posted July 26, 2020 24 minutes ago, Apaec said: Well, 'advanced java knowledge' isn't exactly some unattainable feat, though it does take some practice and reading some tutorials. I'd say that while most scripters with premium scripts on the market have a solid if not strong understanding of Java, and some (esp. scripter IIIs) have wider software dev/computer science knowledge too, you can certainly get a long way with just the basics. It's amazing how much you can pick up by just trying API things out, failing, and asking questions - once you've beaten the initial learning curve (which is quite steep, but don't let that put you off!), improving is much quicker and easier. Indeed, writing scripts for OSBot doesn't have to just be a fun hobby---is a great introduction to the world of programming and software development. Well worth learning! I'm always here to answer questions, programming related or otherwise. Reply here or send me a PM any time you need anything -Apa thank you so much man! Quote Link to comment Share on other sites More sharing options...
Steven Jay Posted July 29, 2020 Share Posted July 29, 2020 Very nice thank you! Surely this should all still work? 1 Quote Link to comment Share on other sites More sharing options...
KingPeriwinkle Posted August 10, 2020 Share Posted August 10, 2020 how do i make a mimic bot? Quote Link to comment Share on other sites More sharing options...
mike3zx Posted August 17, 2020 Share Posted August 17, 2020 I've recently started looking into learning to script and was wondering where do you suggest I go from here to learn more about scripting. I have no prior knowledge and would like to see someone make simple scripts like in a video or something like free lessons. Thanks for any advice and I really appreciate the guide Quote Link to comment Share on other sites More sharing options...
Apaec Posted August 17, 2020 Author Share Posted August 17, 2020 1 hour ago, mike3zx said: I've recently started looking into learning to script and was wondering where do you suggest I go from here to learn more about scripting. I have no prior knowledge and would like to see someone make simple scripts like in a video or something like free lessons. Thanks for any advice and I really appreciate the guide You can get a really long way by trying (and failing!) to write scripts of your own. This kind of stuff is much better learned by doing, rather than through lessons, guides or videos. Think of a cool script that you want to write, make sure it is simple, and give it a shot! Good examples of simple scripts are those which have a very basic task which can be gradually expanded. For example, a woodcutting script can start by just clicking on trees. Then, you can add appropriate delays and pauses, dropping, walking, banking, upgrading axes, etc etc. As always, if you have any questions, post em here and i'll do my best to answer! -Apa 1 Quote Link to comment Share on other sites More sharing options...