rj
07-02-2013, 01:59 PM
Why isn't this script looping? :s infact it does nothing at all
package miner;
import org.parabot.core.ui.components.LogArea;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.Category;
import org.parabot.environment.scripts.Script;
import org.parabot.environment.scripts.ScriptManifest;
import org.rev317.api.methods.Bank;
import org.rev317.api.methods.Camera;
import org.rev317.api.methods.Inventory;
import org.rev317.api.methods.Players;
import org.rev317.api.methods.SceneObjects;
import org.rev317.api.methods.Skill;
import org.rev317.api.methods.Walking;
import org.rev317.api.wrappers.scene.Area;
import org.rev317.api.wrappers.scene.SceneObject;
import org.rev317.api.wrappers.scene.Tile;
import org.rev317.api.wrappers.walking.TilePath;
@ScriptManifest(author = "RJJ95", category = Category.MINING, description = "Run this at ::skills", name = "Any Rock Miner", servers = { "CrisisX" }, version = 0.1)
public final class crisisMiner extends Script {
public static Area mine = new Area (new Tile(3008, 3370, 0) , new Tile(3018, 3367, 0));
public static Area bank = new Area (new Tile(3027, 3383, 0) , new Tile(3031, 3375, 0));
private final Tile[] to_Bank = { new Tile(3094,3496,0), new Tile(3013,3369,0) };
private final Tile[] to_Mine = { new Tile(3017,3372,0), new Tile(3023,3376,0), new Tile(3028, 3379, 0) };
static int BANK = 2213;
@Override
public boolean onExecute() {
LogArea.log("");
LogArea.log("Script Started");
while (true) {
loop();
return true;
}
}
@Override
public void onFinish() {
LogArea.log("Script ended");
}
public int loop() {
LogArea.log("Looping");
if(Inventory.isFull()) {
if (atMine()) {
walkBank();
} else if (atBank()) {
openBank();
handleBank();
} else {
LogArea.log("Not at mine or bank");
walkMine();
}
} else if(!Inventory.isFull()) {
if (atMine()) {
mineRock();
} else if (atBank()) {
walkMine();
} else {
}
}
return 5;
}
public void mineRock() {
LogArea.log("Mining rock");
int lvl = Skill.MINING.getLevel();
int rockID = 2091;
if (lvl < 15) {
rockID = 2091;
}
if ((lvl >= 15) && (lvl < 30)) {
rockID = 2093;
}
if ((lvl >=30) && (lvl < 50)) {
rockID = 2097;
}
if ((lvl >=50) && (lvl < 55)) {
rockID = 14850;
}
if ((lvl >=55) && (lvl < 70)) {
rockID = 2103;
}
if (lvl >= 70) {
rockID = 2105;
} else {
rockID = 2091;
}
final SceneObject Rocks[] = SceneObjects.getNearest(rockID);
final SceneObject Rock = Rocks[0];
if (Rock != null) {
if(!Rock.isOnScreen()){
Camera.turnTo(Rock);
Time.sleep(100);
}
Rock.interact("Mine");
Time.sleep(3000);
while (Players.getLocal().getAnimation() == 626) {
Time.sleep(200);
}
}
}
public void walkBank() {
TilePath path = new TilePath(to_Bank);
if(!path.hasReached() && Walking.readyForNextTile()) {
path.traverse();
}
}
public void walkMine() {
TilePath path = new TilePath(to_Mine);
if(!path.hasReached() && Walking.readyForNextTile()) {
path.traverse();
}
}
public void openBank() {
final SceneObject Banks[] = SceneObjects.getNearest(2213);
final SceneObject Bank = Banks[0];
if (Bank != null) {
if(!Bank.isOnScreen()){
Camera.turnTo(Bank);
Time.sleep(100);
}
Bank.interact("Use");
Time.sleep(3000);
while (Players.getLocal().isWalking()) {
Time.sleep(200);
}
}
}
public void handleBank() {
if (atBank()) {
Bank.depositAllExcept(1267,1275);
} else if (!atBank()) {
walkBank();
}
}
public boolean atMine() {
if (mine.contains(Players.getLocal().getLocation())) {
return true;
} else {
return false;
}
}
public boolean atBank() {
if (bank.contains(Players.getLocal().getLocation())) {
return true;
} else {
return false;
}
}
}
The debug says:
Script started
looping
script ended.
I don't get how it's not looping though
package miner;
import org.parabot.core.ui.components.LogArea;
import org.parabot.environment.api.utils.Time;
import org.parabot.environment.scripts.Category;
import org.parabot.environment.scripts.Script;
import org.parabot.environment.scripts.ScriptManifest;
import org.rev317.api.methods.Bank;
import org.rev317.api.methods.Camera;
import org.rev317.api.methods.Inventory;
import org.rev317.api.methods.Players;
import org.rev317.api.methods.SceneObjects;
import org.rev317.api.methods.Skill;
import org.rev317.api.methods.Walking;
import org.rev317.api.wrappers.scene.Area;
import org.rev317.api.wrappers.scene.SceneObject;
import org.rev317.api.wrappers.scene.Tile;
import org.rev317.api.wrappers.walking.TilePath;
@ScriptManifest(author = "RJJ95", category = Category.MINING, description = "Run this at ::skills", name = "Any Rock Miner", servers = { "CrisisX" }, version = 0.1)
public final class crisisMiner extends Script {
public static Area mine = new Area (new Tile(3008, 3370, 0) , new Tile(3018, 3367, 0));
public static Area bank = new Area (new Tile(3027, 3383, 0) , new Tile(3031, 3375, 0));
private final Tile[] to_Bank = { new Tile(3094,3496,0), new Tile(3013,3369,0) };
private final Tile[] to_Mine = { new Tile(3017,3372,0), new Tile(3023,3376,0), new Tile(3028, 3379, 0) };
static int BANK = 2213;
@Override
public boolean onExecute() {
LogArea.log("");
LogArea.log("Script Started");
while (true) {
loop();
return true;
}
}
@Override
public void onFinish() {
LogArea.log("Script ended");
}
public int loop() {
LogArea.log("Looping");
if(Inventory.isFull()) {
if (atMine()) {
walkBank();
} else if (atBank()) {
openBank();
handleBank();
} else {
LogArea.log("Not at mine or bank");
walkMine();
}
} else if(!Inventory.isFull()) {
if (atMine()) {
mineRock();
} else if (atBank()) {
walkMine();
} else {
}
}
return 5;
}
public void mineRock() {
LogArea.log("Mining rock");
int lvl = Skill.MINING.getLevel();
int rockID = 2091;
if (lvl < 15) {
rockID = 2091;
}
if ((lvl >= 15) && (lvl < 30)) {
rockID = 2093;
}
if ((lvl >=30) && (lvl < 50)) {
rockID = 2097;
}
if ((lvl >=50) && (lvl < 55)) {
rockID = 14850;
}
if ((lvl >=55) && (lvl < 70)) {
rockID = 2103;
}
if (lvl >= 70) {
rockID = 2105;
} else {
rockID = 2091;
}
final SceneObject Rocks[] = SceneObjects.getNearest(rockID);
final SceneObject Rock = Rocks[0];
if (Rock != null) {
if(!Rock.isOnScreen()){
Camera.turnTo(Rock);
Time.sleep(100);
}
Rock.interact("Mine");
Time.sleep(3000);
while (Players.getLocal().getAnimation() == 626) {
Time.sleep(200);
}
}
}
public void walkBank() {
TilePath path = new TilePath(to_Bank);
if(!path.hasReached() && Walking.readyForNextTile()) {
path.traverse();
}
}
public void walkMine() {
TilePath path = new TilePath(to_Mine);
if(!path.hasReached() && Walking.readyForNextTile()) {
path.traverse();
}
}
public void openBank() {
final SceneObject Banks[] = SceneObjects.getNearest(2213);
final SceneObject Bank = Banks[0];
if (Bank != null) {
if(!Bank.isOnScreen()){
Camera.turnTo(Bank);
Time.sleep(100);
}
Bank.interact("Use");
Time.sleep(3000);
while (Players.getLocal().isWalking()) {
Time.sleep(200);
}
}
}
public void handleBank() {
if (atBank()) {
Bank.depositAllExcept(1267,1275);
} else if (!atBank()) {
walkBank();
}
}
public boolean atMine() {
if (mine.contains(Players.getLocal().getLocation())) {
return true;
} else {
return false;
}
}
public boolean atBank() {
if (bank.contains(Players.getLocal().getLocation())) {
return true;
} else {
return false;
}
}
}
The debug says:
Script started
looping
script ended.
I don't get how it's not looping though