ID:2148350
 
(See the best response by Ter13.)
Code:
/area/black_out_outside
layer= AREA_LAYER
Entered(M)
M<<"[M] has entered the void"


Exited(M)
M<<"[M] has left the void"


How would i make it so that when M enters the void area the outside world becomes darker,Without using opacity?

Best response
One way to acheive this is to use override images. override images can change the appearance of an atom provided you show the image to a player by adding it to the client's images list.

var/list/outside_images = list()

//create a new subtype of /image to allow for quicker initialization
image
outside
icon = 'black.dmi'
alpha = 128
plane = OBSCURE_PLANE //an arbitrary plane above your map plane, but below your screen plane.
layer = FOREGROUND_LAYER
override = 1

//change how areas work a little bit.
area
var
outside = 0 //whether this is an outside region

//override Entered/Exited() to keep track of outside images and show them to/hide them from clients.
Entered(mob/m)
if(istype(m)&&outside&&++m.outside==1&&m.client)
m.client.images -= outside_images

Exited(mob/m)
if(istype(m)&&outside)
if(--m.outside==0&&m.client)
m.client.images += outside_images
else if(m.outside<0)
m.outside = 0

//override New() to create outside images and add them to a global list
New()
if(outside)
outside_images += new/image/outside('black.dmi',src)
..() //supercall may not be needed

mob
var/tmp
outside = 0 //outside variable works as a counter of how many outdoor areas our bounds are straddling

proc
updateOutside() //called to recalculate the outside counter manually
client.images -= dark_images
var/counter = 0, success = 0, list/tested = list()
for(var/turf/t in locs)
if(tested.outside)
tested |= t.loc
if(tested.len>counter)
++counter
++success
outside = success
if(outside)
client.images += dark_images


A few notes, 'black.dmi' should be an all-black icon at world.icon_size dimensions.

In isometric or side_map, the layer of the override images should be FOREGROUND layer. For topdown, it doesn't really matter, though.

Your HUD objects should always be on a separate plane from your map objects. These override images use a different plane to ensure conflicts do not occur. You can get away without the plane setting, but be aware that this approach requires some customization.

If you ever set a mob's location manually, you need to call updateOutside(). Otherwise, the position will be out of sync and the counter will be inaccurate. Ideally, you should never set position manually because it makes tracker systems unreliable.
Thank you!