Jump to content

Chop and Burn


TiasJanos

Recommended Posts

Hi all! I was wondering if somebody could help me with my script. It chops trees alright but once the inventory is full it will not light them.

 


import java.awt.Graphics2D;

import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.utility.ConditionalSleep;
import org.osbot.rs07.api.map.Area;



@ScriptManifest(author = "Tias", info = "Cuts trees and burns logs", name = "Choppy and Burny", version = 0, logo = "")
public class Main extends Script {

    @Override
    public void onStart() {
        log("Let's get started!");
    }

    @Override
    public int onLoop() throws InterruptedException {

        int runEnergy = settings.getRunEnergy();
        if (runEnergy > 50 && !settings.isRunning()) {
            settings.setRunning(true);
        }


        RS2Object tree = getObjects().closest(obj -> obj != null && obj.getName().equals("Tree") && getMap().canReach(obj)); //What tree to chop.
        if (!myPlayer().isAnimating() && !getInventory().isFull()) {
            if (tree != null) {
                if (tree.interact("Chop down")) {
                    new ConditionalSleep(5000, 2000) {
                        @Override
                        public boolean condition() throws InterruptedException {
                            return false;
                        }
                    }.sleep();
                }
            }

            else if (tree == null) {  //If it doesn't see a tree it moves the camera and then moves.
                Area treeArea = new Area(3143, 3239, 3198, 3205);
                getCamera().toEntity(tree);
                log("Searching for a tree...");
                if (getWalking().webWalk(treeArea)) {
                    log("Walking to trees...");
                    new ConditionalSleep(5000, 6000) {
                        @Override
                        public boolean condition() throws InterruptedException {
                            return false;
                        }
                    };
                }
            }
            else if (getInventory().isFull()) {
                log("Burning  logs");
                while (inventory.contains("Logs")) {
                    log("looop");

                    if (inventory.isItemSelected()) { inventory.deselectItem(); }

                    if(!(myPlayer().isAnimating()) && inventory.interact("Use", "Tinderbox")) {
                        if (inventory.isItemSelected() && inventory.interactWithNameThatContains("Use", "Logs")) {
                            new ConditionalSleep(3000) {
                                @Override
                                public boolean condition() {
                                    return (myPlayer().isAnimating());
                                }
                            }.sleep();
                        }
                    }
                }
            }
        }

        return random(200, 300);
    }

    @Override
    public void onExit() {
        log("Thanks for running!");
    }

    @Override
    public void onPaint(Graphics2D g) {

    }

}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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