iTz EcLiPsE Posted January 11, 2016 Share Posted January 11, 2016 working on a cooking script after i use my fish on the range the box pops up asking how many to fish how can i get the script to interact with the box to select cook all (same with fletching and alot of other skills) plz help Quote Link to comment Share on other sites More sharing options...
KEVzilla Posted January 11, 2016 Share Posted January 11, 2016 Widgets. Quote Link to comment Share on other sites More sharing options...
Acerd Posted January 11, 2016 Share Posted January 11, 2016 (edited) Widgets if (getWidgets().isVisible(parent,child) { getWidgets().interact(parent, child, action) } you can get widgets from the debugger Edited January 11, 2016 by Assnerd Quote Link to comment Share on other sites More sharing options...
iJodix Posted January 11, 2016 Share Posted January 11, 2016 Widgets ok = getWidgets().getWidgetContainingText("Howm anyblablabla?"); ok.interact("Cook-All"); 1 Quote Link to comment Share on other sites More sharing options...
Dieze Posted January 11, 2016 Share Posted January 11, 2016 Have you tried turning it off and on again? 1 Quote Link to comment Share on other sites More sharing options...
Token Posted January 11, 2016 Share Posted January 11, 2016 if (widgets.getAll().stream().filter(w -> w.isVisible() && w.hasAction("Cook All")).count > 0) widgets.getAll().stream().filter(w -> w.isVisible() && w.hasAction("Cook All")).findFirst().get().interact("Cook All"); The above code will select the option "Cook All" on any widget if the widget is visible. Make sure the action is spelled correctly with uppercase C and A as I don't know if it's supposed to be uppercase or lowercase A. Quote Link to comment Share on other sites More sharing options...
iTz EcLiPsE Posted January 11, 2016 Author Share Posted January 11, 2016 awesome thank you guys ill give this a try and see how it goes Have you tried turning it off and on again? yea multiple time lmao Quote Link to comment Share on other sites More sharing options...
demmonic Posted January 12, 2016 Share Posted January 12, 2016 if (widgets.getAll().stream().filter(w -> w.isVisible() && w.hasAction("Cook All")).count > 0) widgets.getAll().stream().filter(w -> w.isVisible() && w.hasAction("Cook All")).findFirst().get().interact("Cook All"); The above code will select the option "Cook All" on any widget if the widget is visible. Make sure the action is spelled correctly with uppercase C and A as I don't know if it's supposed to be uppercase or lowercase A. That's inefficient as hell. Why aren't you caching the Widget from the first query and reusing it? Quote Link to comment Share on other sites More sharing options...
Token Posted January 12, 2016 Share Posted January 12, 2016 That's inefficient as hell. Why aren't you caching the Widget from the first query and reusing it? Filtering streams is actually very fast. You may cache the widget if you want but then you will continously null check it and verify its visibility which you pretty much do with the above code. As a general rule when writing code, you first make it work and in future iterations you begin optimising it. Quote Link to comment Share on other sites More sharing options...
demmonic Posted January 12, 2016 Share Posted January 12, 2016 (edited) Filtering streams is actually very fast. You may cache the widget if you want but then you will continously null check it and verify its visibility which you pretty much do with the above code. As a general rule when writing code, you first make it work and in future iterations you begin optimising it. You're talking to the wrong person about "general rules of writing code". It doesn't matter if it's "fast", you're sacrificing readability & performance for absolutely no reason. You shouldn't write shit code when another (better) solution is so blatantly obvious. Not only is it shorter (and therefore more readable), but it performs significantly faster. Also, your code has a race condition. If the Widget state changes in between those 2 calls, you're going to get an NPE depending on the API implementation. tl;dr stop giving shit, buggy code to beginners Edited January 12, 2016 by demmonic 2 Quote Link to comment Share on other sites More sharing options...
iTz EcLiPsE Posted January 12, 2016 Author Share Posted January 12, 2016 You're talking to the wrong person about "general rules of writing code". It doesn't matter if it's "fast", you're sacrificing readability & performance for absolutely no reason. You shouldn't write shit code when another (better) solution is so blatantly obvious. Not only is it shorter (and therefore more readable), but it performs significantly faster. Also, your code has a race condition. If the Widget state changes in between those 2 calls, you're going to get an NPE depending on the API implementation. tl;dr stop giving shit, buggy code to beginners lol i didnt understand half of what u said lmao i dont know how to do much for scripting so im sure most of my code is broken or insufficient anyway just trying to make something actually work for learning until i understand alot more so i can actually release scripts any advise or maybe tutorials u recommend are appreciated.. Quote Link to comment Share on other sites More sharing options...
demmonic Posted January 12, 2016 Share Posted January 12, 2016 lol i didnt understand half of what u said lmao i dont know how to do much for scripting so im sure most of my code is broken or insufficient anyway just trying to make something actually work for learning until i understand alot more so i can actually release scripts any advise or maybe tutorials u recommend are appreciated.. I don't really care for tutorials as you can't really encompass a whole language in something that small. I would recommend a book to get an overview of the language, and to act as a reference when you can't figure something out (google helps too.) Other than that, practice makes perfect. The sole reason I don't like people suggesting stuff like that to a beginner is because it's easy to form habits when you don't know any better, but it's generally hard to change them. Anyways, you can always PM me your Skype if you want real time help. I'd be happy to help/give advice in my free time. Quote Link to comment Share on other sites More sharing options...
iTz EcLiPsE Posted January 12, 2016 Author Share Posted January 12, 2016 I don't really care for tutorials as you can't really encompass a whole language in something that small. I would recommend a book to get an overview of the language, and to act as a reference when you can't figure something out (google helps too.) Other than that, practice makes perfect. The sole reason I don't like people suggesting stuff like that to a beginner is because it's easy to form habits when you don't know any better, but it's generally hard to change them. Anyways, you can always PM me your Skype if you want real time help. I'd be happy to help/give advice in my free time. that sounds awesome thank you any particular book u recommend??i think alot of my issues when it comes to writing code (besides being new to it) is i dont know the commands and what all the commands mean and do Quote Link to comment Share on other sites More sharing options...
Token Posted January 12, 2016 Share Posted January 12, 2016 You're talking to the wrong person about "general rules of writing code". It doesn't matter if it's "fast", you're sacrificing readability & performance for absolutely no reason. You shouldn't write shit code when another (better) solution is so blatantly obvious. Not only is it shorter (and therefore more readable), but it performs significantly faster. Also, your code has a race condition. If the Widget state changes in between those 2 calls, you're going to get an NPE depending on the API implementation. tl;dr stop giving shit, buggy code to beginners I highly doubt flaming me for trying to help him solve his problem is going to get you anywhere. But if you do insist on trying to prove I'm wrong, you aren't going to get anywhere because simply by saying that my condition is wrong and the widget state can change between those 2 calls prove you don't know anything about scripting, the OSBot API or programming in general. Some reputable scripters on this site have public APIs they implemented in their scripts which you might want to take a look at before accusing my code of being "shit", you definately have a lot to learn from that and you might be surprised to find solutions very similar to the one I presented above. TL;DR: Find something constructive to do with your time. Quote Link to comment Share on other sites More sharing options...
demmonic Posted January 13, 2016 Share Posted January 13, 2016 I highly doubt flaming me for trying to help him solve his problem is going to get you anywhere. ... TL;DR: Find something constructive to do with your time. I'm not flaming in any way. Yes, I called the tiny snippet of code you posted buggy, and "shit". That is not me flaming you in any way. If you want to get all defensive and post bullshit insults towards me as a person (you've done this several times now, acting like I'm an idiot who doesn't know how to program), then go for it, pal. You're the one that needs to find something constructive to do with your time. But if you do insist on trying to prove I'm wrong, you aren't going to get anywhere because simply by saying that my condition is wrong and the widget state can change between those 2 calls prove you don't know anything about scripting, Prove it then buddy. I'm a bot developer unlike you, and unless the scripting is handled on the game engine's thread (it's not.) You have a race condition! Some reputable scripters on this site have public APIs they implemented in their scripts which you might want to take a look at before accusing my code of being "shit", you definately have a lot to learn from that and you might be surprised to find solutions very similar to the one I presented above. Ok? So you're going to defend yourself by saying that other bad developers are doing what you're doing? Hooray for confirmation bias! Also, more passive aggressive insults via your big ego! Yes yes, you know everything, and I know nothing. Please don't even bother replying to me, I'm ending this here. You're too stupid to listen to anything I have to say. You throw personal insults everywhere, go off topic, and are extremely stubborn. 1 Quote Link to comment Share on other sites More sharing options...