ID:144971
 
Code:
        var/hairtype = input("What kind of hair do you want?") in list("1","2","3","4","5","6")
var/r = input("How much red do you want in your hair?") as num
var/g = input("How much green do you want in your hair?") as num
var/b = input("How much blue do you want in your hair?") as num
switch(hairtype)
if("1")
var/obj/hair/h1/R = new()
R.icon += rgb(r,g,b)
new_mob.overlays += R
if("2")
var/obj/hair/h2/R = new()
R.icon += rgb(r,g,b)
new_mob.overlays += R
if("3")
var/obj/hair/h3/R = new()
R.icon+= rgb(r,g,b)
new_mob.overlays += R
//And so on...


Problem description:

runtime error: Cannot read null.overlays
proc name: CreateCharacter (/mob/creating_character/proc/CreateCharacter)
source file: Login.dm,33
usr: Paynekiller (/mob/creating_character)
src: Paynekiller (/mob/creating_character)
call stack:
Paynekiller (/mob/creating_character): CreateCharacter()
Paynekiller (/mob/creating_character): Login()

Well isn't this lovely? My newbish side is showing.
The problem appears to be when I choose the hair, and it won't read the overlays to new_mob. I mean, that was supposed to work, right? Or did I overlook something? Someone gimme a hint, please.
Cannot read null.overlays basically means that new_mob was either deleted sometime before you choose hair or you never defined it properly and just let it sit there like

var/mob/new_mob


Maybe if you posted more of the code we could help you easier.

-Exophus
It would be easier to help you if we had the actual variable defining new_mob....

Does it look like this?

var/mob/new_mob
In response to Exophus
..Terribly sorry about all that...

it IS done by
var/mob/new_mob


Ya know what? Here's the whole code in it's false glory:
mob/creating_character

Login()
..()
world << "[usr] has just entered '[world.name]'!"
src.CreateCharacter()

proc/CreateCharacter()
var/mob/new_mob
var/char_name
var/skin
char_name = input("Please put your character name in here.","Name") as null|text
var/char = input(src,"Pick your character!") in list("Human","None")
gender = input("Select your Gender") in list("male","female")
skin = input("Select your Colour") in list("White","Black")
var/hairtype = input("What kind of hair do you want?") in list("1","2","3","4","5","6")
var/r = input("How much red do you want in your hair?") as num
var/g = input("How much green do you want in your hair?") as num
var/b = input("How much blue do you want in your hair?") as num
switch(hairtype)
if("1")
var/obj/hair/h1/R = new()
R.icon += rgb(r,g,b)
src.overlays += R
if("2")
var/obj/hair/h2/R = new()
R.icon += rgb(r,g,b)
src.overlays += R
if("3")
var/obj/hair/h3/R = new()
R.icon+= rgb(r,g,b)
src.overlays += R
if("4")
var/obj/hair/h4/R = new()
R.icon+= rgb(r,g,b)
src.overlays += R
if("5")
var/obj/hair/h5/R = new()
R.icon+= rgb(r,g,b)
src.overlays += R
if("6")
var/obj/hair/h6/R = new()
R.icon+= rgb(r,g,b)
src.overlays += R
switch(char)
if("Human")
if(gender == "male" && skin == "White")
new_mob = new /mob/player/human/guy_w
else if(gender == "female" && skin == "white")
new_mob = new /mob/player/human/girl_w
else if(gender == "male" && skin == "Black")
new_mob = new /mob/player/human/guy_b
else if(gender == "female" && skin == "Black")
new_mob = new /mob/player/human/girl_b
if("None")
src.Logout()
new_mob.name = char_name
new_mob.loc = locate(4,2,1)
src.client.mob = new_mob
..()
del(src)


Youch, kinda long when I look at it.

JUST SO YOU KNOW: Someone tried to help me with it, and there's no runtime error, but the hairs won't show up still.

This is my first serious icon game, so I could use all the help I can get.
In response to Paynekiller
Replace
var/mob/new_mob

with
var/mob/new_mob=new()

And just so YOU know, you can do all of that directly in Login(). You don't really need to make a new proc but it's your decision. :P

-Exophus
In response to Exophus
Exophus wrote:
Replace
var/mob/new_mob

with
var/mob/new_mob=new()


Wrong. You fail.
In response to Paynekiller
mob/creating_character

Login()
..()
world << "[usr] has just entered '[world.name]'!"
src.CreateCharacter()

