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
  • Scripting Explained. (Basic Woodcutter) Open Source


    Nex

    Recommended Posts

    Posted

    Im gonna try to explain it as best as i can feel free to comment below what i should add into this guide :) 

     

    To start off every script needs this for the client to be able to read/start it,

    @ScriptManifest(author = "You", name = "Script Name", version = Version, description = "", category = Category of the script)
    public class main 
    extends AbstractScript {	
    

    Script Skeleton:

    So with this in mind were gonna build up a skeleton for the script, all scripts need this: (onExit isnt needed but usefull for infomation)

    @ScriptManifest(author = "Nex", name = "Nex Tree Assasin", version = 0.1, description = "Harrasing tree's", category = Category.WOODCUTTING)
    public class main 
    extends AbstractScript {	
    
        @Override
        public void onStart() {  
        }
     
        @Override
        public int onLoop() {
           return 0;
        }
     
        @Override
        public void onExit() {
        }
    }
    	   
    

    onStart():

    Here you place anything that will be used at the beginning of a script, Example:

    @Override
        public void onStart() {
            log("Starting!");	 
        } 

    onExit():

    Same as with onStart() but this will show when stopping the script, Example:

    @Override
        public void onExit() {
        	log("Stopping!");
        }
    

    onLoop():

    This is where the majority of you're script will take place will go into detail on this later,

     

    Complete Script:

    b114abdf3ff5c0ce9b414fc492fb6ebe.png

    For the Leechers:

    import org.dreambot.api.script.AbstractScript;  // All these imports are from the dreambot API
    import org.dreambot.api.script.ScriptManifest;  // API can be found here: https://dreambot.org/javadocs/
    import org.dreambot.api.script.Category;
    import org.dreambot.api.wrappers.interactive.GameObject;
    
    
    @ScriptManifest(author = "Nex", name = "Nex Tree Assasin", version = 0.1, description = "Harrasing tree's", category = Category.WOODCUTTING)
    public class main 
    extends AbstractScript {	
    
    	@Override
        public void onStart() {
    		log("Starting!");	 // This will display in the CMD or logger on dreambot
        }
     
        @Override
        public int onLoop() {
        	if (getInventory().isFull()) { // Here we check if the inventory is full.
        		getInventory().dropAll("Logs"); // Here we drop all items IF the inventory is full, we specificly telling it to only drop "Logs"
        		sleep(300,500); // This is a basic sleep meaning it will wait for 0,3-0,5 sec
        	} else { // if the inventory isnt full, the script will move on to the next part "else" if inv isnt full.
            	GameObject tree = getGameObjects().closest("Tree"); // Here we define what a tree is in the script, it will search for the nearest game object with the name "Tree"
            	if (tree != null) { // Null check so tree isnt nulled.
        			tree.interact("Chop down"); // Here we say it has to interact with the tree the interaction is "Chop down"
        			sleep(500,600); // This is a basic sleep meaning it will wait for 0,5-0,6 sec
        			sleepUntil(() -> !getLocalPlayer().isAnimating() , 15000); // this will make the bot sleep untill its animating (moving in this case chopping a tree) the 5000 in the end means it will wait 15 sec or re-attempt
                }
        	}   
        	return 300; // basic return value. 
        }
           
        @Override
        public void onExit() {
        	log("Stopping!"); // this will display in the CMD or logger on dreambot
        }
    }
    	    

    Posted

    Nice one :)

    But why are all Tutorials based on Woodcutting :P

    because most people start off making a woodcutter + its easy

     

    Cool tutorial.

    thanks 

    • 4 months later...
    Posted

    Java 8 Update 151

    Are you sure your IDE is using Java 8?

    Posted

    im using the latest version of eclipse for win32

    Posted

    Your ide needs to be configured to use java 8

    Archived

    This topic is now archived and is closed to further replies.

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