Jump to content

Can anyone help me pls ?


John Wick

Recommended Posts

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

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

Link to comment
Share on other sites

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