if( darkness == 0 )
darkness = 1
var/list/types = list()
for( var/turf/T in world )
if( !types.Find( T.type ) )
var/icon/a = new( T.icon )
a.SetIntensity( 0.5 )
T.icon = a
types += T.type
types[T.type] = a
T.icon = types[T.type]

Problem description:

Don't get sidetracked by the code pasted above. It's not the main concern here, but I thought it might help to outline the problem. I want the proc to cast "moonlight" over ALL turfs in the world. And it works for all turfs with the exception of those that have been "stacked" or "layered" in the map. By this, I refer to when one turf is laid down on the map, and then another turf is placed on top of it using the ctrl+click command. What actually happens when I use the proc is this:

It finds a turf by itself, non-layered, it casts moonlight, no problem.

It comes across a location where one turf is layered over the other, it casts moonlight over the topmost layer, ignores the bottommost.

What might be causing this behavior?
When you have multiple turfs, there's actually just one turf with the others being an overlay for that turf.
In response to GhostAnime
By that logic, the bottommost turf is the main turf, with the topmost being an overlay. If that's the case, why is it that the topmost turf turns dark while the bottommost remains as is? Shouldn't the main turf be the one to be recognized by the proc, and the overlay neglected? At this point, I'm open to any code corrections that will allow the Moonlight() proc to work for ALL turfs including layered turfs.
In response to Lethal Dragon
Isn't it the other way around and that the top turf is the main turf, and all things underneath it are added to its underlays?
In response to LordAndrew
Well I'm going to assume that the topmost is the main icon, and the layers beneath it are underlays. I am still unsure how to access and modify the icons associated with an object's underlays. How can I do this?
In response to Lethal Dragon
By accessing and modifying the underlays list.

Note that you cannot directly modify objects in the underlays list. The objects themselves are read-only. However, you can add and remove them, like so:

for(var/O in underlays)
var/icon/I = new(O:icon)
underlays -= O
underlays += I
In response to Garthor
So the idea is to copy the icon of the underlay, remove the existing underlay, modify the copy, then add a new underlay using the modified icon. That solved the problem, thanks!