proc/CreateCharacter()
var/mob/new_mob
var/char_name
var/skin
rename
char_name = input("Please put your character name in here.","Name") as null|text
if(!char_name||!findletters(char_name))
alert(src,"You inputted an invalid name!","Character Creation")
goto rename //no valid name inputted

var/char = input(src,"Pick your character!") in list("Human","None")
gender = input("Select your Gender") in list("male","female")
skin = input("Select your Colour") in list("White","Black")
switch(char)
if("Human")
if(gender == "male" && skin == "White")
new_mob = new /mob/player/human/guy_w
else if(gender == "female" && skin == "white")
new_mob = new /mob/player/human/girl_w
else if(gender == "male" && skin == "Black")
new_mob = new /mob/player/human/guy_b
else if(gender == "female" && skin == "Black")
new_mob = new /mob/player/human/girl_b
if("None")
src.Logout()
new_mob.name = char_name

var/hairtype = input("What kind of hair do you want?") in list("1","2","3","4","5","6")
var/r = input("How much red do you want in your hair?") as num
var/g = input("How much green do you want in your hair?") as num
var/b = input("How much blue do you want in your hair?") as num
switch(hairtype)
if("1")
var/obj/hair/h1/R = new()
R.icon += rgb(r,g,b)
src.overlays += R
if("2")
var/obj/hair/h2/R = new()
R.icon += rgb(r,g,b)
src.overlays += R
if("3")
var/obj/hair/h3/R = new()
R.icon+= rgb(r,g,b)
src.overlays += R
if("4")
var/obj/hair/h4/R = new()
R.icon+= rgb(r,g,b)
src.overlays += R
if("5")
var/obj/hair/h5/R = new()
R.icon+= rgb(r,g,b)
src.overlays += R
if("6")
var/obj/hair/h6/R = new()
R.icon+= rgb(r,g,b)
src.overlays += R
new_mob.loc = locate(4,2,1)
src.client.mob = new_mob
del(src)

//below is part of PhoenixsProcs, an old library that I wrote which contained some useful snippets of code. I overheard Lummox Jr mumbling something about "microlibraries" so I'm waiting for that before releasing stuff
/*
findletters(t)
Args:
t: the text to check
Returns:
1 if it finds letters (a>z) in t, 0 if it doesn't
Example:
if(findletters("xxx"))world<<"Found!"
else world<<"Not found!"

This outputs, "Found!", as the string contains letters.
*/

proc
findletters(t)
if(!istext(t))return
var/q=0
for(var/i=1,i<=length(t),i++)
var/x=text2ascii(t,i)
if(x>=65&&x<=122)q=1
return q


Keep in mind that it's still very stupid and pointless to have a screen popup saying "How much red do you want in your hair?", as most newbies will be "wtf'd" and not knowing what to do just input a random number.

Use hub://Flick.F_ColorSelection to allow your players to select colors.
In response to Android Data
    proc/CreateCharacter()
var/mob/new_mob
var/char_name
var/skin
rename
char_name = input("Please put your character name in here.","Name") as null|text
if(!char_name||!findletters(char_name))
alert(src,"You inputted an invalid name!","Character Creation")
goto rename //no valid name inputted


Wrong. You fail. This is grade two stuff, no use goto when it's not needed.

    proc/CreateCharacter()
var/mob/new_mob
var/char_name
var/skin
do
char_name = input("Please put your character name in here.","Name") as null|text
if(!char_name||!findletters(char_name))
alert(src,"You inputted an invalid name!","Character Creation")
char_name=""
while(!char_name)

---------
var/char = input(src,"Pick your character!") in list("Human","None")
gender = input("Select your Gender") in list("male","female")
skin = input("Select your Colour") in list("White","Black")
switch(char)
if("Human")
if(gender == "male" && skin == "White")
new_mob = new /mob/player/human/guy_w
else if(gender == "female" && skin == "white")
new_mob = new /mob/player/human/girl_w
else if(gender == "male" && skin == "Black")
new_mob = new /mob/player/human/guy_b
else if(gender == "female" && skin == "Black")
new_mob = new /mob/player/human/girl_b
if("None")
src.Logout()


A bunch of checks aren't needed.

        var/char = input(src,"Pick your character!") in list("Human","None")
if(char=="None")Logout()
gender = input("Select your Gender") in list("male","female")
skin = input("Select your Colour") in list("White","Black")
var char_type=text2path("/mob/player/human/[gender=="male"?"guy":"girl"]_[skin=="white"?"w":"b"])
new_mob=new char_type