Can we use the scanner utility to look for an input Y from a player or do we have to use an onPlayerKey event?
java.util.Scanner
-
- English
- angriff
- Thread is marked as Resolved.
-
-
The PlayerKeyEvent and the java.util.Scanner are doing completely different things so they are not really comparable to use one in place of the other.
The PlayerKeyEvent is called when a player presses a button on their keyboard and does something using that key.
The java.util.Scanner requires a full text input, it reads that input and then does something with it i.e. like you do with the PlayerCommandEvent, getting the command as a whole and splitting it to identify what the player wants to do. The Scanner would do more or less what the String.split() method does in this case but in a more complex manner.
But generally speaking you can use every Java method you want since the game is not limiting your coding to API methods only
-
Thanks I had both in a script but was not reading the input and noticed that the script never responded. So I was wondering what was hanging it up. I thought I would asked before I spent time looking it it. I know I was looking for a return too but I think my mistake may have been case related. So I will fool with it somemore. Thanks again.
-
btw to use the PlayerKeyEvent you need:
1) use player.registerKeys(blablabla)
2) use player.setListenForKeyInput(true);
Participate now!
Don’t have an account yet? Create a new account now and be part of our community!