Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • [Script Help] How to select make all option


    zakkyzebra
     Share

    Recommended Posts

    Hey all, so I am a web developer by day, botter by night(and day) and I decided to learn how to write scripts.

     

    I haven't read a lick of java, which I really should, but I don't want to read all of Java's documentation to write a simple little script. So if you know of some good readings on java for osrs, I will look into your recommendations!

     

    Anyways, I decided to make a simple wine maker, but I am stuck at the dialog where it asks you how many you want to make.

     

    How do I reference the dialog and options to use them?

     

    Here is what I have so far, and yes I'm aware some of the methods aren't fool-proof and will eventually break, but I'm workin' on it!

    import org.dreambot.api.methods.Calculations;
    import org.dreambot.api.script.AbstractScript;
    import org.dreambot.api.script.ScriptManifest;
    import org.dreambot.api.script.Category;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    @ScriptManifest(author = "Me", name = "Wine Script", version = 0.1, description = "A script to test out coding in java", category = Category.THIEVING)
    public class main extends AbstractScript {
    
    	public void onStart() {
    		GameObject bank = getGameObjects().closest("Bank booth");
    		bank.interact("Bank");
    	}
    
    	private enum State {
    		BANK, WAIT, COOK, MAKE
    	};
    
    	private State getState() {
    		if (getBank().isOpen())
    			return State.BANK;
    		if (getInventory().getEmptySlots() == 14)
    			return State.BANK;
    		if (getInventory().getEmptySlots() == 0 && !getDialogues().inDialogue())
    			return State.COOK;
    		if (getDialogues().inDialogue())
    			return State.MAKE;
    		return State.WAIT;
    	}
    
    	public void onExit() {
    
    	}
    
    	@Override
    	public int onLoop() {
    		switch (getState()) {
    		case BANK:
    			log("on bank");
    			GameObject bank = getGameObjects().closest("Bank booth");
    			if (!getBank().isOpen()) {
    				bank.interact("Bank");
    			}
    			if (getBank().isOpen()) {
    				getBank().depositAllItems();
    				sleep(Calculations.random(50, 200));
    				getBank().withdraw(1987, 14);
    				sleep(Calculations.random(100, 300));
    				getBank().withdraw(1937, 14);
    				sleep(Calculations.random(50, 250));
    				getBank().close();
    			}
    			sleep(Calculations.random(100, 600));
    			break;
    		case WAIT:
    			log("on wait");
    			sleep(Calculations.random(100, 600));
    			break;
    
    		case COOK:
    			log("on cook");
    			getInventory().interact(1937, "Use");
    			getInventory().interact(1987, "Use");
    			break;
    
    		case MAKE:
    			log("on make");
    			break;
    		}
    		return Calculations.random(500, 600);
    	}
    }
    

    Thanks in advance for the help! 

     

    Also, how can I print things to the console other than with the log method? I have no clue how to print anything which makes it harder to debug and continue.

     

    EDIT: FIGURED IT OUT

     

    added

    			if (getWidgets().getChildWidget(309, 3) !=null && getWidgets().getChildWidget(309, 3).interact("Make All")){
    				log("making");	
    			}
    

    to MAKE

    Edited by zakkyzebra
    Link to comment
    Share on other sites

    Interacting "make-all" uses something called a Widget. If no one helps you soon I'll get you started but I really can't atm.

     

    edit: I see you found it. There's quite some magic behind them, I can help you with it later :)

    Link to comment
    Share on other sites

    Guest
    This topic is now closed to further replies.
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.