ID:176224
 
No errors come up! After you buy the key it goest to your inventory. Each door is set up to work with only 1 door. When I use the following code all the doors open up to this one key

obj/door01
icon = 'mob.dmi'
icon_state = "door01"
density = 1
verb
Open()
for(var/key01 in usr.contents)
set category = "Options"
set src in oview(1)
icon_state = "door02"
sleep(5)
icon_state = "door03"
sleep(5)
icon_state = "door04"
layer += 100
density = 0

and when I use this code all the dorrs say You don't have the key when the key is clearly in my inventory.

obj/door01
icon = 'mob.dmi'
icon_state = "door01"
density = 1
verb
Open()
if(/obj/key01 in usr.contents)
set category = "Options"
set src in oview(1)
icon_state = "door02"
sleep(5)
icon_state = "door03"
sleep(5)
icon_state = "door04"
density = 0
else
usr << "You don't have the key"
The problem with your first attempt is you're looping through everything in your inventory, assigning it the variable key01, and then opening the door and stuff. The problem with your second is that contents holds atoms, not type paths. You want:

if(locate(/obj/key01) in contents)
Codesterz wrote:
if(/obj/key01 in usr.contents)

First of all, you need to locate a key inside of the user's contents.

if(locate(/obj/key01 in usr.contents)



icon_state = "door02"
sleep(5)
icon_state = "door03"
sleep(5)
icon_state = "door04"
density = 0
else
usr << "You don't have the key"

Second, there is a better way to animate a door. Make an animation state, but have it 1 direction. Copy and paste the icons states "door02" to "door04" into that new animation state. Rename the state to "animate", then replace all of that with flick("animate",src).

~>Volte
In response to Volte
I'm to lazy to do that. I'll jst do i the easy/quick way :D
In response to Codesterz
Codesterz wrote:
I'm to lazy to do that. I'll jst do i the easy/quick way :D

The way I specified is the easy and quick way. Coding in animations is time consuming, and can sometimes cause big problems.. One being frustration. =P

~>Volte
In response to Garthor
same problem it says I don't have the key
In response to Codesterz
Warning: The message you are about to read comes from a newbie, please do not think it actually works. :)

I'm sure this may be the hard way to do if it does work, but I would set a variable for the keys and then check so see if they have the right one with something like
if(key1 == 1)
open whatever
else
usr <<"You don't have the key"

maybe you could use that as a last resort.
In response to Codesterz
My bad. It should be usr, not contents.
In response to Garthor
O.0...'tis the end of thy world! Garthor has made a newbie mistake, ones for which he has baffled at others alike for ages!!!
In response to Goku72
Heh. Silence. O_o