ID:1661136
 
(See the best response by GhostAnime.)
Code:
/*
These are simple defaults for your project.
*/


world
version=1
loop_checks=1
tick_lag=1
mob=/mob
name="Sword Art Online"
map_format=TOPDOWN_MAP
status="<font size=-2><font color=red>Loading...</font></font>"
hub="Yoshino21.Sword Art Online"
New()
..()
log="Log.txt"
client
script="<STYLE>BODY {background: black; color: #999999;font-size: -2;font-weight: bold;font-family:Tahoma}</STYLE>"
perspective=EDGE_PERSPECTIVE
Del()


// Make objects move 8 pixels per tick when walking

mob
step_size = 10

obj
step_size = 10

mob
verb
say(msg as text)
set category="Channel" //what the usr says is passed into "msg" as text
world << "[usr]: [msg]" //the world sees chatroom-like output
OOC(msg as text)
set category="Channel"
world << "[usr]: [msg]"
world/mob = /mob/creating_character


mob/creating_character
base_save_allowed = 0 // If player quits before choosing, don't want to save this mob.

Login()
// Spawn here to avoid problems with calling prompts during login.
spawn()
src.CreateCharacter()

proc/CreateCharacter()
// In this case, the code creates a /mob/human or /mob/ogre with the specified attributes.

// Get the character information from them. (You would probably want to do with this a browser page.)
var/prompt_title = "New Character"
var/help_text = "What do you want to name the character?"
var/default_value = key
var/char_name = input(src, help_text, prompt_title, default_value) as null|text
if (!char_name) // Guess they don't want to create a new character after all, so send them to choose a character.
client.base_ChooseCharacter()
return

// Make sure there isn't already a character named that.
// Character names are stored as ckey, so get the ckey version of the name.
var/ckey_name = ckey(char_name)
var/list/characters = client.base_CharacterNames()
if (characters.Find(ckey_name))
alert("You already have a character named that! Please choose another name.")
src.CreateCharacter()
return

var/list/classes = list("Male", "Female")
help_text = "Which class would you like to be?"
default_value = "Male"
var/gender = input(src, help_text, prompt_title, default_value) in classes

// Okay we have enough information, so it's time to create the character and switch the player to it.
var/mob/new_mob
switch(gender)
if ("Male") mob/new_mob = new /mob/Male()
if ("Female") mob/new_mob = new /mob/Female()

// Set the attributes.
new_mob.name = char_name

// Now switch the player client over to the new mob and delete myself since I'm no longer needed.
src.client.mob = new_mob
var/turf/first_location = locate(1, 1, 1)
new_mob.Move(first_location)
del(src)

mob
Login()
..()

// This is just here for this sample, to make it clear which mob you've logged into.
sample_report()


verb
add_save_verb()
// Adds save_me verb to the mob, to show that verb saving works.
src.verbs += /mob/proc/save_me

remove_save_verb()
src.verbs -= /mob/proc/save_me

proc
sample_report()
src << "<BR><BR>"
src << "\blue You are [name]."
src << "\blue Your class is [type]."

save_me()
// This demonstrates verb saving and how to manually save the mob whenever you want..
// This proc gets added and saved as a verb only if add_verb is called by the player.
src.client.base_SaveMob()
src << "\red You have been saved."
<dm>

<b>Sword Art Online.dm:79:error: mob/new_mob: undefined var
Sword Art Online.dm:80:error: mob/new_mob: undefined var
Sword Art Online.dm:116:error: src.client.base_SaveMob: undefined proc
Sword Art Online.dm:59:error: client.base_ChooseCharacter: undefined proc
Sword Art Online.dm:65:error: client.base_CharacterNames: undefined proc
Sword Art Online.dmb - 5 errors, 0 warnings<b>

To fix this you....


Oh wait, you didn't post the errors.
Best response
Yoshino21 wrote:
        switch(gender)
if ("Male") mob/new_mob = new /mob/Male()
if ("Female") mob/new_mob = new /mob/Female()


The error here is that you are referring to the variable by path/variable_name in the switch (as variables are defined as var/var_path_type/var_name).

Fix: change "mob/new_mob" to just "new_mob" in the switch.