Jump to content

Booleans YAY

Recommended Posts

It's a basic short and simple system. I'm learning the API so please if you have any additional ideas and things to add or guides or anything I can use to better myself and my scripts please PM me or reply here!!

 

Script Features:

  • Camera Movement
  • Picks up full inventory of Bones to bury

Hoping to add more!

 

Jar: https://mega.nz/#!1R11TTjJ!WkjkMtG6EU-c-k0StJGnVVLgA4nIUiGP1xP4tTJwBnM

Raw: https://paste.ee/p/2ZRLP

package main.script;

import java.awt.Graphics2D;

import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.model.Item;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

@ScriptManifest(author = "Booleans Yay", info = "Bone burying made ez pz", name = "Bone Bury", version = 1, logo = "")

public class BoneBury extends Script
{

	@[member='Override']
	public void onStart(){}
	
	private enum BotState
	{
		PICKUP, BURY
	};

	private BotState getState()
	{
		return inventory.isFull() ? BotState.BURY : BotState.PICKUP;
	}
	
	@[member='Override']
	public int onLoop() throws InterruptedException
	{
		switch (getState())
		{
		case PICKUP:
			if (!myPlayer().isAnimating())
			{
				GroundItem bone = groundItems.closest("Bones");
				if (bone != null)
				{
					bone.interact("Take");
					Thread.sleep(random(1500));
				}
			}
			break;
		case BURY:
			camera.moveYaw(random(360));
			while (!inventory.isEmpty())
			{
				Item bones = inventory.getItem("Bones");
				if (bones != null)
				{
					bones.interact("Bury");
					if (myPlayer().isAnimating())
					{
						bones.interact("Bury");
						Thread.sleep(random(200));
					}
				}
			}
			break;
		}
		return random(200, 300);
	}

	@[member='Override']
	public void onExit(){}

	@[member='Override']
	public void onPaint(Graphics2D g){}
}
Edited by booleans yay
  • Like 1
Link to comment
Share on other sites

Everything is fine and dandy, but personally the code style of how you put braces is what saddens me the most, also the state framework you have is the cause for some spaghetti code.

But instead of using just simple sleeps, try looking into the ConditionalSleep class of OSBot.

Just my two cents :xfeels:

Link to comment
Share on other sites

Will sleep until the inventory is empty or until 5.5 seconds have passed. Look into using this in your scripts as it is a lot better than regular sleeps. 

Also as Vilius stated, the bracket placement is off and makes it harder to read. 


  new ConditionalSleep(5500) {
                        @ Override
                        public boolean condition() throws InterruptedException {
                            return a.getInventory().isEmpty();
                        }
                    }.sleep();


Overall, not bad for your first script

Edited by Juggles
  • Like 1
Link to comment
Share on other sites

This isn't bad for a first script. However, a more efficient way of burying would be:

while(inventory.contains("Bones")) {
 inventory.interact("Bury", "Bones");
}

Also, look into conditionalsleeps.

				if (bone != null) {
					bone.interact("Take");
					Thread.sleep(random(1500));
				}

could be:

long boneCount = inventory.getAmount("Bones");
new ConditionalSleep(5000) {
   @ Override
   public boolean evaluate() {
        return inventory.getAmount("Bones") > boneCount;
   }
}.sleep();

This will sleep until you have more bones, or until 5 seconds have passed. Very useful in situations like this.

 

Also, this is java! Please never use that brace formation!

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