Jump to content

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


Drewyboyo

Recommended Posts

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) {

}

}

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

getting the same error someone mentioned in the thread of not being able to read the Java 8, looked up a guide on how to set my eclipse project to do so and still getting the errors.

edit: I'll do something instead of mining for now.

Edited by Drewyboyo
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...