ID:268081
 
turf/var
x1
y1
z1
password
key
turf/lock
doorkeypass
Enter()
if(usr.key == "[src.key]")
usr.loc = locate(src.x1,src.y1,src.z1)
else
var/passwords = input("Enter Password")as num
if(passwords == src.password)
usr.loc = locate(src.x1,src.y1,src.z1)

I know this makes a door have a password but im not entirely sure i understand it =/ or how to use it, and im not the type to just copy and paste something so could someone help me understand this snippet? Thanks.
turf/var
x1
y1
z1
password
key
turf/lock
doorkeypass
Enter(atom/movable/A)
if(!ismob(A)) return 0
if(A:key == "[src.key]")
A.loc = locate(src.x1,src.y1,src.z1)
else
var/passwords = input("Enter Password")as num
if(passwords == src.password)
A.loc = locate(src.x1,src.y1,src.z1)

I rewrote that a little. You shouldn't use usr.

Here is what it does:
Once someone walks up to it, if will do the following:
If the person's key is the same as what the turf's 'key' variable is, the player will be transported to (x1,y1,z1). Otherwise, they will be asked for a password. If it matches with the turf's 'password' variable, the player will be teleported in the same way.
First of all, this code gives all turfs 5 new variables, when it really only needs to give them to /turf/lock or /turf/lock/doorkeypass types. Also, the x1, y1, and z1 variables are not needed.

What the code does:

When you attempt enter a turf of the type /turf/lock/doorkeypass, the Enter proc first checks to see if your key is the same as the turf's "key" var. If not, it asks you to enter a password, which it then checks against the turf's "password" var. If you have the correct key or if you enter the correct password, your location is directly set to that of the turf. If not, you will not enter the turf.

To set the password and key variables prior to compiling, you must first place the /turf/lock/doorkeypass turfs on your map, right click on them and select "properties", and then set the variables from there.
In response to Yota
You tell him not to use usr, and yet you blatantly use it in that input() proc.
In response to Garthor
Garthor wrote:
You tell him not to use usr, and yet you blatantly use it in that input() proc.

It's not blatantly obvious for everyone, Garthor.
In response to Jon88
It's blatantly obvious if you take a second to think, "Wait... how does it know which mob to get the input for?", and then either make the obvious link that it isn't src, because that would give you an error, because you can't ask a turf for input, or you can just look it up in the reference.
In response to Garthor
If there is no usr, there's no point in even calling input(). That'd mean the thing entering is an NPC, and we don't want thoes giving a correct password. As for the vars being at the /turf level, I didn't relize that.
In response to Yota
What they were saying is, if you don't tell the input proc what to get info from it automatically gets it from usr. You have to tell it to get input from A, in this case.