Jump to content

Welcome to DreamBot!

Download for Free

Supercharge Your Bots

Run unlimited bots today using DreamBot's Covert Mode and
stay more protected.

Upgrade Now
Frequently Asked Questions
  • Are you not able to open the client? Make sure you have Java 8 installed
  • 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 gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
OSRS Gambling

Interested in advertising your business? Reach out today!

Download the DreamBot client today!
Nex

Scripting Explained. (Basic Woodcutter) Open Source

Recommended Posts

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

Edited by Nex

Share this post


Link to post
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.

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.


×
×
  • Create New...