ID:151108
 
im making a housing system in my game where you go to a certain npc and buy a key for a house. When i try and unlock a door it says cannot read null.id. Does anyone know whats going on? I'm guessing it has something to do with the way the vars are defined but i dont know another way to do it unless i make the door and the key both obj.

turf/var/id
obj/var/id
turf/door/d1
icon = 'door3.dmi'
id = 1
Entered(src)
src:loc = locate(6,76,2)

verb/unlock()
set src in oview(usr, 1)
if(!src.locked)
usr << "[src] is not locked!"
return

var/turf/door/d1/H
var/obj/item/key1/K = locate() in usr.contents
if(K && (K.id == H.id))
src.locked = 0
src.density = 0
icon_state = ""
usr << "You have unlocked [src]."
return

else
usr << "You don't have the proper key."

obj/item/key1
icon = 'key.dmi'
id = 1
desc = "its the key for house #1"
On 4/18/01 3:01 am Haroki wrote:
im making a housing system in my game where you go to a certain npc and buy a key for a house. When i try and unlock a door it says cannot read null.id. Does anyone know whats going on? I'm guessing it has something to do with the way the vars are defined but i dont know another way to do it unless i make the door and the key both obj.

In your code
var/turf/door/d1/H // <- here

H is just a null var. You have to assign it to something, namely the door you want to unlock. But that is just the /turf/door under which you are defining the proc, ie- the src! So either make

var/turf/door/d1/H = src

or (better) just use 'src' instead of 'H'. It will already be of the proper type.