Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

First attempt Woodcutting bot

Featured Replies

Hey guys,

 

I am working on my first woodcutting bot and it seems work but my problem is that if it clicks a tree, it also click another tree. So sometimes it walks between two trees but idk what the problem is.

import org.osbot.rs07.api.Inventory;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
 


import java.awt.*;
 
@ScriptManifest(author = "Jrock", info = "My first script", name = "JWoodcutter", version = 0.01, logo = "")
public class main extends Script {
 
	String tree = "Tree";
	
    @Override
    public void onStart() {
        log("Let's get started with JWoodcutter");
    }
 
    @Override
    public int onLoop() throws InterruptedException {
    	Inventory invent = inventory.getInventory();
    	if(!invent.isFull() && !myPlayer().isAnimating()) chopping
    	{
    		Entity treeEntity = objects.closest(tree);
    		if(treeEntity != null)
    		{
    			treeEntity.interact("Chop down");
    		}
    	}
    	
        return random(200, 300);
    }
 
    @Override
    public void onExit() {
        log("Thanks for running my Woodcutter!");
    }
 
    @Override
    public void onPaint(Graphics2D g) {
 
    }
 
}

Kind Regards,

 

Jrock1000

To understand why this fully works, you need to (somewhat) understand how OSRS works as well as how the OSBot API works. I'll explain both the theory and the solution, but I'll put the theory in a spoiler so you don't have to read it.

 

Theory:

In RS, actions work on a tick-based system. Each tick lasts approximately 2/3 of a second (let's just call it 0.6 seconds), which means that if you click, it wont actually run until the next game tick (anywhere between 0.001 and 0.6 seconds if you think about it). In the perspective of a game tick, you'd be clicking this tree 2-3 times per game tick.

 

Lastly, as far as OSBot goes, the #closest() method works by counting the amount of tiles between you and the object, not the actual distance. This means that an object that is technically further away from you (diagonal vs pure horizontal; our main man Pythagoras proves this) is counted as the same distance.

 

Your solution would be to tag your tree in a variable, like so:

//Global var
Entity tree;

//onLoop
if (tree == null || !tree.exists()) {
    tree = getObjects().closest("Tree");
    if (!tree.isVisible()) getCamera().toEntity(tree);
    tree.interact("Chop down");
}

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.