ID:174276
 
If I could have anyone well experienced in the field of creating a character creation process please respond to this post. I get a runtime error as soon as I input my name, and it stops the process. I have some code, it's not quite working. I'm thinking of just making this an HTML popup like in Dragon Ballz 4k.
mob/other/choosing_character/Login()
..()
if(src.created == 0)
src.CreateNewCharacter()
src.loc = locate(1,1,1)
world << "[src] has joined the world"
world
proc
ReSpawn()
world << "Repop!"
Repop()
spawn(60000)
ReSpawn()
New()
..()
ReSpawn()
mob/Logout()
usr.login = 0
world << "[src.name] logs out..."
del(src)

client/proc/SaveMob()
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
var/char_ckey = cKey(src.mob.name)
F["/[ckey]/[char_ckey]"]<<src.mob

client/proc/LoadMob(char_ckey)
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
F["/[ckey]/[char_ckey]"]>>src.mob

client/Del()
if (istype(src.mob, /mob/other/choosing_character))
return ..()

src.SaveMob()
return ..()


mob/other/choosing_character/proc/CreateNewCharacter()

var/prompt_title = "Character Creation"
var/help_text = "What is your name? REMEMBER: Please use appropriate, RP names."
var/default_value = "[src.key]"
var/char_name = input(src, help_text, prompt_title, default_value) as text

var/list/avatars = list("Lan","Mayl","Dex","Yai","Chaud")
var/avatar = input(src,"Which avatar would you like?","Character Creation") in list(avatars)
var/mob/new_mob
switch(avatar)
if("Lan")
new_mob = new /mob/avatar/Lan()
if("Mayl")
new_mob = new /mob/avatar/Mayl()
if("Yai")
new_mob = new /mob/avatar/Yai()
if("Dex")
new_mob = new /mob/avatar/Dex
if("Chaud")
new_mob = new /mob/avatar/Chaud

new_mob.oicon = new_mob.icon
new_mob.exp = 0
new_mob.name = char_name

src.client.mob = new_mob
var/turf/first_location = locate(1,1,1)
new_mob.loc = first_location
src.created = 1
del(src)

mob
Login()
..()
if (!istype(src, /mob/other/choosing_character))
sample_report()

Write(savefile/F)
..()

F["last_x"] << x
F["last_y"] << y
F["last_z"] << z

Read(savefile/F)
..()

var/last_x
var/last_y
var/last_z
F["last_x"] >> last_x
F["last_y"] >> last_y
F["last_z"] >> last_z
loc = locate(last_x, last_y, last_z)

proc
sample_report()

Here's my runtime error
runtime error: Cannot read null.icon
proc name: CreateNewCharacter (/mob/other/choosing_character/proc/CreateNewCharacter)
usr: Delita12345 (/mob/other/choosing_character)
src: Delita12345 (/mob/other/choosing_character)
call stack:
Delita12345 (/mob/other/choosing_character): CreateNewCharacter()
Delita12345 (/mob/other/choosing_character): Login()

I would really appreciate any and all help. Thanks in advance! Also could you tell me how to process information from HTML popups? like you click on a character and your avatar is that character you clicked.
(PS) sorry about such a huge post
Delita12345 wrote:
var/list/avatars = list("Lan","Mayl","Dex","Yai","Chaud")
var/avatar = input(src,"Which avatar would you like?","Character Creation") in list(avatars)

"avatars" is already a list, so you don't want to say again that it's a list. What it's doing is making a list of a list. Envision placing the avatar names in a box, and then putting the box in another, larger box. Then pick one object out of the larger box. But there's only one object in there; the smaller box. So input() is detecting that there's only one option. Because of that, it automatically selects that option without asking the player. So the "avatar" var ends up equalling the same as the "avatars" list!

var/mob/new_mob
switch(avatar)
if("Lan")
new_mob = new /mob/avatar/Lan()
if("Mayl")
new_mob = new /mob/avatar/Mayl()
if("Yai")
new_mob = new /mob/avatar/Yai()
if("Dex")
new_mob = new /mob/avatar/Dex
if("Chaud")
new_mob = new /mob/avatar/Chaud

As I said before, the "avatar" var is actually a list; not a text string. So it won't equal any of those names, and thus new_mob is never actually created! Which means that this line:

new_mob.oicon = new_mob.icon

...causes an error, because new_mob is null.

Also could you tell me how to process information from HTML popups?

