Jump to content

Code being skipped ?


Recommended Posts

Posted (edited)

Hey guys; I thought I should re-edit and make it a bit neater;

 

Here is my problem, this bit of code keeps getting skipped.

if (bank.isOpen()) {
			if(inventory.isEmpty()) {
				if (getBank().getWithdrawMode().equals(
						Bank.BankMode.WITHDRAW_NOTE)) {
					getBank().withdrawAll("Raw beef");
					log("Withdrawing Noted Beef");
					sleep(random(750, 1500));
				} else {
					bank.enableMode(Bank.BankMode.WITHDRAW_NOTE);
					log("changing to withdraw note mode");
					sleep(random(750, 1500));
				}
			} else {
					bank.depositAll();
			}
			sleep(random(1000, 2500));

The withdraw as a note method just constantly gets skipped;

 

I have a feeling its to do with my states, which are here;

private State getState() {
		if (!inventory.isFull() && cowArea.contains(myPlayer()))
			return State.PICKUP;
		if (inventory.contains("Raw Beef") && muleArea.contains(myPlayer()))
			return State.TRADE;
		if (!inventory.isFull() && !cowArea.contains(myPlayer()))
			return State.WALKTOPICKUP;
		if (inventory.isFull() && !muleArea.contains(myPlayer()))
			return State.WALKTOMULE;
		return State.WAIT;
	}

and

switch (getState()) {
		case PICKUP:
			doPickUp();
			break;
		case WALKTOMULE:
			getWalking().webWalk(muleArea);
			break;
		case TRADE:
			getNotedItems();
			tradeMule();
			offerItems();
			acceptTrade();
			break;
		case WALKTOPICKUP:
			getWalking().webWalk(cowArea);
			break;
		case STOP:
			this.stop();
			break;
		case WAIT:
			sleep(random(200, 300));
			break;
		}
		return random(200, 300);

	}

See I want to withdraw them as a note obviously so I can trade to my mule; however I think my return state for trade fails as I only want it to be recognized as a noted item; but it obviously just skips back to thinking it needs to walk back to cowarea which is not needed to be done till after its finished the trade method;

 

Any help would be appreciated as im stuck as lol

 

Edited by whipz
Posted (edited)
if open()
   if withdrawmode is note
      //withdraw
   else setToNote()
else open()

 

Thanks I have done that with this yet I still seem to have the problem it seems to skip it

if (bank.isOpen()) {
			if(inventory.isEmpty()) {
				if (getBank().getWithdrawMode().equals(
						Bank.BankMode.WITHDRAW_NOTE)) {
					getBank().withdrawAll("Raw beef");
					log("Withdrawing Noted Beef");
					sleep(random(750, 1500));
				} else {
					bank.enableMode(Bank.BankMode.WITHDRAW_NOTE);
					log("changing to withdraw note mode");
					sleep(random(750, 1500));
				}
			} else {
					bank.depositAll();
			}
			sleep(random(1000, 2500));
		} else {
				int rand = random(3);
				if (rand == 1) {
					closestBankBooth.interact("Bank");
					log("Using Bank Booth");
					sleep(random(750, 1500));
					
				} else {
					closestBanker.interact("Bank");
					log("Using NPC Banker");
					sleep(random(750, 1500));
				}
				sleep(random(1000, 2500));
				log("Opening Bank");
			}
		}
	}

what chris said.

 

also, you need to fix your bracketing and your comments. it is making your code more difficult to read than it needs to be

 

Its fine in my ide I just wasnt using the code thing at the top i was just using code in []

 

EDIT:

 

I just realised it could be with my states;

private State getState() {
		if (!inventory.isFull() && cowArea.contains(myPlayer()))
			return State.PICKUP;
		if (inventory.contains("Raw Beef") && muleArea.contains(myPlayer()))
			return State.TRADE;
		if (!inventory.isFull() && !cowArea.contains(myPlayer()))
			return State.WALKTOPICKUP;
		if (inventory.isFull() && !muleArea.contains(myPlayer()))
			return State.WALKTOMULE;
		return State.WAIT;
	}
public int onLoop() throws InterruptedException {
		switch (getState()) {
		case PICKUP:
			doPickUp();
			break;
		case WALKTOMULE:
			getWalking().webWalk(muleArea);
			break;
		case TRADE:
			getNotedItems();
			tradeMule();
			offerItems();
			acceptTrade();
			break;
		case WALKTOPICKUP:
			getWalking().webWalk(cowArea);
			break;
		case STOP:
			this.stop();
			break;
		case WAIT:
			sleep(random(200, 300));
			break;
		}
		return random(200, 300);

	}
Edited by whipz
Posted

if (!inventory.isFull() && !cowArea.contains(myPlayer()))
			return State.WALKTOPICKUP;

Well of course it will run back... inventory isnt full so its switching states

 

 

Yeah I just noticed it before that was the reason for edit; But i cant think of a way to get around it now while still needing to be in the same area to trade the mule;

 

If i was to add to that line that your on now that you quoted and added !bank.isOpen(); would that fix my problem ?

Posted (edited)

WalkToPickUp state. You know what i mean

 

just check bank for beef.

 

if contains beef

withdraw

 

then trade to mule

 

I thought that was what you ment; wasnt sure if you wanted me to make another state to check bank haha sorry all new to this stuff; been a long time last time i did it we used nodes;

 

im testing it now (: 

WalkToPickUp state. You know what i mean

 

just check bank for beef.

 

if contains beef

withdraw

 

then trade to mule

 

if (!inventory.isFull() && !bank.isOpen() && !bank.contains("Raw beef")  && !cowArea.contains(myPlayer()))
return State.WALKTOPICKUP;
 
So I have done this now; and now it just sits at the bank with it open;
 
can close opened new thread open sourced
Edited by whipz

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