John Wick Posted October 4, 2017 Posted October 4, 2017 (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 October 4, 2017 by RuneMaker4657
Apaec Posted October 4, 2017 Posted October 4, 2017 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
John Wick Posted October 4, 2017 Author Posted October 4, 2017 (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 October 4, 2017 by RuneMaker4657