Code:
Problem description:
Basically i'm trying to find out how to disallow spaces in names for example Goku ssj99 I don't want that possible it must be all in 1.. i tried toying around with copytext but i can't seem to get it to work properly..
or you can use this http://www.byond.com/developer/Nadrew/StringHandler
then use the Trim() on the name so it will delete every blank space. |
In response to Karffebon
|
|
Karffebon wrote:
or you can use this http://www.byond.com/developer/Nadrew/StringHandler Trim only removes whitespace on the sides of the string, for example: world << Trim(" John Doe ") // Displays "John Doe" The Strip() process from that library would work, but using a library where a built-in (and native) function works just as well is silly (at least in terms of detection) |
You can also use the ckey() process if you don't want to allow any punctuation:
if(ckey(name) != lowertext(name))
As for how to implement it, I would suggest an infinite while() loop that you break out of when a valid name is given:
This basically keeps asking the player for a name until they give a valid one.
<edit>
Added a call to lowertext() to make the ckey() usage work (ckey() returns text in lower-case form)