ID:147394
 
Alright I start making a demo for a friend, it didn't seem hard so I started. Well obviously it was because I get this run-time error that I cannot get fixed. Here is the entire demo code...

mob
icon = 'icons.dmi'
icon_state = "person"
turf
icon = 'icons.dmi'
grass
icon_state = "grass"
house
woodfloor
icon_state = "floor"
wall
density = 1
icon_state = "wall"
obj
icon = 'icons.dmi'
chair
icon_state = "chair"
bed
icon_state = "bed"
table
icon_state = "table"
var
saveX = 0
saveY = 0
saveZ = 0
var/list/HouseStuff = list()
world/New()
if(fexists("House.sav"))
var/savefile/F = new("House.sav")
F >> HouseStuff
for(var/obj/O in HouseStuff)
O.loc = locate(O.saveX,O.saveY,O.saveZ)
world/Del()
var/savefile/F
F = new("House.sav")
for(var/turf/house/T in world)
for(var/obj/O in T.loc)
O.saveX = O.x
O.saveY = O.y
O.saveZ = O.z
HouseStuff.Add(O)
F << HouseStuff
mob/verb/Lay_Object()
switch(alert(src,"What type of object do you wish to lay?","Laying Objects","Chair","Table","Bed"))
if("Chair")
new/obj/chair(src.loc)
if("Table")
new/obj/table(src.loc)
if("Bed")
new/obj/bed(src.loc)


Not long, not hard...but I get this run-time error...

runtime error: Cannot execute null.Add().
proc name: Del (/world/Del)
usr: null
src:
call stack:
: Del()

I have tweaked and tweaked with this code to no victory. If someone can help me it would be VERY helpful.

Rifthaven wrote:
Alright I start making a demo for a friend, it didn't seem hard so I started. Well obviously it was because I get this run-time error that I cannot get fixed. Here is the entire demo code...

mob
icon = 'icons.dmi'
icon_state = "person"
turf
icon = 'icons.dmi'
grass
icon_state = "grass"
house
woodfloor
icon_state = "floor"
wall
density = 1
icon_state = "wall"
obj
icon = 'icons.dmi'
chair
icon_state = "chair"
bed
icon_state = "bed"
table
icon_state = "table"
var
saveX = 0
saveY = 0
saveZ = 0
var/list/HouseStuff = list()
world/New()
if(fexists("House.sav"))
var/savefile/F = new("House.sav")
F >> HouseStuff
for(var/obj/O in HouseStuff)
O.loc = locate(O.saveX,O.saveY,O.saveZ)
world/Del( <insert code here> )
var/savefile/F
F = new("House.sav")
for(var/turf/house/T in world)
for(var/obj/O in T.loc)
O.saveX = O.x
O.saveY = O.y
O.saveZ = O.z
HouseStuff.Add(O)
F << HouseStuff
mob/verb/Lay_Object()
switch(alert(src,"What type of object do you wish to lay?","Laying Objects","Chair","Table","Bed"))
if("Chair")
new/obj/chair(src.loc)
if("Table")
new/obj/table(src.loc)
if("Bed")
new/obj/bed(src.loc)


Not long, not hard...but I get this run-time error...

runtime error: Cannot execute null.Add().
proc name: Del (/world/Del)
usr: null
src:
call stack:
: Del()

I have tweaked and tweaked with this code to no victory. If someone can help me it would be VERY helpful.


im guessing by that error it is saying that instead of you deleting the item(src) then its gunna delete the world as it says, try putting something in the parenthesis where i put insert code here and i think that will work
HouseStuff is defined as a list, but never initialized.

var/list/HouseStuff=list()
In response to EdEdEd
That's not quite what I was trying to accomplish...when the world shuts down, it's suppose to take the objects and save them in "HouseStuff" then save "HouseStuff" to a savefile.
In response to Goku72
Erm, what do you mean? That line of code in my demo is in my demo...
Rifthaven wrote:
var/list/HouseStuff = list()
world/Del()
var/savefile/F
F = new("House.sav")
for(var/turf/house/T in world)
for(var/obj/O in T.loc)
O.saveX = O.x
O.saveY = O.y
O.saveZ = O.z
HouseStuff.Add(O)
F << HouseStuff
runtime error: Cannot execute null.Add().
proc name: Del (/world/Del)
usr: null
src:
call stack:
: Del()

Have you tried initializing thaat list in another way?

var/list/L // list reference
L = new/list() // make a new list
L = new() // make a new list (implicit type)

var/L[5] // initial length of 5

(taken from DM help file, look for more explained references)
In response to Lazyboy
Nope no work
In response to Rifthaven
Oh, hehehehehe...didn't even see that there, silly me. >.>
But, the list is infact becoming null in some fashion. O.o
In response to Goku72
Yeah but the question is why and where.....hehe
In response to Rifthaven
I just tried using
var/list/HouseStuff[0]
to make the list, and i didnt get anymore errors with the code you provided. But another thing is that the objects are saved no matter what turf the objects are placed on.

[edit]
i just tried the code you pasted normally and i didnt get any runtime errors at all.
[/edit]
In response to Lazyboy
Wierd...because the one you gave me errored....

(Oh and I was aware it save regardless but that's an easy fix and not the problem...hehe)

Can someone else try the code and see if they get a run-time error when they try to exit the world?


*EDIT*
(Be sure to lay an object first!)

*EDIT AGAIN*
Please keep in mind that you don't get a run-time if you don't lay an object, and to lay an object you have to create a mp
It turns out the code was fine...there's something wrong with my dream seeker/maker, I'm going to reinstall and hope it fixes it. I'm sorry for bringing the code to the forums.