Look up client/Topic() in the reference. If you want a more complicated interface than just clicking a single image or link, then use the Dantom.htmllib library to use HTML forms in the popups. (By forms, I mean like this posting system, with multiple text boxes and buttons.)
In response to Crispy
Thank you for the reply Crispy. I would've never thought that the list part made a difference. And you were wrong about the avatar list part. avatars is the list, avatar is just the reference for creating the new_mob. I did see your point however and will keep that in mind. Now now a new problem arises though. Now the character creation works but it says the logout message and doesn't execute SaveMob() but the mob is still there and can move and everything. No runtime errors, no code errors. What's up with it now?
In response to Crispy
could someone please help me?
In response to Delita12345
Some current code would help.
In response to Crispy
how's this?
mob/other/choosing_character/Login()
..()
if(src.created == 0)
src.CreateNewCharacter()
else
src.loc = locate(1,1,1)
world << "[src] has joined the world"
world
proc
ReSpawn()
world << "Repop!"
Repop()
spawn(60000)
ReSpawn()
New()
..()
ReSpawn()
mob/Logout()
world << "[src.name] logs out..."
del(src)

client/proc/SaveMob()
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
var/char_ckey = cKey(src.mob.name)
F["/[ckey]/[char_ckey]"]<<src.mob

client/proc/LoadMob(char_ckey)
var/firstletter=copytext(src.ckey, 1, 2)
var/savefile/F = new("players/[firstletter]/[src.ckey].sav")
F["/[ckey]/[char_ckey]"]>>src.mob

client/Del()
if (istype(src.mob, /mob/other/choosing_character))
return ..()

src.SaveMob()
return ..()



mob/other/choosing_character/proc/CreateNewCharacter()
src << sound('Server 1.mid',1)
var/prompt_title = "Character Creation"
var/help_text = "What is your name? REMEMBER: Please use appropriate, RP names."
var/default_value = "[src.key]"
var/char_name = input(src, help_text, prompt_title, default_value) as text

var/list/avatars = list("Lan","Mayl","Dex","Yai","Chaud")
var/avatar = input(src,"Which avatar would you like?","Character Creation") in avatars
var/mob/new_mob
switch(avatar)
if("Lan")
new_mob = new /mob/avatar/Lan()
if("Mayl")
new_mob = new /mob/avatar/Mayl()
if("Yai")
new_mob = new /mob/avatar/Yai()
if("Dex")
new_mob = new /mob/avatar/Dex()
if("Chaud")
new_mob = new /mob/avatar/Chaud()

new_mob.oicon = new_mob.icon
new_mob.exp = 0
new_mob.name = char_name

src.client.mob = new_mob
var/turf/first_location = locate(1,1,1)
new_mob.loc = first_location
src.created = 1
client.SaveMob()

mob
Login()
..()
if (!istype(src, /mob/other/choosing_character))
sample_report()

Write(savefile/F)
..()

F["last_x"] << x
F["last_y"] << y
F["last_z"] << z

Read(savefile/F)
..()

var/last_x
var/last_y
var/last_z
F["last_x"] >> last_x
F["last_y"] >> last_y
F["last_z"] >> last_z
loc = locate(last_x, last_y, last_z)

proc
sample_report()
In response to Delita12345
> And you were wrong about the avatar list part. avatars is the list, avatar is just the reference for creating the new_mob.

Actually, I was right; "avatar" was getting set to a list because the input() statement was assigning a list to it. But removing the list() bit fixed that. =)

> Now the character creation works but it says the logout message and doesn't execute SaveMob() but the mob is still there and can move and everything. No runtime errors, no code errors. What's up with it now?

Which mob is still there - the choosing_character mob or the created mob? Does control actually switch over to the created mob?

The logout message I have an explanation for, at least; when client.mob is set, the client logs into the new mob. But to log into that mob, it must first log out of its old (choosing_character) mob. Thus, Logout() is called; you see the message, and the choosing_character mob should delete itself.
In response to Crispy
Crispy wrote:
And you were wrong about the avatar list part. avatars is the list, avatar is just the reference for creating the new_mob.

Actually, I was right; "avatar" was getting set to a list because the input() statement was assigning a list to it. But removing the list() bit fixed that. =)

ok, I understand that now

Now the character creation works but it says the logout message and doesn't execute SaveMob() but the mob is still there and can move and everything. No runtime errors, no code errors. What's up with it now?

Which mob is still there - the choosing_character mob or the created mob? Does control actually switch over to the created mob?

I'm not quite sure which is there. I have a basic stick figure icon only for Lan at the moment, and the mob is that stick figure.

The logout message I have an explanation for, at least; when client.mob is set, the client logs into the new mob. But to log into that mob, it must first log out of its old (choosing_character) mob. Thus, Logout() is called; you see the message, and the choosing_character mob should delete itself.

ok, but there is a mob controllable put on the map, without the Login() message.
In response to Delita12345
any suggestions?
In response to Delita12345
any suggestions on why my code is giving me hell?