Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Restricting user input (DBC)

Author
Message
ManiacBR
17
Years of Service
User Offline
Joined: 26th Oct 2006
Location:
Posted: 15th Dec 2006 00:19
In my game I have a working high score table at the end, which asks the user to enter their name.

At the moment I just have,



How would i write this so I could restrct what the user entered to 3 initials?

Thanks in advance.
TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 15th Dec 2006 13:54
You would have to use a different input method - like:



There are other ways - but this is the simplest.

The problem with all of them is that unlike Input, you have to write code for every possible key press - Del, Backspace as well as control the cursor and repeat rate.

TDK_Man

Jerok
19
Years of Service
User Offline
Joined: 7th May 2005
Location: Mars. Wait a sec I\'m on MARS. OMG
Posted: 18th Dec 2006 04:34 Edited at: 18th Dec 2006 04:34
there is a simpler way but it doesn't give as nice of an effect

in this method the player will be able the enter any amount of letters in the input but afterwords it only takes the first three letters of the variable
Firewood
19
Years of Service
User Offline
Joined: 24th Jul 2005
Location:
Posted: 18th Dec 2006 22:52
I have just made a input from the user limited to 8 characters. If the player try to input more than 8 it wil be ignored. It's have the option to use backspace. So if the player type somthing wrong he or she can correct it. I use a bitmap font to put the input on the screen. But if you want to use just text you can. Replace The call to smalFont in Text x,y,Text$. Its check the valid input of characters. And the line "If Len(Name$) < 8" You can change the 8 in a 3 if you like. As you can see its a function. Its return the name op the player.

I have also made a input field where the player only can klick on the letters on the screen. ( The letters is ordered in a matrix) And even there the player can only input as mutch as you want to have.

I hope you can extract that what you want to have.



Never say a question is stupid. Questions not ask are stupid.
Firewood
19
Years of Service
User Offline
Joined: 24th Jul 2005
Location:
Posted: 18th Dec 2006 22:56
Forgot to mention it. There is also a delay in the checking of the keypressed. Reason for this is if the player keep the letter pressed down the loop wil see this and fill up the string. Even if the player did not want to do that. So i give the playse time to releas the key. 150 ms is more than enough for a delay.

Never say a question is stupid. Questions not ask are stupid.

Login to post a reply

Server time is: 2024-09-25 15:24:11
Your offset time is: 2024-09-25 15:24:11