Jump to content

Script won't Start/Run


Recommended Posts

Posted (edited)

Just recently finished adding a closestBank method and ever since my bot won't load. Eclipse doesn't give many errors or nothing, i'm so confused as to what's is causing it.

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.map.Area;
import java.awt.*;
import javax.swing.*;
 
@ScriptManifest(name = "MaxChopper", author = "Cloudcode", version = 1.0, info = "", logo = "")
public class Main extends Script {
       
        public Main() {
            lastTimeCalled = System.currentTimeMillis() - 900000;
        }
        public int wCutLvl;
        public int attackLvl;
        public Area closestBank = Bank.getClosestBank(this);;
        public int highestUsableHatchet;
        public int highestWieldableHatchet;
        private long lastTimeCalled;
        public Area grandExchange = new Area(3162, 3486, 3167, 3486);
        private JFrame gui;
        @SuppressWarnings("unused")
		private String selectedMethod; // Global String variable to store selected option
        private boolean started = false; // Declared at the top of the script (Global)
       
 
    public void onStart() {
        log("Script Started...");
        createGUI();
       
    }
 
    public int getLvls() {
 
        wCutLvl = skills.getStatic(Skill.WOODCUTTING);
        return attackLvl = skills.getStatic(Skill.ATTACK);
    }
    @[member='Override']
    public int onLoop() throws InterruptedException {
 
       
        if(started){
 
            getHighestUsableHatchet();
            getHighestWieldableAxe();
 
        if(highestUsableHatchet == highestWieldableHatchet && inventory.contains(highestUsableHatchet)) {
            getInventory().interact("Wield", highestWieldableHatchet);
        }
        else if (getInventory().equipment.contains(highestWieldableHatchet)) {
           
        }
        else if(!inventory.contains(highestUsableHatchet) || (!getInventory().equipment.contains(highestWieldableHatchet))) {
            getHatchet();
        }
        if(System.currentTimeMillis() - lastTimeCalled > 900000) {
            randomizer();
            }
        }
        return random(200, 300);
}
 
    @[member='Override']
    public void onExit() {
        log("Stopping Script...");
        if(gui != null) { // If the JFrame has been created
 
            gui.setVisible(false); // Hide it
            gui.dispose(); // Dispose
        }
    }
 
    @[member='Override']
    public void onPaint(Graphics2D g) {
       
           if(started){ // If the user has started the script
 
                // Rest of the paint code
            }
 
    }
    public void getHatchet() {
        getWalking().webWalk(closestBank);
       
    }
 
    public void getHighestUsableHatchet () {
   
        if(wCutLvl < 6)
        {
            highestUsableHatchet = 1349;
        }
        else if(wCutLvl >= 6 && wCutLvl < 11)
        {
            highestUsableHatchet = 1353;
        }
        else if(wCutLvl >= 11 && wCutLvl < 21)
        {
            highestUsableHatchet = 1361;
        }
        else if(wCutLvl >= 21 && wCutLvl < 31)
        {
            highestUsableHatchet = 1355;
        }
        else if(wCutLvl >= 31 && wCutLvl < 41)
        {
            highestUsableHatchet = 1357;
        }
        else if(wCutLvl >= 41 && wCutLvl < 61)
        {
            highestUsableHatchet = 6739;
        }
    }
    public void getHighestWieldableAxe()
    {
        if(attackLvl < 5)
        {
            highestWieldableHatchet = 1349;
        }
        else if(attackLvl >= 5 && attackLvl < 10)
        {
            highestWieldableHatchet = 1353;
        }
        else if(attackLvl >= 10 && attackLvl < 20)
        {
            highestWieldableHatchet = 1361;
        }
        else if(attackLvl >= 20 && attackLvl < 30)
        {
            highestWieldableHatchet = 1355;
        }
        else if(attackLvl >= 30 && attackLvl < 40)
        {
            highestWieldableHatchet = 1357;
        }
        else if(attackLvl >= 40 && attackLvl < 60)
        {
            highestWieldableHatchet = 6739;
        }  
    }
   
    public void randomizer()
    {
       
    }
       private void createGUI(){
 
            // Declare two constants for width and height of the GUI
            final int GUI_WIDTH = 350, GUI_HEIGHT = 200;
 
            // Get the size of the screen
            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
 
            // Calculating x and y coordinates
            final int gX = (int) (screenSize.getWidth() / 2) - (GUI_WIDTH / 2);
            final int gY = (int) (screenSize.getHeight() / 2) - (GUI_HEIGHT / 2);
 
            // Create a new JFrame with the title "GUI"
            gui = new JFrame("GUI");
 
            // Set the x coordinate, y coordinate, width and height of the GUI
            gui.setBounds(gX, gY, GUI_WIDTH, GUI_HEIGHT);
 
            gui.setResizable(false); // Disable resizing
 
            // Create a sub container JPanel
            JPanel panel = new JPanel();
 
            // Add it to the GUI
            gui.add(panel);
 
            JLabel label = new JLabel("Select a method:"); // Create a label
            label.setForeground(Color.white); // Set text color to white
            panel.add(label); // Add it to the JPanel
 
            // Create a select box for tree options
            JComboBox<String> methodSelector = new JComboBox<>(new String[]{"Quickest Method(PowerChopping)", "Profitable Method (Banking)"});
 
            // Add an action listener, to listen for user's selections, assign to a variable called selectedTree on selection.
            methodSelector.addActionListener(e -> selectedMethod = methodSelector.getSelectedItem().toString());
 
            // Add the select box to the JPanel
            panel.add(methodSelector);
           
            JButton startButton = new JButton("Start");
            startButton.addActionListener(e -> {
                started  = true;
                gui.setVisible(false);
            });
            panel.add(startButton);
 
            // Make the GUI visible
            gui.setVisible(true);
        }
 
}
Edited by CloudCode

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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