ID:884313
 
(See the best response by DarkCampainger.)
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..
Best response
You want findtext():
if(findtext(name, " "))


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:
mob
Login()

// ...

// Determine a valid player name
while(TRUE)

// Prompt the player for their name
src.name = input(src, "What is your name?", "Welcome to [world.name]!", src.key) as text

if(ckey(name) != lowertext(name))
// Invalid characters
src<<"Your name cannot contain punctuation or spaces!"
else if(length(name) < 3 || length(name) > 20)
// Incorrect length
src<<"Your name must be between 3 and 20 characters long!"
else
// Valid name, break out
break

// ...


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)
Thanks a lot.
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

then use the Trim() on the name so it will delete every blank space.

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)