ID:268881
 
mob
Bump(var/door/locked/L)
if(src.unlocked_doors.Find(L))
L.Open()
else
if(src.contents.len)
if(src.contents.Find(L.key))
src.unlocked_doors.Add(L)
..()


I don't get why it doesn't work. =/
Also, thanks for reading.
obj/door/Bump() better? Why would bumping into a mob work >.>
Are you trying to call this when you bump into the door?
In response to DeathAwaitsU
DeathAwaitsU wrote:
Are you trying to call this when you bump into the door?

Yes.

And to Night: It's the mob bumping it. :P
In response to Hell Ramen
Use Bumped instead:

atom/proc/Bumped(atom/movable/bumped_by) //Declare a new proc for all atoms called Bumped.
atom/movable/Bump(atom/O)
if(O) O.Bumped(src) //Then make Bump call Bumped for the atom that was hit.

obj
door
Locked
Bumped(atom/movable/A)
if(istype(A,/mob/Player))
var/mob/M = A
if(src.unlocked_doors.Find(M))
src.Open()
else
if(M.contents.len)
if(M.contents.Find(src))
M.unlocked_doors.Add(src)


The M(players) and srcs may be wrong btw.
In response to DeathAwaitsU
Whoops, I totally misunderstood that.
In response to Hell Ramen
As in you don't understand my code or misunderstood the Bump concept?
In response to DeathAwaitsU
Don't understand it, could you explain it a bit? =/
In response to DeathAwaitsU
When the door is bumped, call the Bumped() proc.

If the thing that Bumped it(A) is a mob of the type /mob/Player, call that mob M.

The rest is your code, take in mind that the thing Bumping the door(the player) is M and src is the door itself.
In response to DeathAwaitsU
_> Hmmmm...it still doesn't seem to work. I even debugged it with messages (src << "Q1",etc)...well, thanks for the help so far.
In response to Hell Ramen
src << "Q1" would give the object a message not the player...

Try this:

atom/proc/Bumped(atom/movable/bumped_by) //Declare a new proc for all atoms called Bumped.
atom/movable/Bump(atom/O)
if(O) O.Bumped(src) //Then make Bump call Bumped for the atom that was hit.

obj
door
Locked
Bumped(atom/movable/A)
world << "Proc is called"
if(istype(A,/mob/Player))
var/mob/M = A
world << "My code accepted"
if(src.unlocked_doors.Find(M))
src.Open()
else
if(M.contents.len)
if(M.contents.Find(src))
M.unlocked_doors.Add(src)
else
world << "Not right type"
world << M


Tell me what comes up.
In response to DeathAwaitsU
Ahhh, so my coding was wrong in the lowerhalf. Your's is correct.
[edit]So, now my question is, how to correct the bottom half of my code?
In response to Hell Ramen
Could you tell me what you want to do if the door hasn't already been unlocked? Whats that bit after the else?
In response to DeathAwaitsU
If the mobs contents has something.
If it finds the door's key var (src.key)
Add the door to the person's unlocked list.
In response to Hell Ramen
atom/proc/Bumped(atom/movable/bumped_by) //Declare a new proc for all atoms called Bumped.
atom/movable/Bump(atom/O)
if(O) O.Bumped(src) //Then make Bump call Bumped for the atom that was hit.

obj
door
Locked
Bumped(atom/movable/A)
if(istype(A,/mob/Player))
var/mob/M = A
if(src.unlocked_doors.Find(M))
src.Open()
else
if(M.contents.len)
if(M.unlockeddoor)
M.unlocked_doors.Add(src)
else
M << "You need the key!"


Right then, with this if it finds the door in M's list, open it.

If it didn't find the key, it checks if M has unlocked the door. If he has, add the door to M's unlocked doors list.
In response to DeathAwaitsU
"if(M.unlockeddoor)"

I'm kind of trying to make the doors easy to edit, so for each locked door I just have to set a "key = /items/keys/key/blahblah" to it. =/
In response to Hell Ramen
Ok...right...

If I understand you correctly, this example(which I actually tested) should work:

obj
door
density = 1
Bumped(atom/movable/A)
if(istype(A,/mob/Player))
var/mob/M = A
if(M.unlocked_doors.Find(src))
src.Open()
else
if(M.keys.Find(/obj/keys/key/correctkey))
M.unlocked_doors.Add(src)
M << "You can now open this door"
else
M << "You need the key!"


proc/Open()
world << "Pwned"
mob
verb
Gimme()
usr.keys.Add(/obj/keys/key/correctkey)

mob/var/list/unlocked_doors = list()
mob/var/list/keys = list()

obj
keys
key
correctkey
In response to DeathAwaitsU
Yay, thanks Death.