ID:146405
 
Code:
I'm not sure how to fix this, so I was hoping some one could give me some advice on how.
Form/NewCharacter
/*
The form_window variable provides the browse() options that the form will use.
We want the form to show up in its own window (not the built-in browser view).
*/

form_window = "window=NewCharacter;titlebar=0;can_close=0;can_minimize=0;size=600x400"

var
name

/*
To create radio buttons for a variable, specify the radio button options
by creating variables named variablename_1, variablename_2, etc.
*/

gender
gender_1 = "Human"
gender_2 = "Saiyan"

/*
To create a popup menu they can choose from, put the options in a list
called variablename_values.
*/


Initialize()
/*
This sets the initial values for the form each time before it is displayed.
The browse_rsc() calls sends an image to the player that is used
in the web page.
*/

if (!name) name = usr.key
if (!gender) gender = "Human"
usr << browse_rsc('New.bmp', "New.bmp")

HtmlLayout()
/*
You control the appearance of the form here.

We have added an error_text variable to the creating character mob, so we
can display an error if the form wasn't filled out correctly and needs to
be redisplayed with a message. The error_text variable can't be part of
the form object, because then the form tries to let the player edit it.

When you embed a variable such as [name], the html library automatically
puts in the HTML for the text field or radio button or whatever is needed.
In the case of radio buttons, you place the numbered variables where each
should be displayed.

The [submit] variable puts in the necessary submit button at that spot.
You can also place a [reset] button if you want.

There is an image here, which was sent to the player in Initialize()
to put it on their system so it would show up on the page.

This example puts everything in table to make layout control easier.
Some of the table rows are blank to provide extra space between options.
You can change the HTML in any way you like for your game.
*/

var/mob/creating_character/player = usr

var/page = {"<body bgcolor=olive>
<center><img src="face.png"></center>
<font color=red><b>
[player.error_text]</b></font><br>
<table>
<tr><td><b>Name:</b></td><td>
[name]</td></tr>
<tr><td>&nbsp;</td><td>&nbsp</td></tr>
<tr><td><b>Gender:</b></td>
<td>
[gender_1] Human<br>
[gender_2] Saiyan
</td>
<tr><td>&nbsp;</td><td>&nbsp</td></tr>
<tr><td>&nbsp;</td><td>&nbsp</td></tr>
<tr><td>&nbsp;</td><td>
[submit]</td></tr>
</table>
"}

return page

ProcessForm()
/*
This is called when the player submits the form.
Make sure everything is valid; if not, send them back to the
form with an error message.

If everything is okay, create their character and log them
into it, then blank out the web page.

This checks the ckey() version of the name they chose, to make
sure it has actual letters and isn't just punctuation.
*/

var/mob/creating_character/player = usr

var/ckey_name = ckey(name)
if (!ckey_name || ckey_name == "")
player.error_text = "Your name must have alpha-numeric characters in it!"
DisplayForm()
return

// Everything is okay, so create the new mob based on the class they chose.
var/mob/new_mob

// Set the new mob's attributes.
new_mob.name = name //<--This is were the run-time error is pointing to!
switch(gender)
if ("Human") new_mob = new /mob/male()
if ("Saiyan") new_mob = new /mob/male()

// Log their client into the new mob.
usr.client.mob = new_mob

// And finally, blank out their web page since they don't need it now.
new_mob << browse(null, "window=NewCharacter")
return


Problem description:
When I click submit I get this:

runtime error: Cannot modify null.name.
proc name: ProcessForm (/Form/NewCharacter/ProcessForm)
source file: new_char_handling.dm,368
usr: Crzylme (/mob/creating_character)
src: Jon (/Form/NewCharacter)
call stack:
Jon (/Form/NewCharacter): ProcessForm()
Jon (/Form/NewCharacter): StopWaiting()
Jon (/Form/NewCharacter): Topic("src=%5B0x21000001%5D&name=Jon&...", /list (/list))
Crzylme (/client): Topic("src=%5B0x21000001%5D&name=Jon&...", /list (/list), Jon (/Form/NewCharacter))

Then when I try to click it again I get this:

Illegal form call by (Crzylme,/Form/NewCharacter).


Wow, I wrote better comments than I recall!

Anyway, your problem is the first line here:

        var/mob/new_mob

// Set the new mob's attributes.
new_mob.name = name //<--This is were the run-time error is pointing to!


You are declaring a variable but not setting it to anything, so it's just an empty variable. Then you get an error when you try to use it.

Instead, you need to assign a new mob object to the variable like so:

        var/mob/new_mob = new()

// Set the new mob's attributes.
new_mob.name = name //<--This is were the run-time error is pointing to!

In response to Deadron
Thank you very much

It works well now.