ID:178973
 
Alright I try as hard as possible to not be an annoying newbie that you all hate (notice no caps and only one question mark unlike most others) but i dont know how I could code this properly. Well, I am making doors for almost every place in my map and I would like them to be opened when you click on them but as soon as somebody passes over them they close again. That isnt really the biggest problem, I would like to be able to lock the doors by using a certian key on them. Could anybody tell me how to go about this without millions of miles of code to work with?
Well, once they click the door have the doors icon_state change to open and change it's density to 0. Then use the Exited() proc to close the door.

As for the key problem, I've never actually implimented one before so someone else could probably give you a more efficient solution.

An approach that makes sense would be use a testing statment like this:

obj
lockdoor
var/key_type = /obj/blue_key //give each door a keytype
Click()
for(var/obj/key/K in usr.contents) //look for all keys in usr
if(istype(K,key_type))
//open door
In response to English
Ok this is my first time ever answering a code question so I'll try my hardest.

        var
locked = 1
verb
Open()
set src in view(1)
if(src.locked == 0)
src.density = 0
src.opacity = 0
src.icon_state = "open"
else
usr <<"The door is locked.<br>You need a key."

Close()
set src in view(1)
src.density = 1
src.opacity = 1
src.icon_state = "closed"
Unlock()
set src in view(1)
var/has_key = locate(/obj/key/) in usr.contents
if(has_key)
if(src.locked == 1)
usr << "You unlocked the door."
src.locked = 0
else
usr << "You door is not locked."
else
usr << "You don't have the key."
Lock()
set src in view(1)
var/has_key = locate(/obj/key/) in usr.contents
if(has_key)
if(src.locked == 0)
usr << "You lock the door."
else
usr <<"The door is already locked."
else
usr <<"You don't have the key."

If you need any help with this code ill try to help you :P
Hope I helped, Good luck