Jump to content

GUI on Start


Blueorb Scripts

Recommended Posts

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.

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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:

DPVia9s.png

(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

  • Like 1
Link to comment
Share on other sites

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:

DPVia9s.png

(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 by Blueorb Scripts
  • Like 2
Link to comment
Share on other sites

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!

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 :D

 

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 :D

apa

  • Like 1
Link to comment
Share on other sites

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' ;) :doge:

 

 

 

Edited by Explv
Link to comment
Share on other sites

"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' wink.pngdoge.png

NPC dwarf = getNPCFinder().findClosest("Dwarf");
if (dwarf.exists()) dwarf.attack();
else log("wtf");

:/ :/ :/ :/ :/ :/ :/ :/ :/ :/

 

Link to comment
Share on other sites

But how is that any different doge.png

 

 

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 by Bobrocket
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...