Using get_key() to input a string
- Posted by Kevin Sieger <simkin at ZEBRA.NET> Mar 27, 1998
- 843 views
Yes, there is an easier way to input a string, but the use of the get_key allows me to implement real time in a multi-user rpg I'm developing. The problem I have is this: discluding the use of ports.e for getting remote strings, in order to get a local string (so someone can play locally) the game loop constantly checks the kb buffer for characters, loads them into a sequence and grabs the entire string on a carriage return. I then send the string to a parser to break the string down into verbs, nouns etc. Anyway, with get_key, you have to manually echo the character back to the screen, but there is not good way to implement the backspace key (8). Yes, it works fine for actually deleting the character sent (through some commands) but what about erasing the character on screen? If I put if char=8 and index>0 then -- index keeps track of sequence positioning buffer=buffer[1..length(buffer)-1] printf(1,"%s",{char}) end if The above is how I somewhat handle echoing of the other characters elsif char>=32 and char<=122 buffer=buffer&char printf(1,"%s",{char}) end if All of the input characters work fine, but trying to use backspace displays the ascii representation of 8, which is a rectangle with a diamond (or circle?) cut out of the middle. In C (ack!) I could use %c and 8 and it would work fine (I'm assuming, used C code as example). Any clues? Thanks! Kevin