Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package WoodCut;
- import org.osbot.rs07.api.map.Area;
- import org.osbot.rs07.api.model.RS2Object;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- @ScriptManifest(name = "Basic Woodcutter", author = "Joey", version = 1, info = "Cuts wood", logo = "")
- public class Main extends Script {
- private State state;
- //Create your are for where to woodcut
- Area WC = new Area (0,0,0,0);
- //Create your are for your bank
- Area Bank = new Area(0,0,0,0);
- private enum State {
- //These are what must be true and it will go to the case
- Woodcut,WalkToBank,Bank,WalkToWoodcut
- }
- private State getState() {
- //This is where you tell it which case to go to. If true it will go to that case
- if (getInventory().isFull() && Bank.contains(myPlayer())) {
- return state.Bank;
- }
- if (getInventory().isFull() && !Bank.contains(myPlayer())) {
- return state.WalkToBank;
- }
- if (!getInventory().isFull() && WC.contains(myPlayer())) {
- return state.Woodcut;
- }
- if (!getInventory().isFull() && !WC.contains(myPlayer())) {
- return state.WalkToWoodcut;
- }
- return state.Bank;
- }
- public void onStart() {
- //Dont worry about onStart
- }
- @Override
- public int onLoop() throws InterruptedException {
- state = getState();
- switch (state) {
- case Bank:
- //Basically you're saying if the bank isn't open, go open it.
- if (!getBank().isOpen()) {
- getBank().open();
- } else {
- //Now you're saying if the bank is open, deposit everything you have
- getBank().depositAll();
- }
- case WalkToBank:
- //Basic webWalking to the bank. Will handle any obstacle in the way
- getWalking().webWalk(Bank);
- break;
- case Woodcut:
- if (myPlayer().isAnimating()) {
- //You're saying if my player is woodcutting, to do nothing
- //Do nothing
- } else {
- //Here you are null checking the tree. Once it is not equal to null, you can chop. It will only do this when it is not already chopping
- RS2Object tree = getObjects().closest("Tree");
- if (tree != null) {
- tree.interact("Chop");
- }
- }
- break;
- case WalkToWoodcut:
- //Basic webWalk to the area you created for chopping.
- getWalking().webWalk(WC);
- break;
- }
- //This is how long it takes to loop
- return random(150, 175);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement