1 decade ago by ShawnSwander
So I was gonna write this but I don't wana reinvent the wheel
I was going to have it so when the player hits spacebar (or whatever key I assign) the game recognizes it as the player wanting to say something to other players and opens a text entry mode where he can type something and it appears in a message box if he hits enter (a chat game state if you will) I'm thinking I'll have to
track cursor position
get the state of caps lock
get the state of the shift key
put in a delay so one key press doesn't type 4 letters and so a player can hold down the !!!!!! button
another neat thing I thought of is the speech bubble behind the text could be different if the sentence contains ! or ? or keywords
probably more I haven't thought of
here is a snippet so far
I'll have to change it to manipulate the string at the indicated position
Is this already somewhere I looked and didn't find it...
If not, would anyone be interested in the code if I do it?
I was going to have it so when the player hits spacebar (or whatever key I assign) the game recognizes it as the player wanting to say something to other players and opens a text entry mode where he can type something and it appears in a message box if he hits enter (a chat game state if you will) I'm thinking I'll have to
track cursor position
get the state of caps lock
get the state of the shift key
put in a delay so one key press doesn't type 4 letters and so a player can hold down the !!!!!! button
another neat thing I thought of is the speech bubble behind the text could be different if the sentence contains ! or ? or keywords
probably more I haven't thought of
here is a snippet so far
update: function() { switch (this.menustate){ case 0: //Chatlog command line this.unbindAll() //ig.KEY.CAPS //ig.KEY.TAB ig.input.bind( ig.KEY.MOUSE1, 'leftclick' ); ig.input.bind( ig.KEY.MOUSE2, 'rightclick' ); ig.input.bind( ig.KEY.A, 'a' ); ig.input.bind( ig.KEY.B, 'b' ); ig.input.bind( ig.KEY.C, 'c' ); ig.input.bind( ig.KEY.D, 'd' ); ig.input.bind( ig.KEY.E, 'e' ); ig.input.bind( ig.KEY.F, 'f' ); ig.input.bind( ig.KEY.G, 'g' ); ig.input.bind( ig.KEY.H, 'h' ); ig.input.bind( ig.KEY.I, 'i' ); ig.input.bind( ig.KEY.J, 'j' ); ig.input.bind( ig.KEY.K, 'k' ); ig.input.bind( ig.KEY.L, 'l' ); ig.input.bind( ig.KEY.M, 'm' ); ig.input.bind( ig.KEY.N, 'n' ); ig.input.bind( ig.KEY.O, 'o' ); ig.input.bind( ig.KEY.P, 'p' ); ig.input.bind( ig.KEY.Q, 'q' ); ig.input.bind( ig.KEY.R, 'r' ); ig.input.bind( ig.KEY.S, 's' ); ig.input.bind( ig.KEY.T, 't' ); ig.input.bind( ig.KEY.U, 'u' ); ig.input.bind( ig.KEY.V, 'v' ); ig.input.bind( ig.KEY.W, 'w' ); ig.input.bind( ig.KEY.X, 'x' ); ig.input.bind( ig.KEY.Y, 'y' ); ig.input.bind( ig.KEY.Z, 'z' ); ig.input.bind( ig.KEY.DELETE, 'delete' ); ig.input.bind( ig.KEY.BACKSPACE, 'backspace' ); ig.input.bind( ig.KEY.ESC, 'esc' ); ig.input.bind( ig.KEY.SPACE, 'space' ); ig.input.bind( ig.KEY.LEFT_ARROW, 'left' ); ig.input.bind( ig.KEY.RIGHT_ARROW, 'right' ); ig.input.bind( ig.KEY._0, '0' ); ig.input.bind( ig.KEY._1, '1' ); ig.input.bind( ig.KEY._2, '2' ); ig.input.bind( ig.KEY._3, '3' ); ig.input.bind( ig.KEY._4, '4' ); ig.input.bind( ig.KEY._5, '5' ); ig.input.bind( ig.KEY._6, '6' ); ig.input.bind( ig.KEY._7, '7' ); ig.input.bind( ig.KEY._8, '8' ); ig.input.bind( ig.KEY._9, '9' ); ig.input.bind( ig.KEY.END, 'end' ); ig.input.bind( ig.KEY.HOME, 'home' ); ig.input.bind( ig.KEY.INSERT, 'insert' ); ig.input.bind( ig.KEY.ENTER, 'enter'); var player = ig.game.getEntitiesByType( EntityPlayer ); if( ig.input.state('a')){ player.messagebox = player.messagebox + "a" cursorPosition = cursorPosition +1; break; ...
I'll have to change it to manipulate the string at the indicated position
Is this already somewhere I looked and didn't find it...
If not, would anyone be interested in the code if I do it?