ID:528680
 
(See the best response by DarkCampainger.)
Code:
runtime error: bad text or out of bounds
proc name: Submit (/mob/verb/Submit)
usr: LaNuiit (/mob/Player)
src: LaNuiit (/mob/Player)
call stack:
LaNuiit (/mob/Player): Submit()


Problem description:
I recoded and all but still sometimes when i hit that Submit verb i get this runtime error. But it aint always

In Dream Maker, go to Build -> Preferences for [project]... and turn on "Generate debugging information". That way, when you get an error, it will give the specific line number that it's from.

After you get the line number, please post the code for the Submit() verb and mark the line in question.

The more information you give us, the better we can help you--we aren't mind readers ;)
runtime error: bad text or out of bounds
proc name: Submit (/mob/verb/Submit)
source file: CharacterCreation.dm,114
usr: Ssdfsfds (/mob/Player)
src: Ssdfsfds (/mob/Player)
call stack:
Ssdfsfds (/mob/Player): Submit()


/*
//////////////////////////
Submit Creation
//////////////////////////
*/

mob
verb
Submit(/**/)
set hidden=1
var/capped_characters = 0
var/new_name=winget(usr,"nameinput","text")
var/name_length = length(name)
src.name = new_name
if(!new_name)
winset(src,"ChairCreation.nameerror","text=\"X You must enter a name!\"")
return
else
winset(src,"ChairCreation.nameerror","text=\"Youre name is '[src.name]'!\"")
for(var/mob/M in world)
if(M.name == M.key)
if(findtextEx(name,M.name))
winset(src,"ChairCreation.nameerror","text=\"X You can't use the same name as your key!\"")
return
for(var/f in filtered_names)
if(findtextEx(name,f))
winset(src,"ChairCreation.nameerror","text=\"X Your name can not contain '[f]'!\"")
return
for(var/i in illegal_names)
if(findtextEx(name,i))
winset(src,"ChairCreation.nameerror","text=\"X Your name can not contain '[i]'!\"")
return
for(var/C in capital_letters)
if(findtextEx(name,C))
capped_characters++
if(capped_characters>=4)
winset(src,"ChairCreation.nameerror","text=\"X Your name cannot contain that many capitals!\"")
return
if(!(capital_letters.Find("[copytext("[name]",1,2)]")))
winset(src,"ChairCreation.nameerror","text=\"X Your name must start with a capital letter!\"")
return
if(length(name) >= 11 || length(name)<=3)
winset(src,"ChairCreation.nameerror","text=\"X Your name must contain 4 to 10 characters!\"")
return
if(copytext(name,1,2,) == " ")
winset(src,"ChairCreation.nameerror","text=\"X Your name cannot begin with a space!\"")
return
if(copytext(name,name_length,name_length+1) == " ")
winset(src,"ChairCreation.nameerror","text=\"X Your name cannot end with a space!\"")
return
src.Load(/**/)
It doesn't look like you marked the line (you can press Ctrl+G in Dream Maker to go to a specific line).

I don't see what could be causing your error, but I do notice a few things:

var/name_length = length(name)
You probably want to be getting the length of their new_name

src.name = new_name
You probably don't want to do this until after all of the checks

            for(var/mob/M in world)
if(M.name == M.key)
if(findtextEx(name,M.name))
winset(src,"ChairCreation.nameerror","text=\"X You can't use the same name as your key!\"")
return
I'm not entirely sure what you're trying to do with this code, but if you want to get the player's key, you can just use src.key.

Also, you're using findtextEx() in some places where you may want just findtext() (the case-insensitive version)
I want to make that players can named himself in game. But when Submit button is clicked before name is inputed it gives error that the player have to enter a name before submit. And when you enter it runtime error shows
LaNuiit wrote:
runtime error: bad text or out of bounds
proc name: Submit (/mob/verb/Submit)
source file: CharacterCreation.dm,114
usr: Ssdfsfds (/mob/Player)
src: Ssdfsfds (/mob/Player)
call stack:
Ssdfsfds (/mob/Player): Submit()

DarkCampainger wrote:
It doesn't look like you marked the line (you can press Ctrl+G in Dream Maker to go to a specific line).

I need to know which line is number 114 to help you further.
            if(copytext(name,name_length,name_length+1) == " ")
winset(src,"ChairCreation.nameerror","text=\"X Your name cannot end with a space!\"")
return
Best response
Oh, that makes sense. It's because of the first thing I noted:
var/name_length = length(name)

You're getting the length of their old name, not their new one, so if the old name was longer, it will try to read outside of the new name's bounds.
Oh ty man that helps me a lot :)