Jump to content

Help add on or organize? Anything to make this better?


Recommended Posts

Posted

Thanks to @imateamcape for helping me through writing this first one and helping me understand allot of the functioning of how the script works. Any help or opinions on what I could change/add to make it better would be appreciated, after this has been refined (Since it obviously is from Apa's tutorial) I will try and make another script based off the foundations I have learned.

 

 

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.map.constants.Banks;
import org.osbot.rs07.api.model.RS2Object;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;

@ScriptManifest(author = "Drewyboyo", info = "noob script x d", name = "Tea Thiever", version = 0, logo = "")
public class main extends Script {

@@Override
public void onStart() {
log("Welcome to TeaCx.");
log("If you experience any issues while running this script please report them to me on the forums.");
log("Enjoy the tea :D.");
}


private enum State {
TO_BANK,
OPEN_BANK,
USE_BANK,
TO_STALL,
STEAL
};

private Area myBank = (Banks.VARROCK_EAST);
private Area thievingArea = (new Area(3267, 3415, 3271, 3409));

private State getState() {
if(inventory.isFull()) {
if(myBank.contains(myPlayer())) {
if(getBank().isOpen()) {
return State.USE_BANK;
}
return State.OPEN_BANK;
}
return State.TO_BANK;
}
if(thievingArea.contains(myPlayer())) {
return State.STEAL;
}
return State.TO_STALL;
}

@@Override
public int onLoop() throws InterruptedException {
switch (getState()) {
case TO_STALL:
getWalking().webWalk(thievingArea);
break;
case TO_BANK:
getWalking().webWalk(myBank);
break;
case OPEN_BANK:
break;
case USE_BANK:
getBank().depositAll();
break;
case STEAL:
RS2Object stall = getObjects().closest("Tea Stall");
if(stall != null) {
if(stall.hasAction("Steal-from") && stall.interact("Steal-from")) {
return random(1900, 2500);
}
}
break;
}
return random(200, 300);
}

@@Override
public void onExit() {
log("Thanks for running my Tea Thiever!");
}

@@Override
public void onPaint(Graphics2D g) {

}

}

Posted (edited)
case STEAL:
RS2Object stall = getObjects().closest("Tea Stall");
if(stall != null) {
if(stall.hasAction("Steal-from") && stall.interact("Steal-from")) {
return random(1900, 2500);
}
}
break;

Use conditional sleeps so you don't have to worry about sleeping for too little or too long. It's a good idea to get used to using conditional sleeps now for later down the road if you decide to make other scripts that involve interacting with NPCs/objects.

case STEAL:
RS2Object stall = getObjects().closest("Tea Stall");
if(stall != null) {
    if(stall.hasAction("Steal-from") && stall.interact("Steal-from")) {
        new ConditionalSleep(3_000) {
            @[member='Override']
            public boolean condition() throws InterruptedException {
                return myPlayer().isAnimating();
            }
        }.sleep();
    }
}
break;
Edited by Hayase
Posted
case STEAL:
RS2Object stall = getObjects().closest("Tea Stall");
if(stall != null) {
if(stall.hasAction("Steal-from") && stall.interact("Steal-from")) {
return random(1900, 2500);
}
}
break;

Use conditional sleeps so you don't have to worry about sleeping for too little or too long. It's a good idea to get used to using conditional sleeps now for later down the road if you decide to make other scripts that involve interacting with NPCs/objects.

case STEAL:
RS2Object stall = getObjects().closest("Tea Stall");
if(stall != null) {
    if(stall.hasAction("Steal-from") && stall.interact("Steal-from")) {
        new ConditionalSleep(3_000) {
            @[member='Override']
            public boolean condition() throws InterruptedException {
                return myPlayer().isAnimating();
            }
        }.sleep();
    }
}
break;

I was just starting to make a f2p miner, how do i differ rocks from eachother? ex: They're just called rocks, not iron, copper, etc.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...