ID:263712
 
Code:
obj/Gringgots/Vault_Door_1
name="Vault Door"
icon='obj.dmi'
icon_state="vault"
density=1
opacity=1
var/owner=""
verb
Open_Vault()
set src in oview(1)
var/obj/Gringgots/Vault_Door_Key/K
for(K in usr)
if(K.Vault=="[src.name]")
usr.y+=2
usr<<"Welcome back to Gringots Mr. [usr]"
return
else
return
return
Leave_Vault()
set src in oview(1)
var/obj/Gringgots/Vault_Door_Key/K
for(K in usr)
if(K.Vault=="[src.name]")
var/savefile/F = new("Map.sav")
for(var/obj/o in oview(10))
o.lastx = o.x
o.lasty = o.y
o.lastz = o.z
objs.Add(o)
F << objs
usr.y-=2
else
return
return
Buy_Vault()
set src in oview(1)
if(src.owner=="")
var/obj/Gringgots/Vault_Door_Key/K
for(K in usr)
if(K.owner=="")
if(K.Vault=="")
src.name="[usr]'s Vault"
K.owner="[usr]"
K.Vault="[src.name]"
var/savefile/F = new("Map.sav")
for(var/obj/o in oview(10))
o.lastx = o.x
o.lasty = o.y
o.lastz = o.z
objs.Add(o)
F << objs
usr.y+=2
return
else return
else return
else return
obj/Gringgots/Vault_Door_Key
icon='obj.dmi'
icon_state="key"
var/owner=""
var/Vault=""
verb/Get()
set src in oview(1)
src.loc=usr
return
verb/Drop()
src.loc=usr.loc
return


Problem description:
Why does it not work, when i try and buy the Vault i get this:

runtime error: Cannot execute null.Add().
proc name: Buy Vault (/obj/Gringgots/Vault_Door_1/verb/Buy_Vault)
source file: Gringots.dm,51
usr: Lt. Pain (/mob)
src: Lt. Pain\'s Vault (/obj/Gringgots/Vault_Door_1)
call stack:
Lt. Pain\'s Vault (/obj/Gringgots/Vault_Door_1): Buy Vault()
Would appear to meh that objs is null, can you show where you have it defined?
In response to Rifthaven
What object is null?
In response to Lt. Pain
objs.Add(o)


That's causing the run time error, because 'objs' is null. Where is objs defined? I'm assuming it's not defined correctly and that's why you're having this issue.


*EDIT* Foomer went where I was getting at, read his post carefully and you should find your answer.
You're probably trying to add things to a list that isn't defined as a list.

For example:
mob/verb/TestNullError()
var/list/objs
var/obj/O = new()
objs.Add(O)
return objs


That should give you the same error, while what you want is this:

mob/verb/TestNullError()
var/list/objs = list()
var/obj/O = new()
objs.Add(O)
return objs


Alternatively, if you need to have objs lists everywhere but you don't want them all defined as list() because that will hit the list limit real quick, you can turn things into a list when you add to them, and turn them to null again when they're empty.

turf
var/list/objs

proc/AddObj(obj/O)
if(!objs)
objs = list()
objs += O

proc/RemoveObj(obj/O)
if(!objs)
return
objs -= O
if(!objs.len)
objs = null
In response to Rifthaven
var/list/objs = list ()


thats how it defined in a different seciton
srry couldnt seem to get it :/ can you explain furter
In response to Lt. Pain
Why don't you start with which line is line 51.
In response to Foomer
im sorry what?
In response to Lt. Pain
runtime error: Cannot execute null.Add().
proc name: Buy Vault (/obj/Gringgots/Vault_Door_1/verb/Buy_Vault)
source file: Gringots.dm,<font color=red>51</font>
usr: Lt. Pain (/mob)
src: Lt. Pain\'s Vault (/obj/Gringgots/Vault_Door_1)
call stack:
Lt. Pain\'s Vault (/obj/Gringgots/Vault_Door_1): Buy Vault()

That line.
Where is objs defined, and could it be null?
In response to Jp
i see, now can you show me where to define objs please :/