Shift & Backspace When Typing in Name

NickamonPoppytail

  • *
  • Posts: 933
Hello,

I’m creating a scene where the player can name their character, but how do I get the backspace and shift keys to work?

I have currently got an “Any Key” event and have got “key code = key code of <whatever> key” in, but how do I get these keys to carry out their regular function?

Thank you!
Currently developing Poppytail 5, Pixeltail and The Poppytales.

Email: nick.rosemarygames.poppytail@gmail.com

;)

merrak

  • *
  • Posts: 2012
You have to strip out the last character from the input string when the backspace key is struck. I attached an example I wrote, but mine is a bit more complex than is necessary (because I also have a cursor the user can move with the mouse and left/right arrows). It should illustrate the basic idea using the text manipulation blocks, though.

NickamonPoppytail

  • *
  • Posts: 933
You have to strip out the last character from the input string when the backspace key is struck. I attached an example I wrote, but mine is a bit more complex than is necessary (because I also have a cursor the user can move with the mouse and left/right arrows). It should illustrate the basic idea using the text manipulation blocks, though.

I have a game attribute "Name" and a number attribute "Character Count".

My code is "set Name to part of Name (start: ? end: Character Count - 1)". What should I put in the place of the question mark?
Currently developing Poppytail 5, Pixeltail and The Poppytales.

Email: nick.rosemarygames.poppytail@gmail.com

;)

NickamonPoppytail

  • *
  • Posts: 933
Just looked up the "part of text" block in the Blocks Guide and I think I have the backspace key working now, but what about the shift key?
Currently developing Poppytail 5, Pixeltail and The Poppytales.

Email: nick.rosemarygames.poppytail@gmail.com

;)

NickamonPoppytail

  • *
  • Posts: 933
Just looked up the "part of text" block in the Blocks Guide and I think I have the backspace key working now, but what about the shift key?

Never mind. Shift key works automatically.
Currently developing Poppytail 5, Pixeltail and The Poppytales.

Email: nick.rosemarygames.poppytail@gmail.com

;)

merrak

  • *
  • Posts: 2012
You have to strip out the last character from the input string when the backspace key is struck. I attached an example I wrote, but mine is a bit more complex than is necessary (because I also have a cursor the user can move with the mouse and left/right arrows). It should illustrate the basic idea using the text manipulation blocks, though.

I have a game attribute "Name" and a number attribute "Character Count".

My code is "set Name to part of Name (start: ? end: Character Count - 1)". What should I put in the place of the question mark?

If you want to remove the last character in the string, put 0 in for the start and "length of text" - 1 for the end. The 'character count' attribute is needed for the cursor... but if you don't have a cursor then don't worry about keeping a character count.

NickamonPoppytail

  • *
  • Posts: 933
You have to strip out the last character from the input string when the backspace key is struck. I attached an example I wrote, but mine is a bit more complex than is necessary (because I also have a cursor the user can move with the mouse and left/right arrows). It should illustrate the basic idea using the text manipulation blocks, though.

I have a game attribute "Name" and a number attribute "Character Count".

My code is "set Name to part of Name (start: ? end: Character Count - 1)". What should I put in the place of the question mark?

If you want to remove the last character in the string, put 0 in for the start and "length of text" - 1 for the end. The 'character count' attribute is needed for the cursor... but if you don't have a cursor then don't worry about keeping a character count.

Thank you. I just figured that out.
Currently developing Poppytail 5, Pixeltail and The Poppytales.

Email: nick.rosemarygames.poppytail@gmail.com

;)