Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Error in script onStart()

Featured Replies

Hello,

 

I'm working on a script for OSBot, but I've run into a bit of an issue that's driving me crazy

 

I try to open up a JFrame in my onStart(), and I always get the error "Error in script onStart()". That would be fine and dandy if I got some kind of exception in the console, but I'm not, so I have no idea why the error is occurring. By printing out things via the logger, I've determined that the issue is occurring in a constructor of mine. However this constructor still causes an issue even if it's blank. 

public void onStart() {
        this.getBot().getLogger().debug("Opening up JFrame...");
        config = new StartConfig(this);
        window = new JFrame("Start PestControlSucks");
        window.setSize(570, 330);
        window.add(config.getControlPane());
        window.pack();
        window.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        window.setLocation(dim.width / 2 - window.getWidth() / 2, dim.height / 2 - window.getHeight() / 2);
        window.setVisible(true);
        this.getBot().getLogger().debug("JFrame opened, waiting on user input!");
    }

Based on previous debug messages I left, it never gets past new StartConfig

public StartConfig(PestControl instance) {
        this.instance = instance;
        try {
            instance.getBot().getLogger().debug("Setting up radio group");
            radioGroup.add(radioPurchaseXP);
            radioGroup.add(radioPurchaseVoid);
            radioGroup.add(radioLogOut);
            defaultColor = panelAttack.getBackground();

            instance.getBot().getLogger().debug("Starting to load icons");

            // Experience rewards
            labelAttack.setIcon(loadImageIcon("attack"));
            labelStrength.setIcon(loadImageIcon("strength"));
            labelDefence.setIcon(loadImageIcon("defence"));
            labelRange.setIcon(loadImageIcon("range"));
            labelMagic.setIcon(loadImageIcon("magic"));
            labelHitpoints.setIcon(loadImageIcon("hitpoints"));
            labelPrayer.setIcon(loadImageIcon("prayer"));

            // Void rewards
            labelVoidMace.setIcon(loadImageIcon("void_mace"));
            labelVoidBottom.setIcon(loadImageIcon("void_bottom"));
            labelVoidTop.setIcon(loadImageIcon("void_top"));
            labelVoidMelee.setIcon(loadImageIcon("void_melee"));
            labelVoidRange.setIcon(loadImageIcon("void_range"));
            labelVoidMage.setIcon(loadImageIcon("void_mage"));
            labelVoidGloves.setIcon(loadImageIcon("void_gloves"));

            buttonStart.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    StartConfig.this.instance.reallyStart();
                }
            });
        } catch (Exception ex) {
            instance.getBot().getLogger().debug("Error: " + ex.toString());
            instance.getBot().getLogger().error(this, ex);
            ex.printStackTrace();
        }
    }

However, it never even gets to "Setting up radio group"

 

What's going on? Is there any way to enable stacktraces for onStart()

 

Thanks!

you can remove everything from on start. Closely add in each line and see which line give you the error.

Edited by josedpay

is startconfig in your main class?  if so why are you passing an instance of PestControl(which i assume is your main class)

Edited by Novak

  • Author

is startconfig in your main class?  if so why are you passing an instance of PestControl(which i assume is your main class)

 

No, PestControl is the main class. I designed the GUI with Intellij's Swing designer. StartConfig contains the control JPanel, which I add into a JFrame

you can remove everything from on start. Closely add in each line and see which line give you the error.

 

I have already pinpointed the constructor for StartConfig as the error, the rest of onStart works properly

  • Author

I ended up using a hacky solution to get the stacktrace from the bot thread. It looks like the NPE was getting thrown in a function called $$$setupUI$$$(), which is automatically generated by Intellij for the Swing designer.

 

I had no clue as to why it wasn't working, so I ended up deleting the form and recreating it, and it worked.

Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.