ID:155356
 
How do i make a door respond when a player is near by?
You mean when player Bumps into it?
If yes, look into the reference (F1) for Bump() proc.
You would want to define Bumped()

atom
proc
Bumped(atom/Bumper)
..()
movable
Bump(atom/Obstacle)
Obstacle.Bumped(src)
..()


Now you can just call Bumped() on the door instead of one long Bump()

obj
Door
Bumped()
// door code


If you want it to detect people nearby and open without bumping

There are few options:
- You can set a loop to detect people nearby the door once in awhile.
- You can set 'sensor' turf that will open the door when a player enters using Entered() proc
- You can call nearby doors to open on Move()
If you need more information about those methods, just ask.
In response to Rotem12
i'm more interested in when a player is 1 space in-front of said door.

Not on the door itself.
There are several ways you could approach this.

1) Have doors constantly check for nearby mobs.

2) Have mobs constantly check for nearby doors.

3) Have mobs check for nearby doors when moving.

The first two, while working perfectly fine, will bog the game down with unnecessary processing. It's overkill for an otherwise simple and light function. The third option makes the most sense. It's only active when it's needed and avoids unnecessary CPU usage.

First you'll need to make the actual door and provide it with a function to open and close.
// What this does is check to see if the door is already open by looking at its density.
// If the door is dense, that means it's closed. If it's not dense, that means it's open.
obj/Door
var/open_clock=0
proc
Open()
open_clock=10 // Set the clock to 10 seconds.
if(density)
density=0
icon_state="open"
// Since the door is just now opening it starts a timer before it closes again.
// The timer is used to prevent the door from closing in the face of a mob which just came into range.
spawn()while(1)
open_clock--
if(open_clock<=0)
density=1
icon_state="close"
return
sleep(10)


Now that the door is ready, all that's left is to trigger the door's Open() proc whenever the mob moves.
// We're triggering this from the client so mob/Move() doesn't make unnecessary calls to DoorCheck().
client/Move()
..()
mob.DoorCheck()

// Since the mob is checking for doors it's only appropriate to attach this proc to mobs.
// There's also the possibility you might want to have NPC's opening doors at some point.
mob/proc/DoorCheck()
for(var/obj/Door/D in orange(1,src))
D.Open()