Jump to content

What am i doing wrong?


Recommended Posts

Posted

How would i go about fixing these errors? help would be much apprecaited! <3 


Errors:
https://gyazo.com/47644d4e6e865d391b6eb94e8fd3191e

 

Script code

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;

@ScriptManifest(name = "WoodcutterScript", author = "Pgreen", version = 1.0, info = "Basic Woodcutting Script", logo = "")

public class WoodcutterScript extends Script {
    private static final Area TREE_AREA = new Area(3163, 3287, 3167, 3290);

    public class Woodcutter extends Script {
        private long startTime = System.currentTimeMillis();
        private int logsCut = 0;

        // ... (Existing code)


        @Override
        public void onStart() {
            log("Starting Woodcutter script...");
        }

        @Override
        public void onExit() {
            log("Stopping Woodcutter script...");
        }

        @Override
        public int onLoop() throws InterruptedException {
            // The onLoop() method contains the main logic of your script
            // Put the actions you want to repeat here

            // If we don't have an axe equipped, let's equip one
            if (!getEquipment().isWearingItem("Bronze axe") && !getInventory().contains("Bronze axe")) {
                getEquipment().equip("Bronze axe");
                return random(1000, 1500); // Wait for the equipment screen to open
            }

            // If our inventory is full, let's go to the bank and deposit the logs
            if (getInventory().isFull()) {
                getBank().open();
                getBank().depositAll("Logs");
                getBank().close();
            } else {
                // If we're not in the tree area, let's walk there
                if (!TREE_AREA.contains(myPlayer())) {
                    getWalking().webWalk(TREE_AREA);
                } else {
                    // If we're in the tree area, let's cut trees
                    RS2Object tree = getObjects().closest("Tree");
                    if (tree != null && tree.isVisible()) {
                        tree.interact("Chop down");
                        sleepUntil(() -> myPlayer().isAnimating() || myPlayer().isMoving(), random(3000, 5000));
                        sleepUntil(() -> !myPlayer().isAnimating(), random(5000, 8000));
                        logsCut++;
                    }
                }
            }

            return random(100, 200); // Return a value to set the delay between loops
        }


        @Override
        public void onPaint(Graphics2D g) {
            // This is where you can add your custom paint
            // Calculate time spent woodcutting
            long timeElapsed = System.currentTimeMillis() - startTime;
            String timeFormatted = formatTime(timeElapsed);

            // Get woodcutting level
            int woodcuttingLevel = getSkills().getStatic(Skill.WOODCUTTING);

            // Draw the custom paint
            g.setColor(Color.BLACK);
            g.fillRect(10, 10, 180, 75);
            g.setColor(Color.WHITE);
            g.drawRect(10, 10, 180, 75);
            g.setFont(new Font("Arial", Font.PLAIN, 14));
            g.drawString("Woodcutting Level: " + woodcuttingLevel, 15, 30);
            g.drawString("Logs Cut: " + logsCut, 15, 50);
            g.drawString("Time Running: " + timeFormatted, 15, 70);
        }

        private String formatTime(long time) {
            long seconds = time / 1000;
            long minutes = seconds / 60;
            long hours = minutes / 60;
            long days = hours / 24;
            return String.format("%02d:%02d:%02d:%02d", days, hours % 24, minutes % 60, seconds % 60);
        }

        // ... (Existing code)
    }
}


Posted (edited)

 i fixed it kinda but still throwing these errors:

https://gyazo.com/3e92e2cb80ac5a01ba05135fab31a4f8

 

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import java.awt.*;

@ScriptManifest(name = "WoodcutterScript", author = "Pgreen", version = 1.0, info = "Basic Woodcutting Script", logo = "")
    public class WoodcutterScript extends Script {
        private long startTime = System.currentTimeMillis();
        private int logsCut = 0;

        private static final Area TREE_AREA = new Area(3163, 3287, 3167, 3290);

        @Override
        public void onStart() {
            log("Starting Woodcutter script...");
        }

        @Override
        public void onExit() {
            log("Stopping Woodcutter script...");
        }

        @Override
        public int onLoop() throws InterruptedException {
            // The onLoop() method contains the main logic of your script
            // Put the actions you want to repeat here

            // If we don't have an axe equipped, let's equip one
            if (!getEquipment().isWearingItem("Bronze axe") && !getInventory().contains("Bronze axe")) {
                getEquipment().equip("Bronze axe");
                return random(1000, 1500); // Wait for the equipment screen to open
            }

            // If our inventory is full, let's go to the bank and deposit the logs
            if (getInventory().isFull()) {
                getBank().open();
                getBank().depositAll("Logs");
                getBank().close();
            } else {
                // If we're not in the tree area, let's walk there
                if (!TREE_AREA.contains(myPlayer())) {
                    getWalking().webWalk(TREE_AREA);
                } else {
                    // If we're in the tree area, let's cut trees
                    RS2Object tree = getObjects().closest("Tree");
                    if (tree != null && tree.isVisible()) {
                        tree.interact("Chop down");
                        sleepUntil(() -> myPlayer().isAnimating() || myPlayer().isMoving(), random(3000, 5000));
                        sleepUntil(() -> !myPlayer().isAnimating(), random(5000, 8000));
                        logsCut++;
                    }
                }
            }

            return random(100, 200); // Return a value to set the delay between loops
        }


        @Override
        public void onPaint(Graphics2D g) {
            // This is where you can add your custom paint
            // Calculate time spent woodcutting
            long timeElapsed = System.currentTimeMillis() - startTime;
            String timeFormatted = formatTime(timeElapsed);

            // Get woodcutting level
            int woodcuttingLevel = getSkills().getStatic(Skill.WOODCUTTING);

            // Draw the custom paint
            g.setColor(Color.BLACK);
            g.fillRect(10, 10, 180, 75);
            g.setColor(Color.WHITE);
            g.drawRect(10, 10, 180, 75);
            g.setFont(new Font("Arial", Font.PLAIN, 14));
            g.drawString("Woodcutting Level: " + woodcuttingLevel, 15, 30);
            g.drawString("Logs Cut: " + logsCut, 15, 50);
            g.drawString("Time Running: " + timeFormatted, 15, 70);
        }

        private String formatTime(long time) {
            long seconds = time / 1000;
            long minutes = seconds / 60;
            long hours = minutes / 60;
            long days = hours / 24;
            return String.format("%02d:%02d:%02d:%02d", days, hours % 24, minutes % 60, seconds % 60);
        }

        // ... (Existing code)
    }





 

Edited by JaggerNotchas

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...