ID:155281
 
mob
proc
newchar()
if (fexists("players/[src.key]"))
switch(alert(usr, "A character already exists. Would you like to overwrite it?","Yes","No"))
if("Yes")
switch (alert(usr, "This action is permanent. Are you sure?","Yes","No"))
if("Yes")
sleep(0)
fdel("players/[src.key]")
if("No")
return
if("No")
return
var/name = input("", "Please choose your name.") as text|null
if (!usr)
return
if (length(name) < 3)
alert("Name must be between three and seventeen letters.")
return
if (length(name) > 17)
alert("Name must be between three and seventeen letters.")
return
if (name == src.key)
alert("Invalid name (same as key). Please choose another.")
usr.name = "[name]"
usr.icon = 'base.dmi'
race = "Human"


What I want the code to do is return to the "Please choose your name" input after each of those falling alerts. However instead it just terminates the proc altogether and gives the player the usr.icon and race var.

Any help would be appreciated :)</3>
Here is your issue.

return


return ends the current proc and returns a value (if specified). I would suggest using while() for your naming proc.
This belongs in Code Problems, but here is an example of what you need to do:

//NOTE: I simplified your switch(alert()) statements to an if(alert()) statement.
//NOTE 2: NEVER use "usr" in procs. Use "src".

mob
proc
newchar()
if (fexists("players/[src.key]"))
if(alert(src, "A character already exists. Would you like to overwrite it?","Yes","No")=="Yes")
if(alert(src, "This action is permanent. Are you sure?","Yes","No")=="Yes")
sleep(0)
fdel("players/[src.key]")
else
return
else
return
name=key //This sets their name to their key so we can check it.
while(name == key) //As long as their name is their key(Which means they haven't succeeded), it will loop.
var/n = input("", "Please choose your name.") as text|null //I changed this to "n" to avoid confusion with the mob's name var.
if (!src)
return
if (length(n) < 3)
alert("Name must be between three and seventeen letters.")
return
if (length(n) > 17)
alert("Name must be between three and seventeen letters.")
return
name = n
usr.name = "[name]"
usr.icon = 'base.dmi'
race = "Human"


Make sure to read my comments. They also give you some advice, along with fixes and additions.
In response to Albro1
Sorry for misplacing the question.

However, using your code provided with numerous indentation errors and empty else clauses.

"fdel("players/[src.key]")
else
return
else
return"

Both give empty errors, and the whole thing has multiple indentation errors.

I do get what you're trying to do, and I think it is genius. However something is stopping it from working :/
In response to DpT
Any indentation errors are cause by bad indentation in your code. My indentation is correct. I edited your code in Dream Maker and compiled it, so I know that for sure. Your indentation(Maybe you have spaces somewhere instead of tabs?) is the problem here.
In response to Albro1
You're using <small>usr</small> in a proc.

usr.name = "[name]"
usr.icon = 'base.dmi'


Also, what if the player wants his name the same as his key?

You're not giving an alert telling him they cannot use their key name.
In response to Neimo
Yeah, I forgot to edit that part. My apologies. And adding an alert for that is very easy, but it will automatically loop back because their name is still their key.