ID:1289031
 
(See the best response by Super Saiyan X.)
Code:
var/WorldName=""
var
SomeoneChoosing=0
proc
SaveWorld()
world<<"World saving in progress..."
var/savefile/F = new("Worlds/[WorldName] World.sav")
var/list/L = new
L+=genlayer
for(var/Blocks/O in world)
if(!istype(O,/HUD))
if(O.name!="Black")
O.saved_x = O.x
O.saved_y = O.y
O.saved_z = O.z
L += O
else
if(O.owner!=null)
O.saved_x = O.x
O.saved_y = O.y
O.saved_z = O.z
L += O
F[""] << L
world<<"World saved."

Player
verb //Make where once world is opened you automatically go to world as a new player or loaded player.
Save_World()
SaveWorld()
Save_Player()
var/savefile/F = new ("Players/[src.key] [WorldName] World Player")
src<<"<b>Game Saved"
src.xco = src.x
src.yco = src.y
src.zco = src.z
Write(F)
NewWorld()
set hidden = 1
WorldName=input("What do you wish to name this world?") as text
winshow(usr, "Title", 0)
winshow(usr, "Wait",1)
sleep(5)
Generation()
sleep(15)
winshow(usr,"Wait",0)
src.loc=locate(1,1,1)
src.pixel_z=(genlayer*16) // Puts you on top of generated map.
src.icon='Mob.dmi'
src.layer=12
src.client.screen += screen_objects
winshow(usr,"default",1)
LoadWorld()
set hidden = 1
var/list/saveFiles=flist("Worlds/")
var/list/save_display=list()
for(var/v in saveFiles)
save_display+="[v]"
var/choice=input("Welcome to [world.name]! What would you like to do?\n\nSavefiles Used: ","Login") in saveFiles
winshow(src, "Title", 0)
winshow(src, "Wait",1)
sleep(5)
var/savefile/F = new("Worlds/[choice]")
var/list/L = new
F[""] >> L
if(!L)
alert("World Corrupted.")
return
genlayer = L[1]
for(var/Blocks/O in L)
O.loc = locate(O.saved_x,O.saved_y,O.saved_z)
if(fexists("Players/[src.key] [choice] Player"))
var/savefile/D = new("Players/[src.key] [choice] Player")
Read(D)
world << "<font color = blue>[src] has logged in!"
src.loc = locate(src.xco,src.yco,src.zco)
src.pixel_z=(genlayer*16)
src.layer=12
src.client.screen+=screen_objects
else
src.loc=locate(1,1,1)
src.icon='Mob.dmi'
src.layer=12
src.client.screen += screen_objects
for(var/Blocks/B in src)
if(src.pixel_z<B.pixel_z)
src.pixel_z=B.pixel_z
src.pixel_z+=src.pixel_z+16
winshow(src, "Wait",0)
winshow(src,"default",1)


Problem description:

I have searched all over the forums, looked through the help guide, and I've been staring at this for 2 hours now and I can get a single thing to work. How do I get rid of this bad client?

runtime error: Cannot read null.screen
proc name: LoadWorld (/Player/verb/LoadWorld)
source file: World.dm,83
usr: Ganing (/Player)
src: Ganing (/Player)
call stack:
Ganing (/Player): LoadWorld()

FYI 83 is: src.client.screen += screen_objects.

I've tried creating a mob for the client but I just can't get anything to work. It happens when I'm loading a world I've created. The character save system has really nothing to do with it as without it I still get the error. Please help :/
What this tells me is client is null.

Do you set client.mob anywhere (or mob.client)?
Have you output the client.mob information to make sure it's expected?
I went through and made it where it isn't null but now i'm stuck at my own start screen for some reason.

            var/Player/new_mob = new /Player
src.client = new_mob
src.Login()


This should make you call the Login() of the type player right?
Where are you calling that?

client.mob = new /Player


That might not be the best way; but you don't need to call Login(). It's automatically called when you assign a new mob to client.mob.
(I've changed the code a bit)Well for some reason it's not. I have a window that opens that shows you options new/load world and when you click one of them you should revert from WorldMaker to Player and then Login(). But I can't seem to get it to login under Player even if I change the client to /Player. It still logins as if it was a WorldMaker. How is this?

WorldMaker
verb
LoadWorld() //Load any world you have saved
set hidden = 1
var/list/saveFiles=flist("Worlds/")
var/list/save_display=list()
for(var/v in saveFiles)
save_display+="[v]"
var/choice=input("Welcome to [world.name]! What would you like to do?\n\nSavefiles Used: ","Login") in saveFiles
winshow(src, "Title", 0)
winshow(src, "Wait",1)
sleep(5)
var/savefile/F = new("Worlds/[choice]")
var/list/L = new
F[""] >> L
if(!L)
alert("World Corrupted.")
return
WorldName = L[1]
for(var/Blocks/O in L)
O.loc = locate(O.saved_x,O.saved_y,O.saved_z)
var/Player/new_mob = new /Player
src.client = new_mob
NewWorld()
set hidden = 1
WorldName=input("What do you wish to name this world?") as text
winshow(usr, "Title", 0)
winshow(usr, "Wait",1)
sleep(5)
Generation()
sleep(15)
var/Player/new_mob = new /Player
usr.client = new_mob.client
usr.Login() //If this isn't here it seems Login() isn't even called.

WorldMaker
parent_type=/mob
Login() //Login of the client to create/load the world
alert("I'm here32")
if(WorldName==""&&SomeoneChoosing==0)
SomeoneChoosing=1
// var/Player/M = new /Player
// src.client = M
else
winshow(usr, "Wait",1)
while(WorldName=="")
sleep(25)
winshow(usr, "Wait",0)
var/Player/M = new /Player
src.client = M
Player
Login() //Official Login of the player
alert("I'm here")
spawn(5)
if(fexists("Players/[src.key] Player"))
var/savefile/D = new("Players/[src.key] Player")
Read(D)
world << "<font color = blue>[src] has logged in!"
src.loc = locate(src.xco,src.yco,src.zco)
else
src.loc=locate(1,1,1)
src.icon='Mob.dmi'
src.layer=12
src.client.screen += screen_objects
winshow(src, "Wait",0)
winshow(src,"default",1)
src.pixel_z = 160
src.checkEnter()
FYI no matter what I always have that alert I'm here32 pop up. Haven't been able to make the client Login under Player yet.
Best response
Look at what you're doing - you're assigning a /mob to a variable intended as a /client. In like two locations.

Don't need Login() if you assign it correctly:
            var/Player/M = new /Player
src.client.mob = M

Well then. I have been schooled. Thank you.