Jump to content

Question about calling "Servant"


Imthabawse

Recommended Posts

So in my couple day journey I've managed to get my bot to successfully "Build" and "Remove" oak larders thanks to many users advice, tutorials, snippets, etc. Now I've ran into the problem of trying to get the bot to check inventory if I have enough planks to build larders or not. If not then call servant and un-note planks, keep building. If anyone would like to look over the script and point out how retarded I am that'd be great! ?

package simpleLarders;

import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.ui.RS2Widget;
import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;

@ScriptManifest(name = "Simple Larders", author = "Imthabawse", version = 1.0, info = "Makes Oak Larders", logo = "")  //Helps the client understand and find the script we compile

public class SimpleLarders extends Script {

    @Override

    public void onStart() {
log ("Welcome to Simple Larders, Let's start building!");
        //Code here will execute before the loop is started

    }



    @Override

    public void onExit() {
log ("Thanks for using Simple Larders.");
        //Code here will execute after the script ends

    }
 // Should code for checking planks and calling servant be outside onLoop?
    @Override

    public int onLoop() {
        Entity larder_space = getObjects().closest("Larder space");
        if (larder_space != null && larder_space.interact("Build")) {
            new ConditionalSleep(4000) {
                @Override
                public boolean condition() {
                    return !larder_space.exists();
                }
            }.sleep();
        }

        RS2Widget buildlarder = getWidgets().get(458, 5, 4);
        if (buildlarder != null && buildlarder.interact("Build")) {
            new ConditionalSleep(4000) {
                @Override
                public boolean condition() {
                    return myPlayer().isAnimating();
                }
            }.sleep();
        }

        Entity larder = getObjects().closest("Larder");
        if (larder != null && larder.interact("Remove")) {
            new ConditionalSleep(4000) {
                @Override
                public boolean condition() {
                    return !larder.exists();
                }
            }.sleep();
        }
        
        RS2Widget removelarder = getWidgets().getWidgetContainingText("Yes");
        if (removelarder != null && removelarder.interact()) {
        	new ConditionalSleep(4000) {
        		@Override
        		public boolean condition() {
        			return myPlayer().isAnimating();
        		}
        	}.sleep();
        } //Script runs great till this point with a return underneath
          // But I tried to implement checking for planks and calling servant below
        if (getInventory().getAmount("Oak plank") > 5);
        RS2Widget settings = getWidgets().get(548, 35);
        if(settings != null && settings.interact()) {
        	new ConditionalSleep(4000) {
        		@Override
        		public boolean condition() {
        			return myPlayer().isAnimating(); // *Sure this is wrong
        		}                            // Because players not animating?
        	}.sleep();
        }
        
        RS2Widget house = getWidgets().get(261, 99);
        if (house != null && house.interact()) {
        	new ConditionalSleep(4000) {
        		@Override
        		public boolean condition() {
        			return myPlayer().isAnimating(); //* Same as above
        		}
        	}.sleep();
        }
        
        RS2Widget servant = getWidgets().get(370, 19, 0);
        if (servant != null && servant.interact()) {
        	new ConditionalSleep(4000) {
        		@Override
        		public boolean condition() {
        			return myPlayer().isAnimating(); //* Same as above
        		}
        	}.sleep();
        }
        
        RS2Widget unnote = getWidgets().get(219, 1, 1);
        if (unnote != null && unnote.interact()) {
        	new ConditionalSleep(4000) {
        		@Override
        		public boolean condition() {
        			return myPlayer().isAnimating(); //* Same as above
        		}
        	}.sleep();
        }
        
        RS2Widget inven = getWidgets().get(548, 51);
        if (inven != null && inven.interact()) {
        	new ConditionalSleep(8000) {
        		@Override
        		public boolean condition() {
        			return myPlayer().isAnimating(); //* Same as above
        		}
        	}.sleep();
        }
        
        return 5000; //The amount of time in milliseconds before the loop starts over
    }
}

 

thumb_please-help-me-im-dumb-memepanerator-net-me-pretending-like-i-37721104.png

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