ID:170595
![]() Jan 5 2005, 7:16 am
|
|
im having trouble figuring out how to get a door to have a pword..
|
![]() Jan 5 2005, 7:25 am
|
|
Try this(Untested)
|
The flaws in this code are described in [link]. It's very very important to consider robustness in your code, particularly when you're offering it to another newbie.
Lummox JR |
why dos
mob/verb/CreateDoor() var/A=new/obj/Door(usr.loc) A.password=input("What should the door's password be?") obj/var/password obj/var/state obj/Door verb Open() set src in view(1) if(src.state=="Open") return var/Guess=input("What is the door's password?") if(Guess==src.password) src.state="Open" Close() set src in view(1) if(src.state=="Closed") return src.state="Closed" dosnt work? it says: dbz.dm:253:error::invalid expression dbz.dm:255:error:A.password:undefined var dbz.dm:254:A :warning: variable defined but not used mob/verb/CreateDoor() var/A=new/obj/Door(usr.loc) A.password=input("What should the door's password be?") these are the errors i wanted to do guildhouses in the game(donthink i waz copying files)but the house to be whit a password so my game will be not like all the otheres |
A.password is an invalid var. The password var belongs to obj (I'd recommend moving it to obj/Door), so A needs to be defined as such:
mob/verb/CreateDoor() I've moved the vars password and state to obj/Door as they appear to only apply there. Since we've changed A to be of type obj/Door, we can omit the path in the new() statement because it will use the path of the var. I've also given state and password some default values. Also, when posting DM code, use DM tags: <DM> Your code here </DM> That does some basic syntax highlighting, and helps readability. Hope that fixes the errors! |