Chambo Posted August 26, 2015 Share Posted August 26, 2015 (edited) Hey guys i'm trying to make a AIOWalker and I got an error. I've searched everywhere and can't find a solution to this problem. What i'm trying to do: if(startLoc.equals("Varrock") && endLoc.equals("Lumbridge")){ Error: [ERROR][08/26 02:46:32 PM]: Uncaught exception! java.lang.ClassCastException: java.lang.String cannot be cast to [Ljava.lang.String; at Main.lambda$initSettings$0(Main.java:69) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at org.pushingpixels.substance.internal.utils.RolloverButtonListener.mouseReleased(RolloverButtonListener.java:124) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$500(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Here is a sample of the script: (Starts at line 60) final String[][] startLoc = {{"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}}; JComboBox<String> sLBox = new JComboBox<>(startLoc[0]); final String[][] endLoc = {{"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}}; JComboBox<String> eLBox = new JComboBox<>(endLoc[0]); frame.add(sLBox); frame.add(eLBox); JButton button = new JButton("Start"); button.addActionListener(event -> { startLoc[0] = (String[]) sLBox.getSelectedItem(); endLoc[0] = (String[]) eLBox.getSelectedItem(); frame.dispose(); }); Edit: Changed title to [RESOLVED] Edited August 27, 2015 by Chambo Quote Link to comment Share on other sites More sharing options...
Chris Posted August 26, 2015 Share Posted August 26, 2015 (edited) java.lang.String cannot be cast to [Ljava.lang.String; at Main.lambda$initSettings$0(Main.java:69) look at line 69 and there is your error Edit: nvm saw spoiler Edited August 26, 2015 by Sinatra Quote Link to comment Share on other sites More sharing options...
Precise Posted August 26, 2015 Share Posted August 26, 2015 startLoc is a 2 dimension array of strings meaning it cannot equal a single string. 1 Quote Link to comment Share on other sites More sharing options...
Chambo Posted August 26, 2015 Author Share Posted August 26, 2015 startLoc is a 2 dimension array of strings meaning it cannot equal a single string. Sorry i'm very new to scripting and i'm still a bit confused on this. What would I have to do to fix this? Quote Link to comment Share on other sites More sharing options...
Eliot Posted August 26, 2015 Share Posted August 26, 2015 Why is startLoc/endLoc a two dimensional array? It looks like it just needs to be a regular array of Strings. Also, we want to populate our JComboBox with an array, not a single string. As such, we pass the entire array not just the first element. final String[] startLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> sLBox = new JComboBox<>(startLoc); final String[] endLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> eLBox = new JComboBox<>(endLoc); We should not reassign startLoc's value, make a new variable and assign it to the select value! String startingLocation = sLBox.getSelectedItem().toString(); String endingLocation = eLBox.getSelectedItem().toString(); Now we have the String representation of both the ending and starting locations. if (startingLocation.equals("Varrock") && endingLocation.equals("Lumbridge")) { // do stuff! } I would suggest reading up a bit more about how all these components (arrays/Strings/2D arrays/combo boxes) work to get a better understanding of the Java language, but I hope what I provided helps you with your script. 2 Quote Link to comment Share on other sites More sharing options...
Chambo Posted August 26, 2015 Author Share Posted August 26, 2015 Why is startLoc/endLoc a two dimensional array? It looks like it just needs to be a regular array of Strings. Also, we want to populate our JComboBox with an array, not a single string. As such, we pass the entire array not just the first element. final String[] startLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> sLBox = new JComboBox<>(startLoc); final String[] endLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> eLBox = new JComboBox<>(endLoc); We should not reassign startLoc's value, make a new variable and assign it to the select value! String startingLocation = sLBox.getSelectedItem().toString(); String endingLocation = eLBox.getSelectedItem().toString(); Now we have the String representation of both the ending and starting locations. if (startingLocation.equals("Varrock") && endingLocation.equals("Lumbridge")) { // do stuff! } I would suggest reading up a bit more about how all these components (arrays/Strings/2D arrays/combo boxes) work to get a better understanding of the Java language, but I hope what I provided helps you with your script. I changed the variable you gave: startingLocation | to startLocX. Here it is saying the variable "startLocX" & "endLocX" is not used... And here it is saying that it cannot resolve symbol startLocX & endLocX... I'm completely stumped.. I thought I understood but maybe i'm wrong? Quote Link to comment Share on other sites More sharing options...
Eliot Posted August 26, 2015 Share Posted August 26, 2015 I changed the variable you gave: startingLocation | to startLocX. Here it is saying the variable "startLocX" & "endLocX" is not used... And here it is saying that it cannot resolve symbol startLocX & endLocX... I'm completely stumped.. I thought I understood but maybe i'm wrong? Declare startLocX and endLocX outside of the button.addActionListener function. Perhaps right above that try: String startLocX = ""; // then inside the buttonListener startLocX = // whatever When you declare and initialize the variable inside the function its scope is limited to just that function and nothing outside of it will know it exists. Quote Link to comment Share on other sites More sharing options...
Chambo Posted August 26, 2015 Author Share Posted August 26, 2015 Declare startLocX and endLocX outside of the button.addActionListener function. Perhaps right above that try: String startLocX = ""; // then inside the buttonListener startLocX = // whatever When you declare and initialize the variable inside the function its scope is limited to just that function and nothing outside of it will know it exists. It is still stating that the variables: startLocX & endLocX are never used frame.setLocationByPlatform(true); String startLocX = ""; String endLocX = ""; final String[] startLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> sLBox = new JComboBox<>(startLoc); final String[] endLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> eLBox = new JComboBox<>(endLoc); frame.add(sLBox); frame.add(eLBox); JButton button = new JButton("Start"); button.addActionListener(event -> { final String startLocX = sLBox.getSelectedItem().toString(); final String endLocX = eLBox.getSelectedItem().toString(); frame.dispose(); }); frame.add(button); frame.pack(); frame.setVisible(true); } public int onLoop() throws InterruptedException { if(startLoc.equals(endLoc)) { log("Starting Location and End Location CANNOT be the same!"); log("Stopping Script..."); bot.stop(); return 600; }else{ if(startLocX.equals("Varrock") && endLocX.equals("Lumbridge")){ log("Walking from " +startLoc+ " to " +endLoc+ "..."); localWalker.walkPath(v2l); if(lumbridgeA.contains(players.myPosition())){ log("You have arrived at " +endLoc+ "!"); bot.stop(); } Quote Link to comment Share on other sites More sharing options...
Eliot Posted August 26, 2015 Share Posted August 26, 2015 It is still stating that the variables: startLocX & endLocX are never used frame.setLocationByPlatform(true); String startLocX = ""; String endLocX = ""; final String[] startLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> sLBox = new JComboBox<>(startLoc); final String[] endLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> eLBox = new JComboBox<>(endLoc); frame.add(sLBox); frame.add(eLBox); JButton button = new JButton("Start"); button.addActionListener(event -> { final String startLocX = sLBox.getSelectedItem().toString(); final String endLocX = eLBox.getSelectedItem().toString(); frame.dispose(); }); frame.add(button); frame.pack(); frame.setVisible(true); } public int onLoop() throws InterruptedException { if(startLoc.equals(endLoc)) { log("Starting Location and End Location CANNOT be the same!"); log("Stopping Script..."); bot.stop(); return 600; }else{ if(startLocX.equals("Varrock") && endLocX.equals("Lumbridge")){ log("Walking from " +startLoc+ " to " +endLoc+ "..."); localWalker.walkPath(v2l); if(lumbridgeA.contains(players.myPosition())){ log("You have arrived at " +endLoc+ "!"); bot.stop(); } Declare them outside of that method all that code is in (above the onStart). Also in the button listener do not REDECLARE just change the value i.e. not final String eLocX =, just eLocX = This should work for you. 1 Quote Link to comment Share on other sites More sharing options...
Chambo Posted August 26, 2015 Author Share Posted August 26, 2015 (edited) Declare them outside of that method all that code is in (above the onStart). Also in the button listener do not REDECLARE just change the value i.e. not final String eLocX =, just eLocX = This should work for you. So the script starts with no erros!! but the last problem is that it's not executing the walkpath and isn't giving any errors? Source: import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.*; import javax.swing.*; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; /** * Created by OSBot Member: Chambo on 8/25/2015. */ @ScriptManifest(author = "Chambo", info = "Chambo's AIO Walker", logo = "", name = "Chambo's AIO Walker Beta", version = 0.77) public class Main extends Script { /** * AREAS */ Area lumbridgeA = new Area( new Position(3225,3213,0), new Position(3218,3225,0)); Area varrockA = new Area( new Position(3219,3433,0), new Position(3207,3424,0)); /** * POSITIONS */ Position[] v2l = new Position[] { new Position(3213,3428,0), new Position(3212,3415,0), new Position(3212,3407,0), new Position(3212,3403,0), new Position(3212,3397,0), new Position(3211,3387,0), new Position(3211,3385,0), new Position(3211,3378,0), new Position(3211,3368,0), new Position(3210,3363,0), new Position(3206,3361,0), new Position(3206,3357,0), new Position(3204,3346,0), new Position(3205,3342,0), new Position(3206,3340,0), new Position(3209,3336,0), new Position(3213,3331,0), new Position(3215,3329,0), new Position(3223,3323,0), new Position(3225,3314,0), new Position(3225,3310,0), new Position(3231,3306,0), new Position(3238,3298,0), new Position(3239,3290,0), new Position(3239,3288,0), new Position(3239,3286,0), new Position(3238,3281,0), new Position(3240,3269,0), new Position(3240,3267,0), new Position(3240,3265,0), new Position(3234,3262,0), new Position(3232,3262,0), new Position(3230,3262,0), new Position(3229,3260,0), new Position(3231,3259,0), new Position(3231,3255,0), new Position(3231,3255,0), new Position(3231,3249,0), new Position(3230,3248,0), new Position(3233,3238,0), new Position(3233,3228,0), new Position(3233,3226,0), new Position(3233,3222,0), new Position(3229,3219,0), new Position(3227,3219,0), new Position(3227,3219,0), new Position(3223,3219,0), new Position(3222,3218,0), new Position(3222,3218,0),}; Position[] l2v = new Position[] { new Position(3222,3218,0), new Position(3222,3218,0), new Position(3223,3219,0), new Position(3227,3219,0), new Position(3227,3219,0), new Position(3229,3219,0), new Position(3233,3222,0), new Position(3233,3226,0), new Position(3233,3228,0), new Position(3233,3238,0), new Position(3230,3248,0), new Position(3231,3249,0), new Position(3231,3255,0), new Position(3231,3255,0), new Position(3231,3259,0), new Position(3229,3260,0), new Position(3230,3262,0), new Position(3232,3262,0),new Position(3234,3262,0), new Position(3240,3265,0), new Position(3240,3267,0), new Position(3240,3269,0), new Position(3238,3281,0), new Position(3239,3286,0), new Position(3239,3288,0), new Position(3239,3290,0), new Position(3238,3298,0), new Position(3231,3306,0), new Position(3225,3310,0), new Position(3225,3314,0), new Position(3223,3323,0), new Position(3215,3329,0), new Position(3213,3331,0), new Position(3209,3336,0), new Position(3206,3340,0), new Position(3205,3342,0), new Position(3204,3346,0), new Position(3206,3357,0), new Position(3206,3361,0), new Position(3210,3363,0), new Position(3211,3368,0), new Position(3211,3378,0), new Position(3211,3385,0), new Position(3211,3387,0), new Position(3212,3397,0), new Position(3212,3403,0), new Position(3212,3407,0), new Position(3212,3415,0), new Position(3213,3428,0),}; public String startLocX = ""; public String endLocX = ""; public void onStart() throws InterruptedException { EventQueue.invokeLater(this::initSettings); synchronized(Main.class) { try { Main.class.wait(); //forces this thread to wait } catch(InterruptedException e) { e.printStackTrace(); } } } private void initSettings() { JFrame frame = new JFrame("Settings"); frame.setLayout(new FlowLayout()); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { frame.dispose(); synchronized (Main.class) { Main.class.notify(); } } }); frame.setLocationByPlatform(true); final String[] startLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> sLBox = new JComboBox<>(startLoc); final String[] endLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> eLBox = new JComboBox<>(endLoc); frame.add(sLBox); frame.add(eLBox); JButton button = new JButton("Start"); button.addActionListener(event -> { startLocX = sLBox.getSelectedItem().toString(); endLocX = eLBox.getSelectedItem().toString(); frame.dispose(); }); frame.add(button); frame.pack(); frame.setVisible(true); } public int onLoop() throws InterruptedException { if(startLocX.equals(endLocX)) { log("Starting Location and End Location CANNOT be the same!"); log("Stopping Script..."); bot.stop(); return 600; }else{ if(startLocX.equals("Varrock") && endLocX.equals("Lumbridge")){ log("Walking from " +startLocX+ " to " +endLocX+ "..."); localWalker.walkPath(v2l); if(lumbridgeA.contains(players.myPosition())){ log("You have arrived at " +endLocX+ "!"); bot.stop(); } return 650; } else if(startLocX.equals("Lumbridge") && endLocX.equals("Varrock")){ log("Walking from " +startLocX+ " to " +endLocX+ "..."); localWalker.walkPath(l2v); if(varrockA.contains(players.myPosition())){ log("You have arrived at " +endLocX+ "!"); bot.stop(); } return 650; } else { log("Upgrade to Pro for this location!"); } } return 600; } public void onExit() throws InterruptedException { super.onExit(); } @Override public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) final Color color1 = new Color(153, 153, 153); final Color color2 = new Color(255, 0, 0); final Color color3 = new Color(0, 0, 0); final Color color4 = new Color(255, 255, 255); final BasicStroke stroke1 = new BasicStroke(3); final Font font1 = new Font("Arial", 0, 9); final Font font2 = new Font("Arial", 1, 21); final Font font3 = new Font("Arial", 0, 15); final Font font4 = new Font("Arial", 0, 8); g.setColor(color1); g.fillRect(9, 346, 500, 126); g.setColor(color2); g.setStroke(stroke1); g.drawRect(9, 346, 500, 126); g.setFont(font1); g.setColor(color1); g.drawString("Version: ", 15, 332); g.setFont(font2); g.setColor(color3); /**g.drawString("EXP p/h:", 17, 378); g.setColor(color4); g.drawString("EXP p/h:", 14, 375); g.setColor(color3); g.drawString("Gold p/h:", 18, 417); g.setColor(color4); g.drawString("Gold p/h:", 15, 414); g.setColor(color3); g.drawString("Run Time:", 18, 454); g.setColor(color4); g.drawString("Run Time:", 15, 451); g.setColor(color3); g.drawString("Current Level:", 270, 380); g.setColor(color4); g.drawString("Current Level:", 267, 377); g.setColor(color3); g.drawString("Levels Gained:", 271, 417); g.setColor(color4); g.drawString("Levels Gained:", 268, 414); */ g.setColor(color3); g.drawString("Status:", 273, 453); g.setColor(color4); g.drawString("Status:", 270, 450); g.setFont(font3); //g.drawString("EXPPH", 121, 375); //g.drawString("GOLDPH", 128, 414); //g.drawString("RUNTIME", 137, 450); //g.drawString("40", 439, 377); //g.drawString("+29", 444, 414); g.drawString("Running: " + endLocX , 370, 452); g.setFont(font4); g.setColor(color1); g.drawString("0.29", 59, 332); } } edit: Added Source: Edited August 26, 2015 by Chambo Quote Link to comment Share on other sites More sharing options...
Eliot Posted August 26, 2015 Share Posted August 26, 2015 So the script starts with no erros!! but the last problem is that it's not executing the walkpath and isn't giving any errors? Source: import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.*; import javax.swing.*; import java.awt.*; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; /** * Created by OSBot Member: Chambo on 8/25/2015. */ @ScriptManifest(author = "Chambo", info = "Chambo's AIO Walker", logo = "", name = "Chambo's AIO Walker Beta", version = 0.77) public class Main extends Script { /** * AREAS */ Area lumbridgeA = new Area( new Position(3225,3213,0), new Position(3218,3225,0)); Area varrockA = new Area( new Position(3219,3433,0), new Position(3207,3424,0)); /** * POSITIONS */ Position[] v2l = new Position[] { new Position(3213,3428,0), new Position(3212,3415,0), new Position(3212,3407,0), new Position(3212,3403,0), new Position(3212,3397,0), new Position(3211,3387,0), new Position(3211,3385,0), new Position(3211,3378,0), new Position(3211,3368,0), new Position(3210,3363,0), new Position(3206,3361,0), new Position(3206,3357,0), new Position(3204,3346,0), new Position(3205,3342,0), new Position(3206,3340,0), new Position(3209,3336,0), new Position(3213,3331,0), new Position(3215,3329,0), new Position(3223,3323,0), new Position(3225,3314,0), new Position(3225,3310,0), new Position(3231,3306,0), new Position(3238,3298,0), new Position(3239,3290,0), new Position(3239,3288,0), new Position(3239,3286,0), new Position(3238,3281,0), new Position(3240,3269,0), new Position(3240,3267,0), new Position(3240,3265,0), new Position(3234,3262,0), new Position(3232,3262,0), new Position(3230,3262,0), new Position(3229,3260,0), new Position(3231,3259,0), new Position(3231,3255,0), new Position(3231,3255,0), new Position(3231,3249,0), new Position(3230,3248,0), new Position(3233,3238,0), new Position(3233,3228,0), new Position(3233,3226,0), new Position(3233,3222,0), new Position(3229,3219,0), new Position(3227,3219,0), new Position(3227,3219,0), new Position(3223,3219,0), new Position(3222,3218,0), new Position(3222,3218,0),}; Position[] l2v = new Position[] { new Position(3222,3218,0), new Position(3222,3218,0), new Position(3223,3219,0), new Position(3227,3219,0), new Position(3227,3219,0), new Position(3229,3219,0), new Position(3233,3222,0), new Position(3233,3226,0), new Position(3233,3228,0), new Position(3233,3238,0), new Position(3230,3248,0), new Position(3231,3249,0), new Position(3231,3255,0), new Position(3231,3255,0), new Position(3231,3259,0), new Position(3229,3260,0), new Position(3230,3262,0), new Position(3232,3262,0),new Position(3234,3262,0), new Position(3240,3265,0), new Position(3240,3267,0), new Position(3240,3269,0), new Position(3238,3281,0), new Position(3239,3286,0), new Position(3239,3288,0), new Position(3239,3290,0), new Position(3238,3298,0), new Position(3231,3306,0), new Position(3225,3310,0), new Position(3225,3314,0), new Position(3223,3323,0), new Position(3215,3329,0), new Position(3213,3331,0), new Position(3209,3336,0), new Position(3206,3340,0), new Position(3205,3342,0), new Position(3204,3346,0), new Position(3206,3357,0), new Position(3206,3361,0), new Position(3210,3363,0), new Position(3211,3368,0), new Position(3211,3378,0), new Position(3211,3385,0), new Position(3211,3387,0), new Position(3212,3397,0), new Position(3212,3403,0), new Position(3212,3407,0), new Position(3212,3415,0), new Position(3213,3428,0),}; public String startLocX = ""; public String endLocX = ""; public void onStart() throws InterruptedException { EventQueue.invokeLater(this::initSettings); synchronized(Main.class) { try { Main.class.wait(); //forces this thread to wait } catch(InterruptedException e) { e.printStackTrace(); } } } private void initSettings() { JFrame frame = new JFrame("Settings"); frame.setLayout(new FlowLayout()); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { frame.dispose(); synchronized (Main.class) { Main.class.notify(); } } }); frame.setLocationByPlatform(true); final String[] startLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> sLBox = new JComboBox<>(startLoc); final String[] endLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> eLBox = new JComboBox<>(endLoc); frame.add(sLBox); frame.add(eLBox); JButton button = new JButton("Start"); button.addActionListener(event -> { startLocX = sLBox.getSelectedItem().toString(); endLocX = eLBox.getSelectedItem().toString(); frame.dispose(); }); frame.add(button); frame.pack(); frame.setVisible(true); } public int onLoop() throws InterruptedException { if(startLocX.equals(endLocX)) { log("Starting Location and End Location CANNOT be the same!"); log("Stopping Script..."); bot.stop(); return 600; }else{ if(startLocX.equals("Varrock") && endLocX.equals("Lumbridge")){ log("Walking from " +startLocX+ " to " +endLocX+ "..."); localWalker.walkPath(v2l); if(lumbridgeA.contains(players.myPosition())){ log("You have arrived at " +endLocX+ "!"); bot.stop(); } return 650; } else if(startLocX.equals("Lumbridge") && endLocX.equals("Varrock")){ log("Walking from " +startLocX+ " to " +endLocX+ "..."); localWalker.walkPath(l2v); if(varrockA.contains(players.myPosition())){ log("You have arrived at " +endLocX+ "!"); bot.stop(); } return 650; } else { log("Upgrade to Pro for this location!"); } } return 600; } public void onExit() throws InterruptedException { super.onExit(); } @Override public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) final Color color1 = new Color(153, 153, 153); final Color color2 = new Color(255, 0, 0); final Color color3 = new Color(0, 0, 0); final Color color4 = new Color(255, 255, 255); final BasicStroke stroke1 = new BasicStroke(3); final Font font1 = new Font("Arial", 0, 9); final Font font2 = new Font("Arial", 1, 21); final Font font3 = new Font("Arial", 0, 15); final Font font4 = new Font("Arial", 0, 8); g.setColor(color1); g.fillRect(9, 346, 500, 126); g.setColor(color2); g.setStroke(stroke1); g.drawRect(9, 346, 500, 126); g.setFont(font1); g.setColor(color1); g.drawString("Version: ", 15, 332); g.setFont(font2); g.setColor(color3); /**g.drawString("EXP p/h:", 17, 378); g.setColor(color4); g.drawString("EXP p/h:", 14, 375); g.setColor(color3); g.drawString("Gold p/h:", 18, 417); g.setColor(color4); g.drawString("Gold p/h:", 15, 414); g.setColor(color3); g.drawString("Run Time:", 18, 454); g.setColor(color4); g.drawString("Run Time:", 15, 451); g.setColor(color3); g.drawString("Current Level:", 270, 380); g.setColor(color4); g.drawString("Current Level:", 267, 377); g.setColor(color3); g.drawString("Levels Gained:", 271, 417); g.setColor(color4); g.drawString("Levels Gained:", 268, 414); */ g.setColor(color3); g.drawString("Status:", 273, 453); g.setColor(color4); g.drawString("Status:", 270, 450); g.setFont(font3); //g.drawString("EXPPH", 121, 375); //g.drawString("GOLDPH", 128, 414); //g.drawString("RUNTIME", 137, 450); //g.drawString("40", 439, 377); //g.drawString("+29", 444, 414); g.drawString("Running: " + endLocX , 370, 452); g.setFont(font4); g.setColor(color1); g.drawString("0.29", 59, 332); } } edit: Added Source: Is anything getting logged? If not, add more log statements to see what is executing. Quote Link to comment Share on other sites More sharing options...
Chambo Posted August 26, 2015 Author Share Posted August 26, 2015 Is anything getting logged? If not, add more log statements to see what is executing. import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.map.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * Created by OSBot Member: Chambo on 8/25/2015. */ @ScriptManifest(author = "Chambo", info = "Chambo's AIO Walker", logo = "", name = "Chambo's AIO Walker Beta", version = 0.79) public class Main extends Script { /** * AREAS */ Area lumbridgeA = new Area( new Position(3225,3213,0), new Position(3218,3225,0)); Area varrockA = new Area( new Position(3219,3433,0), new Position(3207,3424,0)); /** * POSITIONS */ Position[] v2l = new Position[] { new Position(3213,3428,0), new Position(3212,3415,0), new Position(3212,3407,0), new Position(3212,3403,0), new Position(3212,3397,0), new Position(3211,3387,0), new Position(3211,3385,0), new Position(3211,3378,0), new Position(3211,3368,0), new Position(3210,3363,0), new Position(3206,3361,0), new Position(3206,3357,0), new Position(3204,3346,0), new Position(3205,3342,0), new Position(3206,3340,0), new Position(3209,3336,0), new Position(3213,3331,0), new Position(3215,3329,0), new Position(3223,3323,0), new Position(3225,3314,0), new Position(3225,3310,0), new Position(3231,3306,0), new Position(3238,3298,0), new Position(3239,3290,0), new Position(3239,3288,0), new Position(3239,3286,0), new Position(3238,3281,0), new Position(3240,3269,0), new Position(3240,3267,0), new Position(3240,3265,0), new Position(3234,3262,0), new Position(3232,3262,0), new Position(3230,3262,0), new Position(3229,3260,0), new Position(3231,3259,0), new Position(3231,3255,0), new Position(3231,3255,0), new Position(3231,3249,0), new Position(3230,3248,0), new Position(3233,3238,0), new Position(3233,3228,0), new Position(3233,3226,0), new Position(3233,3222,0), new Position(3229,3219,0), new Position(3227,3219,0), new Position(3227,3219,0), new Position(3223,3219,0), new Position(3222,3218,0), new Position(3222,3218,0),}; Position[] l2v = new Position[] { new Position(3222,3218,0), new Position(3222,3218,0), new Position(3223,3219,0), new Position(3227,3219,0), new Position(3227,3219,0), new Position(3229,3219,0), new Position(3233,3222,0), new Position(3233,3226,0), new Position(3233,3228,0), new Position(3233,3238,0), new Position(3230,3248,0), new Position(3231,3249,0), new Position(3231,3255,0), new Position(3231,3255,0), new Position(3231,3259,0), new Position(3229,3260,0), new Position(3230,3262,0), new Position(3232,3262,0),new Position(3234,3262,0), new Position(3240,3265,0), new Position(3240,3267,0), new Position(3240,3269,0), new Position(3238,3281,0), new Position(3239,3286,0), new Position(3239,3288,0), new Position(3239,3290,0), new Position(3238,3298,0), new Position(3231,3306,0), new Position(3225,3310,0), new Position(3225,3314,0), new Position(3223,3323,0), new Position(3215,3329,0), new Position(3213,3331,0), new Position(3209,3336,0), new Position(3206,3340,0), new Position(3205,3342,0), new Position(3204,3346,0), new Position(3206,3357,0), new Position(3206,3361,0), new Position(3210,3363,0), new Position(3211,3368,0), new Position(3211,3378,0), new Position(3211,3385,0), new Position(3211,3387,0), new Position(3212,3397,0), new Position(3212,3403,0), new Position(3212,3407,0), new Position(3212,3415,0), new Position(3213,3428,0),}; public String startLocX = ""; public String endLocX = ""; public void onStart() throws InterruptedException { EventQueue.invokeLater(this::initSettings); log("Script has started!"); synchronized(Main.class) { try { Main.class.wait(); //forces this thread to wait log("Thread is being forced to wait!"); } catch(InterruptedException e) { e.printStackTrace(); log("Thread wasn't forced to wait?"); } } } private void initSettings() { log("Settings Window has been opened!"); JFrame frame = new JFrame("Settings"); frame.setLayout(new FlowLayout()); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { frame.dispose(); log("Settings Window has been closed!"); synchronized (Main.class) { Main.class.notify(); } } }); frame.setLocationByPlatform(true); final String[] startLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> sLBox = new JComboBox<>(startLoc); final String[] endLoc = {"Lumbridge", "Varrock", "Falador", "Al Kharid", "Draynor Village"}; JComboBox<String> eLBox = new JComboBox<>(endLoc); frame.add(sLBox); frame.add(eLBox); JButton button = new JButton("Start"); button.addActionListener(event -> { log("Start button pressed!"); startLocX = sLBox.getSelectedItem().toString(); endLocX = eLBox.getSelectedItem().toString(); frame.dispose(); log("Settings were closed! Script will be started!"); }); frame.add(button); frame.pack(); frame.setVisible(true); } public int onLoop() throws InterruptedException { log("onLoop has started!"); if(startLocX.equals(endLocX)) { log("Starting Location and End Location CANNOT be the same!"); log("Stopping Script..."); bot.stop(); return 600; }else{ if(startLocX.equals("Varrock") && endLocX.equals("Lumbridge")){ log("Walking from " +startLocX+ " to " +endLocX+ "..."); localWalker.walkPath(v2l); if(lumbridgeA.contains(players.myPosition())){ log("You have arrived at " +endLocX+ "!"); bot.stop(); } return 0; } else if(startLocX.equals("Lumbridge") && endLocX.equals("Varrock")){ log("Walking from " +startLocX+ " to " +endLocX+ "..."); localWalker.walkPath(l2v); if(varrockA.contains(players.myPosition())){ log("You have arrived at " +endLocX+ "!"); bot.stop(); } return 0; } else { log("Upgrade to Pro for this location!"); } } return 600; } public void onExit() throws InterruptedException { super.onExit(); } @Override public void onPaint(Graphics2D g) { //This is where you will put your code for paint(s) final Color color1 = new Color(153, 153, 153); final Color color2 = new Color(255, 0, 0); final Color color3 = new Color(0, 0, 0); final Color color4 = new Color(255, 255, 255); final BasicStroke stroke1 = new BasicStroke(3); final Font font1 = new Font("Arial", 0, 9); final Font font2 = new Font("Arial", 1, 21); final Font font3 = new Font("Arial", 0, 15); final Font font4 = new Font("Arial", 0, 8); g.setColor(color1); g.fillRect(9, 346, 500, 126); g.setColor(color2); g.setStroke(stroke1); g.drawRect(9, 346, 500, 126); g.setFont(font1); g.setColor(color1); g.drawString("Version: ", 15, 332); g.setFont(font2); g.setColor(color3); /**g.drawString("EXP p/h:", 17, 378); g.setColor(color4); g.drawString("EXP p/h:", 14, 375); g.setColor(color3); g.drawString("Gold p/h:", 18, 417); g.setColor(color4); g.drawString("Gold p/h:", 15, 414); g.setColor(color3); g.drawString("Run Time:", 18, 454); g.setColor(color4); g.drawString("Run Time:", 15, 451); g.setColor(color3); g.drawString("Current Level:", 270, 380); g.setColor(color4); g.drawString("Current Level:", 267, 377); g.setColor(color3); g.drawString("Levels Gained:", 271, 417); g.setColor(color4); g.drawString("Levels Gained:", 268, 414); */ g.setColor(color3); g.drawString("Status:", 273, 453); g.setColor(color4); g.drawString("Status:", 270, 450); g.setFont(font3); //g.drawString("EXPPH", 121, 375); //g.drawString("GOLDPH", 128, 414); //g.drawString("RUNTIME", 137, 450); //g.drawString("40", 439, 377); //g.drawString("+29", 444, 414); g.drawString("Running: " + endLocX , 370, 452); g.setFont(font4); g.setColor(color1); g.drawString("0.29", 59, 332); } } I added in some logs and it seems that the onLoop() never starts? I followed this tutorial here to get the script to wait for the GUI: http://osbot.org/forum/topic/75074-creating-a-settings-ui-specify-settings-when-script-starts/ Quote Link to comment Share on other sites More sharing options...
Chambo Posted August 26, 2015 Author Share Posted August 26, 2015 Is anyone able to help me with this? Quote Link to comment Share on other sites More sharing options...
FrostBug Posted August 26, 2015 Share Posted August 26, 2015 (edited) If I'm not mistaking you have a deadlock. You're waiting indefinitely in a synchronization block locked on Main.class The EDT tries to enter a synchronization block also locked on Main.class in order to notify the above thread = The EDT cannot enter the synchronization block because a thread is waiting in the first synchronization block = The first thread is never notified Edited August 26, 2015 by FrostBug 1 Quote Link to comment Share on other sites More sharing options...
Chambo Posted August 27, 2015 Author Share Posted August 27, 2015 If I'm not mistaking you have a deadlock. You're waiting indefinitely in a synchronization block locked on Main.class The EDT tries to enter a synchronization block also locked on Main.class in order to notify the above thread = The EDT cannot enter the synchronization block because a thread is waiting in the first synchronization block = The first thread is never notified So how would I go about fixing this issue? Quote Link to comment Share on other sites More sharing options...