Jump to content

Glaciation96

Members
  • Posts

    76
  • Joined

  • Last visited

  • Feedback

    0%

Everything posted by Glaciation96

  1. Hello folks, Could I get some help to understand what is going on in the Sleep class please? I understand that it allows your script to use lambdas when sleeping, and you'll just be calling the static sleepUntil method, which fills out the Sleep constructor and returns its own object method, but my question is; When does the mandate override boolean method condition() get called? It returns the functional method from BooleanSupplier, but I can't seem to follow the code from around this point. Is there perhaps a link between the member variable 'condition' and the override method condition()? It's not just there because it extends ConditionalSleep is it? I'm guessing it's actually doing something.. Any help would be greatly appreciated. I've been stumped by this for around a week now so I thought I had to ask. Many thanks!
  2. 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!
  3. 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!
  4. Howdy, Was an amazing script for the short time that I had it (I'm no longer a member). I liked the display, such as GUI and curser. Made the simple fact of using the bot feel good. It's a late revisit, but I have some minor feedback as I may start playing/botting again soon. From what I've seen, I don't think the bot loot Rannarr seeds does it? They're quite valuable so if it's not a feature yet, I think it would make a good addition! Well, really depends on how rich the people are who use this. I'm poor so it makes a difference to me?
  5. 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?
  6. Wow. I've just discovered a valuable resource.
  7. 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?
  8. 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.
  9. I return to this thread in shame, sorry guys. Mission failed. researched into multithreading and it looks like such a powerful tool! Thanks for bringing this up to me, but the struggle is real. Requesting guidance, please! I'll try to make this as easy to answer as possible by going through the logic in my code! Did I at least get close? For context, what I shared are the only changes that I made, in regards to trying to implement multithreading... Also, the bot worked before this, albeit the multiple interactions to fish. When I start the bot, I can't tell what's wrong really... The bot doesn't even do anything and then the client goes incredibly slow, then crashes. I'm guessing it's due to my infinite loop? But isn't that just to keep checking/updating the 1 bool? Since I wrote the code, my snippet looks quite easy to read for me, but obviously, it'll be different for other people. I hope I've made answering this as easy as possible! There could be a couple things wrong, or a million. If it's just a messy pile of mistakes making it too much effort to answer, just let me know. That way at least I know I'm not even close, so instead of making minor changes to try getting this to work, I can just scrap it for a whole new approach to the multithreading issue. Thanks a bunch fellas. EDIT: Improving readability
  10. Thanks for the additional info! I've not given Malcolm's method a go yet as I've just 'completed' my script, so just focused on fixing the minor errors right now before I move onto implementing improvements (like tackling the double interaction properly). I'll definitely want to take a look into what you suggested as well. I made a quick search, and I assume it's called java concurrency and/or multithreading which you're referring to.
  11. So the object class is the super class of all super classes, basically? I never looked into it before, but always assumed that a super class never inherited anything themselves. Guess there are many layers upon layers of this class hierarchy. Your explanation deepened my perspective on java, very informative, thanks! Unfortunately, it's now question time... (sorry lol) I'm sure you've all experienced this before, but when it comes to fishing (and possibly other activities), if you double-click the fishing spot, the player will stop fishing after looping through the fishing animation 3 times (about 5 seconds of fishing), forcing you (or the bot) to click the spot again. If you click it once, it's fine. The character will fish until the spot goes or inv is full. The bot will always double click if you use the standard/basic method, which is obviously 'interact -> conditional sleep'. The bot will always try to interact with the fishing spot a second time as the conditional sleep returns !myPlayer().isAnimating(). But obviously, the character doesn't fish, or initiate the fishing animation as soon as the interaction is made which is the reason. Is adding the general sleep(random(small sleep here)) just before the conditional sleep to return !myPlayer().isAnimating() the only way to bypass the double interaction? The drawback of this for me is that the general sleep time just slows down the onLoop rate for the bot itself. It hurts my script since I rely on the continuous looping to check if there are any free fish on the ground whilst fishing lol. Just wondering if there is a convenient method for improvement on this little drawback, maybe like the conditional sleep returning some secret condition I don't know about If the solution is something like implementing lambdas, just tell me there's no solution lol Yes apa, I took your advice to make use of the continuous onLoop for my second script Thanks fellas!
  12. Yes, it is for shift dropping. That aside, that was a lot of information. Very much appreciated! Constantly checking your bot is a skill lol. I think the way I've structured mine, it'll just break before it gets to the part I'm unsure of, probably, then forcing me to patch up my script in other areas when I'd prefer to finish up what I'm currently working on. I tend to 'finish' the script before running tests, ultimately taking the brunt of all my mistakes at once? Should definitely get into the habit of being able to test as I go for sure though. Thanks for the help!
  13. Guess who's back? Got a quick one this time getKeyboard().pressKey(KeyEvent.VK_SHIFT); for (int i = 0; i < invSlotIndex.length; i++) { Item item = getInventory().getItemInSlot(i); if (item != null && !item.nameContains(levelFishType.getTool())) { //Look in this line //Interact etc } } So I've been working on my second script still, and it's nowhere near 'testing ready', which makes knowing if certain methods from the API actually do what I THINK they do. It's more difficult to get the answer if no one has covered the method in the forums. So I guess the question is, have you ever used item.nameContains() before? Does it simply grab the names of items like a sort of filter? I'm trying to drop items in a randomised fashion by grabbing the index of inventory slots, then proceeding to drop the item in that slot IF it's not something important like my Lobster pot. This is stated in my String[] named levelFishType.getTool(). I've already tried: item.getName().equals(levelFishType.getTool()) But it's giving me this error: Unlikely argument type for equals(): String[] seems to be unrelated to String Which is rather strange, unless .equals only strictly take strings and not string arrays. Thanks!
  14. Ahh so it was to do with something in an entirely different aspect of Java, perfect, I'll look into those, cheers!
  15. Hey there, got another problem. Been quite a while! Slowly getting there... It's about enums again, and passing parameters. As a bottom feeder, I'm not too sure how to implement certain techniques properly, in this case, varargs? Below is a small snippet, hopefully it has everything you need to see what my issue is The mission here is to bank everything except the items that the bot will be using, plus coins. The above code works, but only if levelFishType isn't baitFishing. It won't crash the script, but instead the bot will bank everything except from the fishing rod(because of the [0] index), but bank the fishing bait which is not what I want. I've heard of varargs, and have tried multiple syntax combinations to try getting it to work. Could I get some guidance on this? For example, I've tried this, but obviously, it doesn't work. public final String[] Essentials = { levelFishType.getTool(String[]...varName), "Coins" }; Thanks!!
  16. Many thanks for the clarification! Gravedigging this thread turned out very beneficial to my understanding in the end ? EDIT: For the Array Stream, I'll have to come back to that in a few weeks time lol, but it's great to have it there for later reference.
  17. I'm not intentionally looking for old posts, just digging through all the resources that I can find, then commenting to test my own understanding of java/botting lol. Also does my code not make sense or not work? So long as it's not the latter I'm happy ? He also asked for "any items" which I guess could translate to all or just some of the items, to me anyway. Nice Explv's Map btw, been using that loads.
  18. Using this method, you're unable to single out an item from the array. You'll just withdraw everything in the array. Unless that is what you want, a method to pick out singular items from an array would be more useful surely? Would this work? String[] items = new String[] {"Coins", "Death rune"}; for (String i : items) { if (getBank().contains(i) { getBank().withdrawAll(i[0]); //For coins } }
  19. Not sure if you've implemented the stuff that malcolm has suggested, but that script you first shared should have lit Eclipse up with red lines. Unless your Eclipse isn't showing you any red lines despite the errors in code, it should have been obvious as to why it wouldn't start if it's riddled with red? Also, even if you don't have any red, it STILL may not start. I had that happen to me once, but Apaec was able to fix it for me. It's because I called something which I shouldn't have. Maybe you've done the same? Also, my last question was left unanswered:( I'm guessing it's because the guy who wrote that example probably went off on a weird, messy one. Making his code an effort to read. That's my bad. Not to worry as what he's doing apparently isn't good practice, so who needs to learn from that anyway right?! Lol. EDIT: If you go back a couple pages, you can see him fix this issue for me. It might leave a hint as to why your script won't start. Assuming that you've gotten rid of the red lines first of course.
  20. Thanks for the response! But unfortunately, I'm still not quite there When you said it will return false for every value of the variable 'currentFishType', I'm guessing, in that case, it'll be SMALLNET (as the script first starts anyway). Therefore those values being... "Small fishing net", "Net", new int[]{303} Right? But the confusion is that, when does currentFishType actually have the values of FishingType.LEVEL? I ctrl+f searched for " = FishingType.LEVEL", and he never once sets anything to be FishingType.LEVEL. The only time I see it being used is when he doubles up the =, so he only ever compares a value to FishingType.LEVEL. Sorry my understanding of Java is at the bottom of the barrel basic lol, so if he used another method to do this then there's the culprit for my confusion. Could it be possible that he's calling this comparison for the purpose of it returning false every time? Surely not, as that would achieve nothing... Thanks again!
  21. Hello fellas. The scrub is back. With a question as always. I'm trying to use the above example as a basis for my second script. He uses various techniques that are a step beyond what I've been using, so it's a good direction for me to further my understanding. However, there is something that I've been struggling to wrap my head around. It is this condition which he uses multiple times during his onLoop. if(currentFishType == FishingType.LEVEL) { //code here... } Those are variables that he had taken from his enum, to store his actions and tools, depending on the player's levels. I've copied it below. private FishingType currentFishingType = FishingType.SMALLNET; private enum FishingType{ SMALLNET("Small fishing net", "Net", new int[]{303}), LURE("Fly fishing rod", "Lure", new int[]{309, 314}), BAIT("Fishing rod", "Bait", new int[]{307, 313}), CAGE("Lobster pot", "Cage", new int[]{301}), HARPOON("Harpoon", "Harpoon", new int[]{311}), BIGNET("Big fishing net", "Net", new int[]{305}), LEVEL("?", "?", new int[]{}); private final String tool; private final String action; private final int[] reqItems; FishingType(String tool, String action, int[] reqItems) { this.tool = tool; this.action = action; this.reqItems = reqItems; } public String getTool() { return tool; } public String getAction() { return action; } public int[] getRequiredItems(){ return reqItems; } } From that information, isn't what he's doing no different than this? if(FishingType.SMALLNET == FishingType.LEVEL) { //code here } He's comparing two different variables or constants in his enum! Won't that just return false every time? What's the point in this? Been looking through this for a couple days now lol. Thought I'd finally ask for some assistance in understanding an example that was written by someone far better than me. Thanks. If this is confusing then I've missed out some necessary code from his script. Please check the link if that's the case please. Shouldn't take you pros too long to skim through his code right? ?
  22. It worked! No errors, thank you. Knowing what to declare and how to call out more complicated coding is a damn pain :/... Guess the next time I run into an issue like this, I gotta try calling out the parent code aswell. Whatever the proper term for that is...
  23. Hello there, Sorry if this is asking for a bit much, but I've been stuck on this for a while. Will share my code now. I've looked into numerous tutorials about enumeration and the like, how to use them with println etc, but the implementation here seems a little different for my scenario. I managed to get my last issue sorted with the fish pickup, but would like to move onto more advanced stuff. Right now, I'm working on a method which will be called to determine the type of fishing the bot will undertake. Basically, the question here is... How the hell do I call whatever it is I'm trying to achieve? Tried a couple ways, but with errors. Do I have to create additional variables? Or is it just a quick fix? Trying to make a more dynamic script which looks into the player's levels. Many thanks! EDIT: Or if there is a tutorial in Java which covers this, just pointing me there is more than enough! Same with if whether or not what I'm trying to do has a term. Typing "Implementing enums" into Google isn't giving the most desirable results in this case...
  24. Ahh that's great, means I'm on the right path lol, I'm also very new to this stuff and usually the one asking all the questions! Won't be long before I pop up with a new one aswell ?
×
×
  • Create New...