ID:178274
 
I want a password on my door, here is my code:

door
icon = 'obj.dmi'
icon_state = "door"
density = 1
var/password
if(src.password)
var/P = input("Password","What is the password?") as text

and my errors are:

obj.dm:42:error:src.password:value not allowed here
obj.dm:43:error:= :expected a constant expression
obj.dm:43:error::empty type name (indentation error?)
JimmyWimmy wrote:
I want a password on my door, here is my code:

door
icon = 'obj.dmi'
icon_state = "door"
density = 1
var/password
if(src.password)
var/P = input("Password","What is the password?") as text

and my errors are:

obj.dm:42:error:src.password:value not allowed here
obj.dm:43:error:= :expected a constant expression
obj.dm:43:error::empty type name (indentation error?)

The code here needs to be inside a proc. You should look at one of the tutorials to see how to create procs.
you need to put the if() inside of a proc, you see, like this:

obj
door
density = 1
icon = 'Door.dmi'
icon_state = "DoorClosed"
var
password = "Geese are evil"
verb
open()
set src in oview(1)
if(password)
usr.misc = input("Password?","Password?") as text
if(usr.misc == password)
open() //call the open proc defined below.
else
usr << "incorrect password!"
else
open()
proc
open()
density = 0
icon_state = "DoorOpen"
Sleep(20)
close()
close()
density = 1
icon_state = "DoorClosed"

Obviosly there are some mistakes in this code, but if you use the help commands, you can catch them! Good luck!
Try this:

obj/door
icon = 'door.dmi'
icon_state = "closed"
density = 1
var/pword = "Cheese"
verb/Open()
set src in oview(1)
var/junk = input("What password?","Password")
if(junk == pword)
src <<"Correct password!"
density = 0
icon_state = "open"
else
src <<"Incorrect password!"
return


That MIGHT work.

-Kappa the Imp
In response to Kappa the Imp
kappa, I already posted the working code, and besides, he is trying to make it so that only CERTAIN doors have passwords, you code would not be fitting for that