world
mob = /mob/other/choosing_character
name = "One Punch Man"
hub_password = "omolewa"
view = 7
fps = 10
version = 1.0
status = "<B><font size = -2><font color = green>One Punch Man</font> <font color = purple>{Version Beta 1.0}</font>"
hub = "Dragonpearl123.onepunchman"
sleep_offline = 0
map_format = TOPDOWN_MAP
icon_size = 32
var/list/_races = list("Human"=/mob/characters/Human, "Mage"=/mob/characters/Mage) //obviously, modify this to suit your races.
client
var/tmp
mob/oldmob
proc
Save()
if(oldmob&&oldmob.savable)
var/savefile/savefile = new("players/[copytext(ckey, 1, 2)]/[ckey].sav")
savefile["/[ckey]/[ckey(mob.name)]"] << oldmob
Del()
Save()
..()
mob/other/choosing_character
var
list/characters = list()
savefile/savefile
Login()
client.eye = locate(rand(1,150),rand(1,150),1)
client.perspective = EYE_PERSPECTIVE
spawn()
ChooseCharacter()
proc
ChooseCharacter()
//we don't need to reload the savefile more than once. Store it and keep the chars list around
savefile = new("players/[copytext(ckey, 1, 2)]/[ckey].sav")
savefile.cd = "/[ckey]"
characters = savefile.dir
var/list/menu //it's best to define these outside of a loop where possible. There are reasons.
var/result
while(client)
menu = characters + "New Character" + "Delete Character"
result=input("Choose an option", "One Punch Man") as anything in menu
switch(result)
if("New Character")
CreateNewCharacter()
if("Delete Character")
DeleteCharacter()
else
LoadCharacter(result)
DeleteCharacter()
var/result = input("Delete character", "Character Creation") as null|anything in characters
if (result)
savefile.dir.Remove(result)
characters -= result
CreateNewCharacter()
var/char_name
do
char_name = input(src, "What is your name?","New Character") as null|text
if(!char_name)
return
if (ckey(char_name) in characters)
alert("This name isn't acceptable.")
char_name = null
while(!char_name)
var/char_race = input(src, "What race do you wish to be?", "New Character", "Human", "Mage") in _races
var/rtype = _races[char_race]
var/mob/new_mob = new rtype()
new_mob.client = client //after creating the new character, you need to set the new mob's client to end the character creation process and suspend the loop.
new_mob.savable = 1
new_mob.name = char_name
savefile[ckey(char_name)] << new_mob //save the character in the savefile before this mob is garbage collected.
LoadCharacter(char)
var/mob/m
savefile[char] >> m
m.savable = 1 //shouldn't be necessary, but in case you don't want to purge your savefiles.
//if(client) m.client = client //this should never happen, but just in case something goes wrong we'll put it here anyway to be safe
mob
var
savable = 0
Login()
if(client.oldmob) client.Save()
client.oldmob = src
src.loc=locate(44,39,1)
src.icon_state = ""
src.sight = 0
client.eye = src
client.perspective = MOB_PERSPECTIVE
src << output("<b><font color = red>Welcome to One Punch Man The Game, we owe no affiliation to one punch man so don't sue us XD</font>","system")
world << output("<font color=purple><b>[name] has joined the ranks</b></font>", "chatbox")
sample_report()
Logout()
client.Save()
del src
Write(savefile/F)
if(!savable) return
..()
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()
src << output("<b><font size = 1><font color = silver><center>By: Dragonpear321","system")
src << output("<b>Beta Testing One Punch Man","system")
Problem description:
This is really starting to grind my gears, the game will not save anything and I am getting these runetime errors.
runtime error: Cannot execute null.Save().
proc name: Logout (/mob/Logout)
source file: Start.dm,110
usr: (src)
src: Dragonpearl123 (/mob/other/choosing_character)
src.loc: null
call stack:
Dragonpearl123 (/mob/other/choosing_character): Logout()
Dragonpearl123 (/mob/other/choosing_character): CreateNewCharacter()
Dragonpearl123 (/mob/other/choosing_character): ChooseCharacter()
Dragonpearl123 (/mob/other/choosing_character): Login()
Can someone please help me!!!