Blueorb Scripts Posted November 1, 2015 Share Posted November 1, 2015 I'm in need of assistance with my first script. I've been working on it for a week now and have been looking at a lot of the popular tutorials in the section. I have yet to find one that helps with a GUI. I've even looked at old scripts to see how some people may have done it; but found nothing. I'm not referring to paint, that I have and is done. I'd like a GUI to pop up before the script starts with settings and the such to allow the user to input what they want the script to do. All help is appreicated. Quote Link to comment Share on other sites More sharing options...
Chris Posted November 1, 2015 Share Posted November 1, 2015 PlankerGUI gui = new PlankerGUI(this); gui.setVisible(true); try { while (gui.isVisible()) { sleep(100); } }catch (InterruptedException e){ e.printStackTrace(); } Quote Link to comment Share on other sites More sharing options...
Explv Posted November 1, 2015 Share Posted November 1, 2015 I'm in need of assistance with my first script. I've been working on it for a week now and have been looking at a lot of the popular tutorials in the section. I have yet to find one that helps with a GUI. I've even looked at old scripts to see how some people may have done it; but found nothing. I'm not referring to paint, that I have and is done. I'd like a GUI to pop up before the script starts with settings and the such to allow the user to input what they want the script to do. All help is appreicated. Read about Java Swing and how to use its components. 1 Quote Link to comment Share on other sites More sharing options...
Apaec Posted November 1, 2015 Share Posted November 1, 2015 Uhhhh depends what you wish to input. If it's a more complex set of variables which need adjusting before the script runs, you'll need a full gui which you design piece by piece with swing components. If you need just one (or maybe a couple) of variables changing for much more basic scripts, there are a few shortcuts. String s = JOptionPane.showInputDialog("Title", "Default option"); when you run this code, the script will open an input dialogue box which awaits user input. Once the user presses ok, it will save the input to the string 's' (as u can see from the code). You can do this with ints too.. If you need a more complicated gui like that of my rock crabs script: (somewhat outdated version but you get the idea) So ye, if you need something like that, I recommend you install the windowbuilderpro plugin for eclipse (if that's what you're using - if not then i'm sure you'll be able to find an equivalent plugin for your ide) You can install this plugin here (it will give you instructions on this page too: http://www.eclipse.org/windowbuilder/download.php ) Once you have that, it will make your life 10x easier. All you need to do after that is build the gui and send the variables to the main class using an actionListener on a start jbutton (for example). let me know if you have any further questions and i'll be willing to help apa 1 Quote Link to comment Share on other sites More sharing options...
Blueorb Scripts Posted November 1, 2015 Author Share Posted November 1, 2015 (edited) PlankerGUI gui = new PlankerGUI(this); gui.setVisible(true); try { while (gui.isVisible()) { sleep(100); } }catch (InterruptedException e){ e.printStackTrace(); } Thank you very much, I'll look into this code after my homework. I've seen you around the script dev section a lot and have been following your progress. Greatly appreicated. I hope to join scripter II when I meet the prerequisites. Read about Java Swing and how to use its components. Will do. My room mate may actually know of this, hes taking game development and is in our programming II course in which the main language they teach in until progamming III is Java. I'll speak to him about this. Uhhhh depends what you wish to input. If it's a more complex set of variables which need adjusting before the script runs, you'll need a full gui which you design piece by piece with swing components. If you need just one (or maybe a couple) of variables changing for much more basic scripts, there are a few shortcuts. String s = JOptionPane.showInputDialog("Title", "Default option"); when you run this code, the script will open an input dialogue box which awaits user input. Once the user presses ok, it will save the input to the string 's' (as u can see from the code). You can do this with ints too.. If you need a more complicated gui like that of my rock crabs script: (somewhat outdated version but you get the idea) So ye, if you need something like that, I recommend you install the windowbuilderpro plugin for eclipse (if that's what you're using - if not then i'm sure you'll be able to find an equivalent plugin for your ide) You can install this plugin here (it will give you instructions on this page too: http://www.eclipse.org/windowbuilder/download.php ) Once you have that, it will make your life 10x easier. All you need to do after that is build the gui and send the variables to the main class using an actionListener on a start jbutton (for example). let me know if you have any further questions and i'll be willing to help apa Your tutorial for learning how to begin writing scripts is actually where I started from and I cannot thank you enough. I actually didn't realize how easy a lot of this is due to the API. I've looked at another member's custom API like OSBot's, however opted out to focus on learning more about OSB's API. I've been building off your sample tea thiever and will be converting it to a node "framework" soon to be more efficient on lower end PCs. I'm using it as a base to learn off of and hopefully expand it to more than just tea thieving which my version mellows out at 6k XP/hour due to my massive delays I have in place. I don't need a complex GUI such as your rock crab script. Thats a bit overdoing it for a simple something like this. I plan to just have a check box to see if the user (me) wants to bank the tea at the cost of a lower XP/hour. This is just helping us produce our script we plan to release which more details will be available when it comes time. I've been programming in .NET for a while now so a GUI is easier to work with for me. Thank you all very much for your time. If anyone else wishes to contribute or add more resources, I'd greatly appreciate it. Edited November 1, 2015 by Blueorb Scripts 2 Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted November 1, 2015 Share Posted November 1, 2015 Thank you very much, I'll look into this code after my homework. I've seen you around the script dev section a lot and have been following your progress. Greatly appreicated. I hope to join scripter II when I meet the prerequisites. Will do. My room mate may actually know of this, hes taking game development and is in our programming II course in which the main language they teach in until progamming III is Java. I'll speak to him about this. Your tutorial for learning how to begin writing scripts is actually where I started from and I cannot thank you enough. I actually didn't realize how easy a lot of this is due to the API. I've looked at another member's custom API like OSBot's, however opted out to focus on learning more about OSB's API. I've been building off your sample tea thiever and will be converting it to a node "framework" soon to be more efficient on lower end PCs. I'm using it as a base to learn off of and hopefully expand it to more than just tea thieving which my version mellows out at 6k XP/hour due to my massive delays I have in place. I don't need a complex GUI such as your rock crab script. Thats a bit overdoing it for a simple something like this. I plan to just have a check box to see if the user (me) wants to bank the tea at the cost of a lower XP/hour. This is just helping us produce our script we plan to release which more details will be available when it comes time. I've been programming in .NET for a while now so a GUI is easier to work with for me. Thank you all very much for your time. If anyone else wishes to contribute or add more resources, I'd greatly appreciate it. As far as other APIs are concerned, they are typically made to bridge the gap between no knowledge and full knowledge (at least mine is). There are a lot of things that OSBot's API does that it shouldn't do, for example: getNpcs().closest("Dwarf").interact("Attack"); Will break your script if there is no "Dwarf" NPC. Little shameless self plug here, but my API allows this (eg no script breaking) getNPCFinder().findClosest("Dwarf").attack(); What you might notice in the change between .NET to Java that there isn't as much type checking (ie you do a lot of default(type) in .NET for a lot of classes whereas you don't really in Java). You also have to use the .equals(object) method in Java, instead of using == in .NET. Lastly, Java tends to use methods for public modifiers (eg .getItem() vs .Item). Good luck! 1 Quote Link to comment Share on other sites More sharing options...
Blueorb Scripts Posted November 1, 2015 Author Share Posted November 1, 2015 As far as other APIs are concerned, they are typically made to bridge the gap between no knowledge and full knowledge (at least mine is). There are a lot of things that OSBot's API does that it shouldn't do, for example: getNpcs().closest("Dwarf").interact("Attack"); Will break your script if there is no "Dwarf" NPC. Little shameless self plug here, but my API allows this (eg no script breaking) getNPCFinder().findClosest("Dwarf").attack(); What you might notice in the change between .NET to Java that there isn't as much type checking (ie you do a lot of default(type) in .NET for a lot of classes whereas you don't really in Java). You also have to use the .equals(object) method in Java, instead of using == in .NET. Lastly, Java tends to use methods for public modifiers (eg .getItem() vs .Item). Good luck! Ahh yes, you were the member I was referring to. I read your points against I think Alek about how yours is more useful or better in various cases. I be sure to take a look at after I learn more about Java which I start that class next semester and after I learn more about OSB's API. I've notice a few of Java's quirks; I already hate Eclipse. I would use another IDE but the college prefers us to use eclipse so I don't see why I would want to get settled in with another one in the event I need programming help from a teacher or fellow student. Quote Link to comment Share on other sites More sharing options...
Apaec Posted November 1, 2015 Share Posted November 1, 2015 Ahh yes, you were the member I was referring to. I read your points against I think Alek about how yours is more useful or better in various cases. I be sure to take a look at after I learn more about Java which I start that class next semester and after I learn more about OSB's API. I've notice a few of Java's quirks; I already hate Eclipse. I would use another IDE but the college prefers us to use eclipse so I don't see why I would want to get settled in with another one in the event I need programming help from a teacher or fellow student. nothing wrong with eclipse Also, i wouldn't say node frameworks were more efficient. Infact potentially less so. I guess they are a bit more organised and have a different style which makes it appropriate for some projects and unnecessary for others. But yes, gl, and as I said, let me know if you have any more questions apa 1 Quote Link to comment Share on other sites More sharing options...
Explv Posted November 2, 2015 Share Posted November 2, 2015 (edited) As far as other APIs are concerned, they are typically made to bridge the gap between no knowledge and full knowledge (at least mine is). There are a lot of things that OSBot's API does that it shouldn't do, for example: getNpcs().closest("Dwarf").interact("Attack"); Will break your script if there is no "Dwarf" NPC. Little shameless self plug here, but my API allows this (eg no script breaking) getNPCFinder().findClosest("Dwarf").attack(); What you might notice in the change between .NET to Java that there isn't as much type checking (ie you do a lot of default(type) in .NET for a lot of classes whereas you don't really in Java). You also have to use the .equals(object) method in Java, instead of using == in .NET. Lastly, Java tends to use methods for public modifiers (eg .getItem() vs .Item). Good luck! "As far as other APIs are concerned, they are typically made to bridge the gap between no knowledge and full knowledge (at least mine is). There are a lot of things that OSBot's API does that it shouldn't do" That IS what it should do, it makes sense in your program to write NPC dwarf = getNpcs().closest("Dwarf"); if( dwarf != null ) dwarf.interact("Attack"); So that you can then handle the case where there isn't a Dwarf nearby. NPC dwarf = getNpcs().closest("Dwarf"); if( dwarf != null ) dwarf.interact("Attack"); else log("Where's he gone??"); It doesn't make sense to create a seperate method in an API to handle the null case, just sayin' ;) Edited November 2, 2015 by Explv Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted November 2, 2015 Share Posted November 2, 2015 "As far as other APIs are concerned, they are typically made to bridge the gap between no knowledge and full knowledge (at least mine is). There are a lot of things that OSBot's API does that it shouldn't do" That IS what it should do, it makes sense in your program to write NPC dwarf = getNpcs().closest("Dwarf"); if( dwarf != null ) dwarf.interact("Attack"); So that you can then handle the case where there isn't a Dwarf nearby. NPC dwarf = getNpcs().closest("Dwarf"); if( dwarf != null ) dwarf.interact("Attack"); else log("Where's he gone??"); It doesn't make sense to create a seperate method in an API to handle the null case, just sayin' NPC dwarf = getNPCFinder().findClosest("Dwarf"); if (dwarf.exists()) dwarf.attack(); else log("wtf"); :/ :/ :/ :/ :/ Quote Link to comment Share on other sites More sharing options...
Explv Posted November 2, 2015 Share Posted November 2, 2015 NPC dwarf = getNPCFinder().findClosest("Dwarf"); if (dwarf.exists()) dwarf.attack(); else log("wtf"); :/ :/ :/ :/ :/ But how is that any different Quote Link to comment Share on other sites More sharing options...
Bobrocket Posted November 2, 2015 Share Posted November 2, 2015 (edited) But how is that any different Empty object will not throw errors when calling methods (thus making get...Finder.findClosest().interact/attack/pickpocket safe to use). Not null checking also allows a more understandable code base - "wouldn't an entity exist if it isn't null?". Edited November 2, 2015 by Bobrocket Quote Link to comment Share on other sites More sharing options...