sonda Posted October 3, 2017 Share Posted October 3, 2017 I have watched some videos, searched the web, and this website for information pertaining to what Im trying to do, i haven't had any luck. I made an ore pick script, mainly so i can have one account Powermine, while the other picks up the loot and banks it. But would work for any dropped ore. I am mainly doing this for the learning aspect and i would REALLY prefer to have checkbox's with the different type of ore you want to pick up, with support for multiple ores. Quote Link to comment Share on other sites More sharing options...
TheWind Posted October 3, 2017 Share Posted October 3, 2017 (edited) I believe NetBeans has a windows builder built into it. I believe there is also a windows builder plugin for eclipse which is really good. If you're looking to make it from scratch (which is usually unnecessary) unless you're just learning the basic the java docs have really good examples of every component. http://docs.oracle.com/javase/tutorial/uiswing/components/button.html In terms of the basic setup, you would have a JFrame which is the main window. A JPanel which is basically like a context that is on the JFrame so you're not putting the components directly onto it. Then you would just add whatever components you need to the JPanel. Forgive me if I may have misinterpreted the question of your thread. Edited October 3, 2017 by TheWind Quote Link to comment Share on other sites More sharing options...
sonda Posted October 3, 2017 Author Share Posted October 3, 2017 I do have the window builder for eclipse, I can get to that point and even basically design the window. I'm having an issue of not knowing how to connect the dots. I can make a drop down box with different ore types that you can chose from. But making my script collect them is my issue. Quote Link to comment Share on other sites More sharing options...
Explv Posted October 3, 2017 Share Posted October 3, 2017 (edited) 1 hour ago, sonda said: I do have the window builder for eclipse, I can get to that point and even basically design the window. I'm having an issue of not knowing how to connect the dots. I can make a drop down box with different ore types that you can chose from. But making my script collect them is my issue. If you can't connect the dots then you need to revisit the basics of Java. In particular OOP, assuming your GUI is in a separate class. I would recommend you don't use a GUI builder, so you can actually learn how it works. Edited October 3, 2017 by Explv Quote Link to comment Share on other sites More sharing options...
sonda Posted October 3, 2017 Author Share Posted October 3, 2017 I like to see a working example of how things work, it helps me understand. The GUI is in a separate class, I believe it was one of your threads I was looking at that had a GUI tutorial. I have had good success with learning to write scripts by taking a working script and modifying it to do something completely different. Everybody is different I suppose. a decent GUI tutorial using the window builder would help a lot of people I believe. Quote Link to comment Share on other sites More sharing options...
Explv Posted October 3, 2017 Share Posted October 3, 2017 (edited) 8 minutes ago, sonda said: I like to see a working example of how things work, it helps me understand. The GUI is in a separate class, I believe it was one of your threads I was looking at that had a GUI tutorial. I have had good success with learning to write scripts by taking a working script and modifying it to do something completely different. Everybody is different I suppose. a decent GUI tutorial using the window builder would help a lot of people I believe. There are already tonnes of GUI tutorials and examples online, the way you do it in OSBot is no different. Just Google Swing Tutorials Edited October 3, 2017 by Explv Quote Link to comment Share on other sites More sharing options...
sonda Posted October 4, 2017 Author Share Posted October 4, 2017 Alright, I've been working at it for hours, i can get my script to work perfectly fine - without the Gui, but ive made loads and loads of changes back and forth trying to get it to work. i cannot figure it out =\ maybe somebody can tell be where am going wrong? The GUI pops up and everything appears to be correct visually. it just doesn't do what i want it to. I can also get it to work great with a Jcombobox i just really prefer the checkbox option for multiple types of gathering at once. I know i'm ignorant when it comes to this, i am very new at it and don't quite have the experience mind set some of you have. but i am willing to try - and learn. package OreLooter; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.GroundItem; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.JCheckBox; @ScriptManifest(author = "Brian", info = "Orelooter", name = "Orelooter", version = 0, logo = "") public class OreLooter extends Script implements ItemListener { static Object lock = new Object(); public gui gui = new gui(); private long copperoreCollected; private long prevInvCount; private long timeBegan; private long timeRan; private long hph; JCheckBox Clay = new JCheckBox("Clay"); @Override public void onStart() { gui.run(this); prevInvCount = getInventory().getAmount(436); timeBegan = System.currentTimeMillis(); } private enum State { COLLECT, FULL, WALK, WAIT } private State getState() { Area MINE = new Area(3232, 3143, 3221, 3149); if (inventory.isFull()) return State.FULL; if (!inventory.isFull() && MINE.contains(myPlayer())) return State.COLLECT; if (!MINE.contains(myPlayer()) && !inventory.isFull()) return State.WALK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { JCheckBox Clay = new JCheckBox("Clay"); JCheckBox Tin = new JCheckBox("Tin"); JCheckBox Copper = new JCheckBox("Copper"); JCheckBox Iron = new JCheckBox("Iron"); JCheckBox Coal =new JCheckBox("Coal"); if (Coal.isSelected())log("coal is selected"); long invCount = getInventory().getAmount(436); if (invCount > prevInvCount) setCOPPER_ORECollected(getCOPPER_ORECollected() + (invCount - prevInvCount)); prevInvCount = invCount; GroundItem Clayo = groundItems.closest("Clay"); GroundItem Tino = groundItems.closest("Tin ore"); GroundItem Coppero = groundItems.closest("Copper ore"); GroundItem Irono = groundItems.closest("Iron ore"); GroundItem Coalo = groundItems.closest("Coal"); switch (getState()) { case COLLECT: if (Clay.isSelected()) { if (Clayo != null && getMap().canReach(Clayo)) Clayo.interact("take"); } if (Tino != null && getMap().canReach(Tino) && Tin.isSelected()) { log("Tin selected"); Tino.interact("take"); } if (Copper.isSelected()) { log("Searching for Copper"); if (Coppero != null && getMap().canReach(Coppero)) log("Copper selected"); Coppero.interact("take"); } if (Irono != null && getMap().canReach(Irono) && Iron.isSelected()) { log("Iron selected"); Irono.interact("take"); } if (Coalo != null && getMap().canReach(Coalo) && Coal.isSelected()) { log("Coal selected"); Coalo.interact("take"); } sleep(2000); break; case FULL: walking.webWalk(new Position(3209, 3220, 2)); if (bank.isOpen()) { bank.depositAll(); } else { objects.closest("Bank booth").interact("Bank"); } break; case WALK: Area MINE = new Area(3232, 3143, 3221, 3149); walking.webWalk(MINE); case WAIT: } return (random(400, 1500)); } @Override public void onExit() { log("THANKS APAEC FOR ALL THE HELP"); } @Override public void onPaint(Graphics2D g) { hph = (int) (copperoreCollected / ((System.currentTimeMillis() - timeBegan) / 3600000.0D)); timeRan = System.currentTimeMillis() - this.timeBegan; Graphics2D gr = (Graphics2D) g; gr.setColor(Color.WHITE); gr.setFont(new Font("Arial", Font.BOLD, 12)); g.drawString(formatTime(timeRan), 440, 25); gr.drawString("Time:", 400, 25); gr.drawString("" + copperoreCollected, 440, 40); gr.drawString("Ores:", 400, 40); gr.drawString("Ores/h:", 400, 65); g.drawString("" + hph, 450, 65); gr.setColor(Color.YELLOW); g.drawString("Gold/h", 400, 78); g.drawString("" + hph * 37, 450, 78); g.drawString("Gold:", 400, 52); g.drawString("" + copperoreCollected * 37, 440, 52); g.setColor(Color.WHITE); g.drawRect(390, 10, 100, 75); } public String formatTime(long ms) { long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24; s %= 60; m %= 60; h %= 24; return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s) : h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s); } public long getCOPPER_ORECollected() { return copperoreCollected; } public void setCOPPER_ORECollected(long COPPER_ORECollected) { copperoreCollected = COPPER_ORECollected; } @Override public void itemStateChanged(ItemEvent arg0) { // TODO Auto-generated method stub } } package OreLooter; import java.awt.Color; import java.awt.Font; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.TitledBorder; import javax.swing.JCheckBox; public class gui { /** * @wbp.parser.entryPoint */ @SuppressWarnings("static-access") public void run(OreLooter main) { JFrame jFrame = new JFrame("OSBOT GUI Tutorial"); jFrame.setSize(300, 500); jFrame.setResizable(false); JPanel settingsPanel = new JPanel(); settingsPanel.setBackground(Color.DARK_GRAY); settingsPanel.setForeground(Color.DARK_GRAY); TitledBorder leftBorder = BorderFactory.createTitledBorder("Settings"); leftBorder.setTitleJustification(TitledBorder.LEFT); settingsPanel.setBorder(leftBorder); settingsPanel.setLayout(null); settingsPanel.setBounds(5, 200, 280, 180); jFrame.getContentPane().add(settingsPanel); JPanel startPanel = new JPanel(); startPanel.setBackground(Color.DARK_GRAY); startPanel.setForeground(Color.DARK_GRAY); startPanel.setLayout(null); startPanel.setBounds(5, 350, 70, 20); jFrame.getContentPane().add(startPanel); JLabel treeSelection = new JLabel("Select an Ore:"); treeSelection.setFont(new Font("Tahoma", Font.BOLD, 14)); treeSelection.setForeground(Color.GRAY); treeSelection.setBounds(10, 79, 118, 20); settingsPanel.add(treeSelection); JCheckBox Clay = new JCheckBox("Clay"); Clay.setForeground(Color.LIGHT_GRAY); Clay.setBackground(Color.DARK_GRAY); Clay.setFont(new Font("Georgia", Font.PLAIN, 13)); Clay.setBounds(154, 27, 97, 23); settingsPanel.add(Clay); JCheckBox Tin = new JCheckBox("Tin ore"); Tin.setForeground(Color.LIGHT_GRAY); Tin.setBackground(Color.DARK_GRAY); Tin.setFont(new Font("Georgia", Font.PLAIN, 13)); Tin.setBounds(154, 53, 97, 23); settingsPanel.add(Tin); JCheckBox Copper = new JCheckBox("Copper ore"); Copper.setForeground(Color.LIGHT_GRAY); Copper.setBackground(Color.DARK_GRAY); Copper.setFont(new Font("Georgia", Font.PLAIN, 13)); Copper.setBounds(154, 79, 97, 23); settingsPanel.add(Copper); JCheckBox Iron = new JCheckBox("Iron"); Iron.setForeground(Color.LIGHT_GRAY); Iron.setBackground(Color.DARK_GRAY); Iron.setFont(new Font("Georgia", Font.PLAIN, 13)); Iron.setBounds(154, 105, 97, 23); settingsPanel.add(Iron); JCheckBox Coal = new JCheckBox("Coal"); Coal.setFont(new Font("Georgia", Font.PLAIN, 13)); Coal.setForeground(Color.LIGHT_GRAY); Coal.setBackground(Color.DARK_GRAY); Coal.setBounds(154, 131, 97, 23); settingsPanel.add(Coal); JButton startButton = new JButton("Start"); startButton.addActionListener(e -> { synchronized (OreLooter.lock) { main.lock.notify(); } jFrame.setVisible(false); }); startButton.setBounds(5, 390, 279, 20); startPanel.add(startButton); JLabel lblNewLabel = new JLabel("Ore Lo0ter"); lblNewLabel.setFont(new Font("Georgia", Font.BOLD | Font.ITALIC, 30)); lblNewLabel.setForeground(Color.LIGHT_GRAY); lblNewLabel.setBounds(10, 11, 197, 110); startPanel.add(lblNewLabel); JLabel lblWalksToLumby = new JLabel("lumby east mine, picks up ore, and banks!"); lblWalksToLumby.setFont(new Font("Tahoma", Font.BOLD, 12)); lblWalksToLumby.setForeground(Color.GRAY); lblWalksToLumby.setBounds(5, 92, 279, 101); startPanel.add(lblWalksToLumby); jFrame.setVisible(true); } } Quote Link to comment Share on other sites More sharing options...
HunterRS Posted October 4, 2017 Share Posted October 4, 2017 (edited) You need to figure this out on your own or else you will never understand it, from your code I can see you don't understand how OOP works... Here is a clue from my jewelry maker: Main: if(getData){ status = "Getting data"; craft = gui.isCrafting(); enchant = gui.isEnchanting(); string = gui.isString(); makingItem = gui.getChosenJewelry(); GUI: setCrafting(chckbxCraft.isSelected()); public void setCrafting(boolean crafting) { this.crafting = crafting; } public boolean isEnchanting() { return enchanting; } public boolean isString() { return string; } public boolean isCrafting() { return crafting; } public boolean getStart(){ return this.start; } public String getChosenJewelry(){ return this.chosenJewelry; } Keep in mind these are just code snippets to help you understand how you should pass var from your GUI to your script. I suggest you learn at least the basics of Java and OOP before you start writing scripts. If you can't wait then just pay someone else to write you a script because you won't get far without first learning, sorry mate. 4 hours ago, sonda said: Alright, I've been working at it for hours, i can get my script to work perfectly fine - without the Gui, but ive made loads and loads of changes back and forth trying to get it to work. i cannot figure it out =\ maybe somebody can tell be where am going wrong? The GUI pops up and everything appears to be correct visually. it just doesn't do what i want it to. I can also get it to work great with a Jcombobox i just really prefer the checkbox option for multiple types of gathering at once. I know i'm ignorant when it comes to this, i am very new at it and don't quite have the experience mind set some of you have. but i am willing to try - and learn. package OreLooter; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.GroundItem; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.JCheckBox; @ScriptManifest(author = "Brian", info = "Orelooter", name = "Orelooter", version = 0, logo = "") public class OreLooter extends Script implements ItemListener { static Object lock = new Object(); public gui gui = new gui(); private long copperoreCollected; private long prevInvCount; private long timeBegan; private long timeRan; private long hph; JCheckBox Clay = new JCheckBox("Clay"); @Override public void onStart() { gui.run(this); prevInvCount = getInventory().getAmount(436); timeBegan = System.currentTimeMillis(); } private enum State { COLLECT, FULL, WALK, WAIT } private State getState() { Area MINE = new Area(3232, 3143, 3221, 3149); if (inventory.isFull()) return State.FULL; if (!inventory.isFull() && MINE.contains(myPlayer())) return State.COLLECT; if (!MINE.contains(myPlayer()) && !inventory.isFull()) return State.WALK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { JCheckBox Clay = new JCheckBox("Clay"); JCheckBox Tin = new JCheckBox("Tin"); JCheckBox Copper = new JCheckBox("Copper"); JCheckBox Iron = new JCheckBox("Iron"); JCheckBox Coal =new JCheckBox("Coal"); if (Coal.isSelected())log("coal is selected"); long invCount = getInventory().getAmount(436); if (invCount > prevInvCount) setCOPPER_ORECollected(getCOPPER_ORECollected() + (invCount - prevInvCount)); prevInvCount = invCount; GroundItem Clayo = groundItems.closest("Clay"); GroundItem Tino = groundItems.closest("Tin ore"); GroundItem Coppero = groundItems.closest("Copper ore"); GroundItem Irono = groundItems.closest("Iron ore"); GroundItem Coalo = groundItems.closest("Coal"); switch (getState()) { case COLLECT: if (Clay.isSelected()) { if (Clayo != null && getMap().canReach(Clayo)) Clayo.interact("take"); } if (Tino != null && getMap().canReach(Tino) && Tin.isSelected()) { log("Tin selected"); Tino.interact("take"); } if (Copper.isSelected()) { log("Searching for Copper"); if (Coppero != null && getMap().canReach(Coppero)) log("Copper selected"); Coppero.interact("take"); } if (Irono != null && getMap().canReach(Irono) && Iron.isSelected()) { log("Iron selected"); Irono.interact("take"); } if (Coalo != null && getMap().canReach(Coalo) && Coal.isSelected()) { log("Coal selected"); Coalo.interact("take"); } sleep(2000); break; case FULL: walking.webWalk(new Position(3209, 3220, 2)); if (bank.isOpen()) { bank.depositAll(); } else { objects.closest("Bank booth").interact("Bank"); } break; case WALK: Area MINE = new Area(3232, 3143, 3221, 3149); walking.webWalk(MINE); case WAIT: } return (random(400, 1500)); } @Override public void onExit() { log("THANKS APAEC FOR ALL THE HELP"); } @Override public void onPaint(Graphics2D g) { hph = (int) (copperoreCollected / ((System.currentTimeMillis() - timeBegan) / 3600000.0D)); timeRan = System.currentTimeMillis() - this.timeBegan; Graphics2D gr = (Graphics2D) g; gr.setColor(Color.WHITE); gr.setFont(new Font("Arial", Font.BOLD, 12)); g.drawString(formatTime(timeRan), 440, 25); gr.drawString("Time:", 400, 25); gr.drawString("" + copperoreCollected, 440, 40); gr.drawString("Ores:", 400, 40); gr.drawString("Ores/h:", 400, 65); g.drawString("" + hph, 450, 65); gr.setColor(Color.YELLOW); g.drawString("Gold/h", 400, 78); g.drawString("" + hph * 37, 450, 78); g.drawString("Gold:", 400, 52); g.drawString("" + copperoreCollected * 37, 440, 52); g.setColor(Color.WHITE); g.drawRect(390, 10, 100, 75); } public String formatTime(long ms) { long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24; s %= 60; m %= 60; h %= 24; return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s) : h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s); } public long getCOPPER_ORECollected() { return copperoreCollected; } public void setCOPPER_ORECollected(long COPPER_ORECollected) { copperoreCollected = COPPER_ORECollected; } @Override public void itemStateChanged(ItemEvent arg0) { // TODO Auto-generated method stub } } package OreLooter; import java.awt.Color; import java.awt.Font; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.TitledBorder; import javax.swing.JCheckBox; public class gui { /** * @wbp.parser.entryPoint */ @SuppressWarnings("static-access") public void run(OreLooter main) { JFrame jFrame = new JFrame("OSBOT GUI Tutorial"); jFrame.setSize(300, 500); jFrame.setResizable(false); JPanel settingsPanel = new JPanel(); settingsPanel.setBackground(Color.DARK_GRAY); settingsPanel.setForeground(Color.DARK_GRAY); TitledBorder leftBorder = BorderFactory.createTitledBorder("Settings"); leftBorder.setTitleJustification(TitledBorder.LEFT); settingsPanel.setBorder(leftBorder); settingsPanel.setLayout(null); settingsPanel.setBounds(5, 200, 280, 180); jFrame.getContentPane().add(settingsPanel); JPanel startPanel = new JPanel(); startPanel.setBackground(Color.DARK_GRAY); startPanel.setForeground(Color.DARK_GRAY); startPanel.setLayout(null); startPanel.setBounds(5, 350, 70, 20); jFrame.getContentPane().add(startPanel); JLabel treeSelection = new JLabel("Select an Ore:"); treeSelection.setFont(new Font("Tahoma", Font.BOLD, 14)); treeSelection.setForeground(Color.GRAY); treeSelection.setBounds(10, 79, 118, 20); settingsPanel.add(treeSelection); JCheckBox Clay = new JCheckBox("Clay"); Clay.setForeground(Color.LIGHT_GRAY); Clay.setBackground(Color.DARK_GRAY); Clay.setFont(new Font("Georgia", Font.PLAIN, 13)); Clay.setBounds(154, 27, 97, 23); settingsPanel.add(Clay); JCheckBox Tin = new JCheckBox("Tin ore"); Tin.setForeground(Color.LIGHT_GRAY); Tin.setBackground(Color.DARK_GRAY); Tin.setFont(new Font("Georgia", Font.PLAIN, 13)); Tin.setBounds(154, 53, 97, 23); settingsPanel.add(Tin); JCheckBox Copper = new JCheckBox("Copper ore"); Copper.setForeground(Color.LIGHT_GRAY); Copper.setBackground(Color.DARK_GRAY); Copper.setFont(new Font("Georgia", Font.PLAIN, 13)); Copper.setBounds(154, 79, 97, 23); settingsPanel.add(Copper); JCheckBox Iron = new JCheckBox("Iron"); Iron.setForeground(Color.LIGHT_GRAY); Iron.setBackground(Color.DARK_GRAY); Iron.setFont(new Font("Georgia", Font.PLAIN, 13)); Iron.setBounds(154, 105, 97, 23); settingsPanel.add(Iron); JCheckBox Coal = new JCheckBox("Coal"); Coal.setFont(new Font("Georgia", Font.PLAIN, 13)); Coal.setForeground(Color.LIGHT_GRAY); Coal.setBackground(Color.DARK_GRAY); Coal.setBounds(154, 131, 97, 23); settingsPanel.add(Coal); JButton startButton = new JButton("Start"); startButton.addActionListener(e -> { synchronized (OreLooter.lock) { main.lock.notify(); } jFrame.setVisible(false); }); startButton.setBounds(5, 390, 279, 20); startPanel.add(startButton); JLabel lblNewLabel = new JLabel("Ore Lo0ter"); lblNewLabel.setFont(new Font("Georgia", Font.BOLD | Font.ITALIC, 30)); lblNewLabel.setForeground(Color.LIGHT_GRAY); lblNewLabel.setBounds(10, 11, 197, 110); startPanel.add(lblNewLabel); JLabel lblWalksToLumby = new JLabel("lumby east mine, picks up ore, and banks!"); lblWalksToLumby.setFont(new Font("Tahoma", Font.BOLD, 12)); lblWalksToLumby.setForeground(Color.GRAY); lblWalksToLumby.setBounds(5, 92, 279, 101); startPanel.add(lblWalksToLumby); jFrame.setVisible(true); } } Edited October 4, 2017 by HunterRS Quote Link to comment Share on other sites More sharing options...
TheWind Posted October 4, 2017 Share Posted October 4, 2017 (edited) I decided to go ahead and post the entire script. I made a few changes which I believe were what your goal was. Dealing with threads and concurrency can be a tricky topic. I know I still struggle with it sometimes. There are still many things in this script that can be improved, but I believe you are off to a great start! I'm hoping that after looking at how I used a boolean to assign whether or not the checkbox was checked after pressing start you will be able to proceed with doing so for the rest of the ore checkboxes. There are many ways that this could have been done, but I believe that this was the simplest and definitely the best way to learn! Edit: if you have any more questions feel free to ask package OreLooter; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.GroundItem; import java.awt.*; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import javax.swing.JCheckBox; @ScriptManifest(author = "Brian", info = "Orelooter", name = "Orelooter", version = 0, logo = "") public class OreLooter extends Script implements ItemListener { // Should not be static Object lock = new Object(); public gui gui = new gui(); private long copperoreCollected; private long prevInvCount; private long timeBegan; private long timeRan; private long hph; public boolean clayCheckBox = false; @Override public void onStart() throws InterruptedException { gui.run(this); synchronized(lock) { // must make the lock object wait which in essence pauses this class from executing until it is notified lock.wait(); } prevInvCount = getInventory().getAmount(436); timeBegan = System.currentTimeMillis(); log("Is clay checkbox selected: " + clayCheckBox); } private enum State { COLLECT, FULL, WALK, WAIT } private State getState() { Area MINE = new Area(3232, 3143, 3221, 3149); if (inventory.isFull()) return State.FULL; if (!inventory.isFull() && MINE.contains(myPlayer())) return State.COLLECT; if (!MINE.contains(myPlayer()) && !inventory.isFull()) return State.WALK; return State.WAIT; } @Override public int onLoop() throws InterruptedException { // none of these are needed as they are already in your gui class. JCheckBox Clay = new JCheckBox("Clay"); JCheckBox Tin = new JCheckBox("Tin"); JCheckBox Copper = new JCheckBox("Copper"); JCheckBox Iron = new JCheckBox("Iron"); JCheckBox Coal =new JCheckBox("Coal"); if (Coal.isSelected())log("coal is selected"); long invCount = getInventory().getAmount(436); if (invCount > prevInvCount) setCOPPER_ORECollected(getCOPPER_ORECollected() + (invCount - prevInvCount)); prevInvCount = invCount; GroundItem Clayo = groundItems.closest("Clay"); GroundItem Tino = groundItems.closest("Tin ore"); GroundItem Coppero = groundItems.closest("Copper ore"); GroundItem Irono = groundItems.closest("Iron ore"); GroundItem Coalo = groundItems.closest("Coal"); switch (getState()) { case COLLECT: if (clayCheckBox) { if (Clayo != null && getMap().canReach(Clayo)) Clayo.interact("take"); } if (Tino != null && getMap().canReach(Tino) && Tin.isSelected()) { log("Tin selected"); Tino.interact("take"); } if (Copper.isSelected()) { log("Searching for Copper"); if (Coppero != null && getMap().canReach(Coppero)) log("Copper selected"); Coppero.interact("take"); } if (Irono != null && getMap().canReach(Irono) && Iron.isSelected()) { log("Iron selected"); Irono.interact("take"); } if (Coalo != null && getMap().canReach(Coalo) && Coal.isSelected()) { log("Coal selected"); Coalo.interact("take"); } sleep(2000); break; case FULL: walking.webWalk(new Position(3209, 3220, 2)); if (bank.isOpen()) { bank.depositAll(); } else { objects.closest("Bank booth").interact("Bank"); } break; case WALK: Area MINE = new Area(3232, 3143, 3221, 3149); walking.webWalk(MINE); case WAIT: } return (random(400, 1500)); } @Override public void onExit() { log("THANKS APAEC FOR ALL THE HELP"); } @Override public void onPaint(Graphics2D g) { hph = (int) (copperoreCollected / ((System.currentTimeMillis() - timeBegan) / 3600000.0D)); timeRan = System.currentTimeMillis() - this.timeBegan; Graphics2D gr = (Graphics2D) g; gr.setColor(Color.WHITE); gr.setFont(new Font("Arial", Font.BOLD, 12)); g.drawString(formatTime(timeRan), 440, 25); gr.drawString("Time:", 400, 25); gr.drawString("" + copperoreCollected, 440, 40); gr.drawString("Ores:", 400, 40); gr.drawString("Ores/h:", 400, 65); g.drawString("" + hph, 450, 65); gr.setColor(Color.YELLOW); g.drawString("Gold/h", 400, 78); g.drawString("" + hph * 37, 450, 78); g.drawString("Gold:", 400, 52); g.drawString("" + copperoreCollected * 37, 440, 52); g.setColor(Color.WHITE); g.drawRect(390, 10, 100, 75); } public String formatTime(long ms) { long s = ms / 1000, m = s / 60, h = m / 60, d = h / 24; s %= 60; m %= 60; h %= 24; return d > 0 ? String.format("%02d:%02d:%02d:%02d", d, h, m, s) : h > 0 ? String.format("%02d:%02d:%02d", h, m, s) : String.format("%02d:%02d", m, s); } public long getCOPPER_ORECollected() { return copperoreCollected; } public void setCOPPER_ORECollected(long COPPER_ORECollected) { copperoreCollected = COPPER_ORECollected; } @Override public void itemStateChanged(ItemEvent arg0) { // TODO Auto-generated method stub } } package OreLooter; import java.awt.Color; import java.awt.Font; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.border.TitledBorder; import javax.swing.JCheckBox; public class gui { /** * @wbp.parser.entryPoint */ public void run(OreLooter main) { JFrame jFrame = new JFrame("OSBOT GUI Tutorial"); jFrame.setSize(300, 500); jFrame.setResizable(false); JPanel settingsPanel = new JPanel(); settingsPanel.setBackground(Color.DARK_GRAY); settingsPanel.setForeground(Color.DARK_GRAY); TitledBorder leftBorder = BorderFactory.createTitledBorder("Settings"); leftBorder.setTitleJustification(TitledBorder.LEFT); settingsPanel.setBorder(leftBorder); settingsPanel.setLayout(null); settingsPanel.setBounds(5, 200, 280, 180); jFrame.getContentPane().add(settingsPanel); JPanel startPanel = new JPanel(); startPanel.setBackground(Color.DARK_GRAY); startPanel.setForeground(Color.DARK_GRAY); startPanel.setLayout(null); startPanel.setBounds(5, 350, 70, 20); jFrame.getContentPane().add(startPanel); JLabel treeSelection = new JLabel("Select an Ore:"); treeSelection.setFont(new Font("Tahoma", Font.BOLD, 14)); treeSelection.setForeground(Color.GRAY); treeSelection.setBounds(10, 79, 118, 20); settingsPanel.add(treeSelection); JCheckBox Clay = new JCheckBox("Clay"); Clay.setForeground(Color.LIGHT_GRAY); Clay.setBackground(Color.DARK_GRAY); Clay.setFont(new Font("Georgia", Font.PLAIN, 13)); Clay.setBounds(154, 27, 97, 23); settingsPanel.add(Clay); JCheckBox Tin = new JCheckBox("Tin ore"); Tin.setForeground(Color.LIGHT_GRAY); Tin.setBackground(Color.DARK_GRAY); Tin.setFont(new Font("Georgia", Font.PLAIN, 13)); Tin.setBounds(154, 53, 97, 23); settingsPanel.add(Tin); JCheckBox Copper = new JCheckBox("Copper ore"); Copper.setForeground(Color.LIGHT_GRAY); Copper.setBackground(Color.DARK_GRAY); Copper.setFont(new Font("Georgia", Font.PLAIN, 13)); Copper.setBounds(154, 79, 97, 23); settingsPanel.add(Copper); JCheckBox Iron = new JCheckBox("Iron"); Iron.setForeground(Color.LIGHT_GRAY); Iron.setBackground(Color.DARK_GRAY); Iron.setFont(new Font("Georgia", Font.PLAIN, 13)); Iron.setBounds(154, 105, 97, 23); settingsPanel.add(Iron); JCheckBox Coal = new JCheckBox("Coal"); Coal.setFont(new Font("Georgia", Font.PLAIN, 13)); Coal.setForeground(Color.LIGHT_GRAY); Coal.setBackground(Color.DARK_GRAY); Coal.setBounds(154, 131, 97, 23); settingsPanel.add(Coal); JButton startButton = new JButton("Start"); startButton.addActionListener(e -> { jFrame.setVisible(false); // everything that is a setting should be called before you unlock the main class main.clayCheckBox = Clay.isSelected(); // this is where the boolean for the clayCheckBox is set to true if the clay checkbox is checked synchronized (main.lock) { // this unlocks the main class and lets it run again main.lock.notify(); } }); startButton.setBounds(5, 390, 279, 20); startPanel.add(startButton); JLabel lblNewLabel = new JLabel("Ore Lo0ter"); lblNewLabel.setFont(new Font("Georgia", Font.BOLD | Font.ITALIC, 30)); lblNewLabel.setForeground(Color.LIGHT_GRAY); lblNewLabel.setBounds(10, 11, 197, 110); startPanel.add(lblNewLabel); JLabel lblWalksToLumby = new JLabel("lumby east mine, picks up ore, and banks!"); lblWalksToLumby.setFont(new Font("Tahoma", Font.BOLD, 12)); lblWalksToLumby.setForeground(Color.GRAY); lblWalksToLumby.setBounds(5, 92, 279, 101); startPanel.add(lblWalksToLumby); jFrame.setVisible(true); } } Edited October 4, 2017 by TheWind 1 Quote Link to comment Share on other sites More sharing options...