ID:178850
 
Could someone please show me how to make doors that open when you have a certain item in your inventory?
first off make an object
obj
key
verb
Get()
set src in oview(1)
usr.contents+=new/obj/key
usr.key var=1//this gives the character the ability to open the door
del(src)
turf
door
icon='door.dmi'
density = 1
verb
Open()
set src in view(1)
if(usr.key var>=1)
del src

thats about all you need


In response to Richter
Richter wrote:
usr.contents+=new/obj/key
usr.key var=1//this gives the character

This isn't really a good way to do that--nor syntactically correct. A better way is for the door check proc to do something like this:
// src is the door
// M is the player
var/obj/key/thekey
for(thekey in M)
if(thekey.keycode==keycode) // if the key is for this door
break
if(thekey) // if a key was found
... // open up
else
M << "You don't have the right key for [src]."

Lummox JR