Jump to content

Can anyone help me pls ?


Recommended Posts

Posted (edited)

- I using this code to activate actions in onLoop, my question is what i need put in the last return state (red color)... I understood that using for example: 

if (inventory.contains("Coins")

return State.Buy;

The case Buy will be called and the player will buy something, but the last return state (red color) have no if statement to activate it and im confused at what to put here.

private getStateif return 
        return ;
    return State.??

My other question is: When this private State getState() {} call one case how can i stop the verification until the case completes the actions inside it, because for example:

in private State getState have the statement:

if (!inventory.contains("Coins")

return State.Go_Bank_Withdraw_Coins;

And in onLoop have the code:

switch (getState()) {

case Go_Bank_Withdraw_Coins:

if (!BankArea.contains(myPlayer)){

walking.Webwalk(BankArea)}

break;

}

The verification in private State getState will not stop until the case complete, contrariwise will keep calling the case.

Edited by RuneMaker4657
Posted

If you're unsure about what's going on, i'd suggest switching over to a slightly simpler structure: the 'if' statement!

Work straight in the onLoop. For example:

if (getBank().isOpen() {
	if (!getInventory().isEmpty() {
		getBank().depositAll();
	}
} else { 
	getBank().open();
}

At some point, I will update my guide as I think it's a little too abstracted for a beginner to programming altogether.

Apa

Posted (edited)
21 minutes ago, Apaec said:

If you're unsure about what's going on, i'd suggest switching over to a slightly simpler structure: the 'if' statement!

Work straight in the onLoop. For example:


if (getBank().isOpen() {
	if (!getInventory().isEmpty() {
		getBank().depositAll();
	}
} else { 
	getBank().open();
}

At some point, I will update my guide as I think it's a little too abstracted for a beginner to programming altogether.

Apa

Yeah its work when the script is simple but this states with coins was just an random example... the script that i using switch states have 490 lines, i cant put all if statements in onLoop.

ill try rewrite this removing the states, and call

private void() throws InterruptedException {}

in onLoop.. but i think will keep not stop the verifications until the methods done.

Edited by RuneMaker4657

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