Jump to content

Sebastian

Members
  • Posts

    283
  • Joined

  • Last visited

  • Feedback

    100%

Everything posted by Sebastian

  1. Yea it looks really cancerous. I'm already using IntelliJ but school really wants us to use BlueJ. Well, there's no option i guess.
  2. Sadly i need to use blueJ because they want to give a preliminary examination..
  3. Hi everyone, What are your thoughts on BlueJ for Java? My uni wants me to use BlueJ to learn classes and objects but i don't really enjoy it. The editor is ugly and i already understand classes and objects.
  4. Lol sick. I had to pay 20 euro for one year.
  5. I've really enjoyed Oculus. It has a good story and a lot of mindfucks.
  6. My account is blocked due to too many incorrect login attempts. I've mailed them a month ago and still didn't get any email. If i were you i shouldn't expect an email soon.
  7. I've just received a Lynda.com subscription from my university. I see that they have Java tutorials. Should i follow them? Are they any good?
  8. Well, @IDontEvenBot I would still like to thank you for your time and effort :).
  9. I've fixed it! This is how i've done it: I've changed: public class cooksassistant extends MethodProvider { into: public cooksassistant(Script i) throws InterruptedException Now i have to put an 'i' before i use osbot api. Like so: NPC cook = i.npcs.closest("Cook"); cook.interact("Talk-to"); i.log("Talking to Cook"); Not sure how i fixed it but i fixed it lol. Lol, we did the same but different xD
  10. What do you mean? It gives me the error: java.lang.NullPointerException
  11. Hi Jamie, Thanks for your answer. The problem is that i can't read anything because the logger goes too fast and i can't scroll up since the client is frozen.
  12. Hi Osbot, My script is freezing when i try to start the cooks assistant quest. Why is this? I have 3 classes: main, gui & cooksassistant. When i select cooks assistant in the gui and press start, the whole client freezes. Main class: import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import java.awt.*; @ScriptManifest(author = "Sebastian", info = "All F2P Quests", name = "SB Quester", version = 0, logo = "") public class main extends Script { public String quest = ""; Object lock = new Object(); private gui gui = new gui(); private cooksassistant cooksAssistant = new cooksassistant(); @Override public void onStart() { log("Starting script.."); gui.run(this); } private enum State { COOKSASSISTANT, WAIT }; private State getState() { if (quest == "Cooks Assistant") return State.COOKSASSISTANT; return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()) { case COOKSASSISTANT: cooksAssistant.run(); break; case WAIT: sleep(random(500, 700)); break; } return random(200, 300); } @Override public void onExit() { log("Goodbye"); } @Override public void onPaint(Graphics2D g) { } } GUI: JComboBox<String> questList = new JComboBox<String>(new String[] { "None", "Cooks Assistant"}); questList.addActionListener(e -> main.quest = (String) questList.getSelectedItem()); Cooksassistant class: import org.osbot.rs07.script.MethodProvider; public class cooksassistant extends MethodProvider { public void run() { log("Talking to Cook"); } } Does someone know what the problem is here?
  13. 10/10 Laravel. Also, i would use VueJS.
  14. Did you try restarting your laptop?
  15. Oh, you are not a hater! I love critisizm so i can improve myself :). Thanks for the feedback.
  16. Sebastian's GUI Tutorial Intro Hi, and welcome to my guide on how to make a GUI. I want to make this thread because i couldn't find a tutorial on GUI's on the OSBot forums. Today we are going to make a GUI for a woodcutting script. Keep in mind that i only use woodcutting as an example. You can easily replace woodcutting with every other thing. In this tutorial we will use Java Swing. This tutorial is "noob" friendly but i assume that you know a little bit about Osbot scripting. If you don't, please follow Apae's tutorial on how to make your first script We are creating a GUI with comboBox and a start button. NOTE: English is not my first language so bear with me if i use any spelling mistakes in this tutorial. General information GUI stands for "Graphical User Interface". This is a box that will appear when you start your script. The user of your script can apply settings for your bot. What do we need? Basic Java knowledge Eclipse or IntelliJ Step 1: Creating the classes The first thing we need to do is creating the classes. I decided to make 2 classes: main gui First we create the gui class. public class gui { public void run() { // Enter new code } } Now we want to connect the gui class with the main class. We can do that by typing "main main" into the public void run(). Example: public class gui { public void run(main main) { // Enter new code } } To tell that the gui exists we need to write some code in the main class: private gui gui = new gui(); Now the gui class is connected with the main class. We will come back to this later on in this tutorial. To run the gui class on start we need to add "gui.run(this);" into our onStart() method in the main class. Example: public void onStart() { log("Starting script.."); gui.run(this); } Alright. We are done with creating the classes. Let's continue to the next step! Step 2: Creating the jFrame If you start your script now, nothing will appear. That's because we didn't make the GUI yet. We've only created the files to work with. So, the first thing we need to do is creating the jFrame. Switch back to your gui class and paste the following into the "Public void run(main main)": JFrame jFrame = new JFrame("OSBOT Tutorial GUI"); Cool! We've created our first jFrame! But.. We're not done yet. If you start your script now nothing will appear. That's because we haven't set the size and we didn't make it visible yet. That's what we're going to do now. So, under the "JFrame jFrame = new JFrame("OSBOT Tutorial GUI");" we need to paste the following: jFrame.setSize(300, 500); jFrame.setResizable(false); Alright, so now we've added the size and we've set the setResizable to false because we don't want users to resize the gui. The gui is still not visible yet but we're getting somewhere. Let's move on to the next step. Step 3: Creating a JPanel To make the gui a bit more beautiful we are going to add a panel. We will call this panel the "settings" panel. Inside this panel all our settings will be displayed. Paste the following code into the gui run void: JPanel settingsPanel = new JPanel(); TitledBorder leftBorder = BorderFactory.createTitledBorder("Settings"); leftBorder.setTitleJustification(TitledBorder.LEFT); settingsPanel.setBorder(leftBorder); settingsPanel.setLayout(null); settingsPanel.setBounds(5, 200, 280, 180); jFrame.add(settingsPanel); This will add a panel to our jFrame. This seems like a lot of code so let me break it down to you. JPanel settingsPanel = new JPanel(); This will create the settingsPanel. TitledBorder leftBorder = BorderFactory.createTitledBorder("Settings"); This creates a titled border with the word "Settings" in it. jFrame.add(settingsPanel); This will add the settingsPanel to our jFrame. Alright, your code should look like this: public class gui { public void run(main main) { JFrame jFrame = new JFrame("OSBOT GUI Tutorial"); jFrame.setSize(300, 500); jFrame.setResizable(false); JPanel settingsPanel = new JPanel(); TitledBorder leftBorder = BorderFactory.createTitledBorder("Settings"); leftBorder.setTitleJustification(TitledBorder.LEFT); settingsPanel.setBorder(leftBorder); settingsPanel.setLayout(null); settingsPanel.setBounds(5, 200, 280, 180); jFrame.add(settingsPanel); } } We also need to create a start panel. This is only to make the gui a bit more beautiful. JPanel startPanel = new JPanel(); startPanel.setLayout(null); startPanel.setBounds(5, 350, 70, 20); jFrame.add(startPanel); Now it's time to get to the next step; adding the comboBox. Step 3: Adding the label & combobox First, we need to create a label. A label can be made like this: JLabel treeSelection = new JLabel("Select a Tree:"); Second, we need to set some bounds and we need to add the Label to our settingsPanel. treeSelection.setBounds(10, 40, 95, 20); settingsPanel.add(treeSelection); Alright. We've added our first label into our settingsPanel! Now we need to create the comboBox: JComboBox<String> treeList = new JComboBox<String>(new String[] { "None", "Tree", "Oak", "Willow", "Yew", "Magic tree"}); Next, open your main class and create a public string called tree: public String tree = ""; Once you've done that you need to go back to your gui class. To check what tree you have selected we need to add an eventlistener: treeList.addActionListener(e -> main.tree = (String) treeList.getSelectedItem()); This will set the public String tree in your main class to the selected tree. For example: If i selected Oak, the script will make the public String tree like this: public String tree = "Oak"; So now the script knows what tree you'd like to chop :). Alright, next thing we need to do is setting the bounds and add it to our settingsPanel. treeList.setBounds(160, 40, 110, 20); settingsPanel.add(treeList); Ok. So far we've created a jFrame, added the settings & start panel, added a Label and added a working comboBox. Your gui class should look like this: public class gui { public void run(main main) { JFrame jFrame = new JFrame("OSBOT GUI Tutorial"); jFrame.setSize(300, 500); jFrame.setResizable(false); JPanel settingsPanel = new JPanel(); TitledBorder leftBorder = BorderFactory.createTitledBorder("Settings"); leftBorder.setTitleJustification(TitledBorder.LEFT); settingsPanel.setBorder(leftBorder); settingsPanel.setLayout(null); settingsPanel.setBounds(5, 200, 280, 180); jFrame.add(settingsPanel); JPanel startPanel = new JPanel(); startPanel.setLayout(null); startPanel.setBounds(5, 350, 70, 20); jFrame.add(startPanel); JLabel treeSelection = new JLabel("Select a Tree:"); treeSelection.setBounds(10, 40, 95, 20); settingsPanel.add(treeSelection); JComboBox<String> treeList = new JComboBox<String>(new String[] { "None", "Tree", "Oak", "Willow", "Yew", "Magic tree"}); treeList.addActionListener(e -> main.tree = (String) treeList.getSelectedItem()); treeList.setBounds(160, 40, 110, 20); settingsPanel.add(treeList); } } Step 4: Adding the start button We're almost done! The only thing we still need to do is: Adding the start button Making the start button work with an actionlistener First, in our main class we need to add a lock. This will prevent the script from starting when the gui is still open. Go to your main class and insert the following code: Object lock = new Object(); Because we call the gui class on start, this will lock the script from running. Next we need to create a button: JButton startButton = new JButton("Start"); Second, create an actionlistener so when the button is pressed, the script will start. startButton.addActionListener(e -> { synchronized (main.lock) { main.lock.notify(); } jFrame.setVisible(false); }); This will unlock the script and the jFrame will dissapear. In other words: your script will start. Third, we need to add some bounds and make the button visible: startButton.setBounds(5, 390, 70, 20); startPanel.add(startButton); And last but not least, set the jFrame to visible otherwise you won't see anything when you start your script. jFrame.setVisible(true); Alright! We are done! Go export your script and check it out. The gui should look like this: Whole GUI Class: public class gui { public void run(main main) { JFrame jFrame = new JFrame("OSBOT GUI Tutorial"); jFrame.setSize(300, 500); jFrame.setResizable(false); JPanel settingsPanel = new JPanel(); TitledBorder leftBorder = BorderFactory.createTitledBorder("Settings"); leftBorder.setTitleJustification(TitledBorder.LEFT); settingsPanel.setBorder(leftBorder); settingsPanel.setLayout(null); settingsPanel.setBounds(5, 200, 280, 180); jFrame.add(settingsPanel); JPanel startPanel = new JPanel(); startPanel.setLayout(null); startPanel.setBounds(5, 350, 70, 20); jFrame.add(startPanel); JLabel treeSelection = new JLabel("Select a Tree:"); treeSelection.setBounds(10, 40, 95, 20); settingsPanel.add(treeSelection); JComboBox<String> treeList = new JComboBox<String>(new String[] { "None", "Tree", "Oak", "Willow", "Yew", "Magic tree"}); treeList.addActionListener(e -> main.tree = (String) treeList.getSelectedItem()); treeList.setBounds(160, 40, 110, 20); settingsPanel.add(treeList); JButton startButton = new JButton("Start"); startButton.addActionListener(e -> { synchronized (main.lock) { main.lock.notify(); } jFrame.setVisible(false); }); startButton.setBounds(5, 390, 70, 20); startPanel.add(startButton); jFrame.setVisible(true); } } The end of this tutorial I hope you liked my tutorial on how to make a simple GUI for your script. Go play around with it and become better with Java Swing. If you have any questions please ask.
  17. Hey @Lemons, Thank you for your quick reply! It worked like a charm :). Would this be the same method for a GUI class? EDIT:: Created a GUI the same way as you told me without extending the MethodProvider Thanks again dud.
  18. Hi everyone, I need to know how to use multiple classes. I'm creating a little quester. I have a main class with the onloop() and i have a class for the cooks assistent quest called cookassistent. I want to script the whole procedure of cooks assistent in that class. How would i do that?
  19. It's very common that people haven't found their 'thing' in their 20's yet. I was struggling with finding my 'thing' too. I have found my thing when i was around 21,5. I love people. I love the way people act, I love the way people are thinking, I like helping people, I love the human Brain (What it's able to), (lucid) dreaming etc etc. It's just too fuckin' fascinating that we are human and that we can do a lot of things. Actually, i need to finish my last year of programming and then i will follow a master course Psychology. I'm 90% sure that that is my thing, but if it isn't.. well.. Then it's just a good life lesson for me. Like i said: Find your thing, don't fuckin' think so much. Thinking is good, but not too much. It's not worth the trouble. Enjoy life when you can. Also, it's just a fase. Almost everyone in their 20's have this problem.
  20. Very negative thoughts if you ask me. Thinking that you came on this world and die at the end. It's true tho, but life has been given to you. So, live everyday. Do something with your life. Don't just sit behind your desktop everyday. Make friends, find love, find your 'thing' in life and discover. Life has so much things for you. You just need to be open for it so you can find it. If you're really struggling with this; please find an psychologist. And i didn't mean that in a bad way.
  21. iPhone 7 here (let the hate begin)
  22. @Token for trial mod. He's a nice lad. Always in for helping another.
  23. ALMOST. HAVE SCHOOL TILL 17:00 SO I STILL NEED A WHILE
  24. Thanks! I will be also looking into React and Redux.
  25. Hey everyone. So, i have a small question. I'm currently re-writing a business website for a school project. I am familiar with JavaScript but i have a bit knowledge about extentions like VueJS, Ajax, AngularJS etc etc. My school is pushing about using VueJS because it's lightweight and easy to use. What i know is that VueJS is almost the same as AngularJS but newer. I have been using VueJS for some time now and it's really fine to use. But, as someone who likes feedback, i'm asking you guys if i should keep using VueJS or stick to AngularJS. What are your thoughts about VueJS and are you using it? Sebastian
×
×
  • Create New...