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.
ID:147394
![]() Jun 13 2004, 5:43 pm
|
|
HouseStuff is defined as a list, but never initialized.
var/list/HouseStuff=list() |
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.
|
Rifthaven wrote:
var/list/HouseStuff = list() 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) |
Oh, hehehehehe...didn't even see that there, silly me. >.>
But, the list is infact becoming null in some fashion. O.o |
I just tried using
var/list/HouseStuff[0]
[edit] i just tried the code you pasted normally and i didnt get any runtime errors at all. [/edit] |
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 |
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