Shift & Backspace When Typing in Name

NickamonPoppytail

  • *
  • Posts: 1068
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!
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH; also canon to the Poppytail series. Easter Fun 2: A sequel to the original Easter Fun. One Million: Last-one-standing style small project; also canon to the Poppytail series.. The Poppytales: Hand-drawn spin-off bullet-hell RPG using characters from all my other book and game projects. Not canon to the Poppytail series.

merrak

  • *
  • Posts: 2320
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: 1068
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?
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH; also canon to the Poppytail series. Easter Fun 2: A sequel to the original Easter Fun. One Million: Last-one-standing style small project; also canon to the Poppytail series.. The Poppytales: Hand-drawn spin-off bullet-hell RPG using characters from all my other book and game projects. Not canon to the Poppytail series.

NickamonPoppytail

  • *
  • Posts: 1068
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?
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH; also canon to the Poppytail series. Easter Fun 2: A sequel to the original Easter Fun. One Million: Last-one-standing style small project; also canon to the Poppytail series.. The Poppytales: Hand-drawn spin-off bullet-hell RPG using characters from all my other book and game projects. Not canon to the Poppytail series.

NickamonPoppytail

  • *
  • Posts: 1068
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.
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH; also canon to the Poppytail series. Easter Fun 2: A sequel to the original Easter Fun. One Million: Last-one-standing style small project; also canon to the Poppytail series.. The Poppytales: Hand-drawn spin-off bullet-hell RPG using characters from all my other book and game projects. Not canon to the Poppytail series.

merrak

  • *
  • Posts: 2320
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: 1068
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.
Upcoming Projects
Poppytail 5 and Pixeltail: Fifth and sixth main instalments in Poppytail series. A Game About Trimming Hedges: Final Version: An updated version of the original AGATH; also canon to the Poppytail series. Easter Fun 2: A sequel to the original Easter Fun. One Million: Last-one-standing style small project; also canon to the Poppytail series.. The Poppytales: Hand-drawn spin-off bullet-hell RPG using characters from all my other book and game projects. Not canon to the Poppytail series.