ID:2027502
 
(See the best response by Azurift.)
Code:
turf
wall
icon = 'rock.dmi'
density = 1


Problem description: I create a turf that represents a wall, setting its density to 1 as walls can not be passed but there are some cases that I want to sets its density to 0 so it can actually be passed, but only for the current player (after he/she performed some actions). How can I do w/o making it for all the players? Consider for example I have a proc set_density under mob and want from there to change the wall's density to 0 but only for the specific player and not for all...

It depends on how exactly you want to choose who can go through the wall and who cannot.

One potential way is to modify the turf/Enter proc, this is the proc that checks whether a mob can pass into the turf and either permits (returns 1) or denies (returns 0) entry into the turf, the standard behavior is based on density.

But by overriding the Enter() proc for that specific type with your own code you can make ways to permit specific mobs entry.
In response to Clusterfack
Clusterfack wrote:
It depends on how exactly you want to choose who can go through the wall and who cannot.

One potential way is to modify the turf/Enter proc, this is the proc that checks whether a mob can pass into the turf and either permits (returns 1) or denies (returns 0) entry into the turf, the standard behavior is based on density.

But by overriding the Enter() proc for that specific type with your own code you can make ways to permit specific mobs entry.

turf/MonsterBlock
density=1
Enter(mob/M) //this gets ran when somebody tries to enter this location
if(ismob(M))
if(!istype(M,/mob/Monster))
return 1 //returning 1 here will automaticaly allow any non monsters to enter
Following the previous 2 responses, I would do something like this:

/* Somewhere... */
turf/MagicWall
var
list/allowed = list()

Enter(mob/m)
if(m in allowed)
return TRUE
else
return FALSE

/* Somewhere else... */
mob
verb
getAccessToMagicWall()
var/turf/MagicWall/mw = locate(/turf/MagicWall)
mw.allowed.Add(src)


This is a very basic example, and would not work under a ton of particular circumstances (like if you had multiple instances of /turf/MagicWall).
Best response
Here's my version:

mob/player/verb/thePower()
thePower = !thePower
if (thePower)
usr << "You have activated the power; you can walk through magic walls now!"
else
usr << "You have deactivated the power; you're back to being boring. Yay!"

turf/magicwall
icon = 'turf.dmi'
icon_state = "magicwall"
density = 1
desc = "A magic wall; only those with the power can step through it!"
Enter(mob/M)
if(M.client) // check to see if the mob in question has a client, thus making it a player
var/mob/player/P = M // cast the mob as a player to gain the attributes of it(like thePower)
if(P.thePower) // check to see if the mob (player) has thePower activated...
return TRUE // allow this mob (player) to enter this turf
else // if the mob (player) does not meet the above criteria...
return FALSE // then do not allow the mob (player) to enter
return ..()

Obviously you'll have to add a "thePower" boolean variable to Player. Hope this helps!

EDIT: Took a nap and looked at my code again--I forgot the return ..() call!
Typical Goose. Best solution in the most unweildly and unfriendly way possible.

I love it.