ID:161105
 
Code:
turf
roof
icon = 'roof3.dmi'
turf
roof
layer = MOB_LAYER+1 //overhead

Problem description:
I need help with this the roof works but i cant see whats uner the roof my mob just goes in how do i make where i can see whats inside the building?

Well, one way to do it would be to have a special state for when someone enters the area (we would be changing this to an /area insted of a /turf).
area/roof
icon_state = "roof_state"
layer = MOB_LAYER + 1

var
//When a player enters it, it will be turned into
//a floor.
entered_state = "floor_state"

//It will be on the same level as turfs when a
//player enters it.
entered_layer = TURF_LAYER

Entered(mob/m)
//Called when the mob enters the area.

if(m.client)
//If the mob has a client (that means, if the
//mob is a player), then alter the icon_state
//and layer to be the pre-designated layer and
//icon_state.
icon_state = entered_state
layer = entered_layer

Exited(mob/m)
for(var/mob/m in contents)
//As long as a mob with a client (a player) is
//still in the /area's contents, don't do
//anything.
if(m.client) return

//When there are no more players present, then
//revert the icon_state and layer back to what they
//were initially.
icon_state = initial(icon_state)
layer = initial(layer)
In response to Popisfizzy
another way to do it:

var/COVER_LAYER = 10
area
var
icon/covericon // icon file to use for this area's cover
covericon_state = "" // iconstate for the cover
image/coverimage /* image of the cover, stored with the area so it can be be added or
subtracted from from a client's view at will without creating
new images. */


Del()
if(coverimage) del(coverimage) // delete lingering images
..()

Entered(O) // O just entered this area
..()
// if this area is covered and O is a mob with a client
if(coverimage && ismob(O) && O:client)
O:client.images -= coverimage // remove the coverimage from the client's view

Exited(O) // O just exited this area
..()
// if this area is covered and O is a mob with a client
if(coverimage && ismob(O) && O:client)
O:client << coverimage // show the coverimage to the client

New()
..()
if(covericon) // if this area has a covericon
coverimage = image(covericon,src,covericon_state,COVER_LAYER) // make a coverimage of the icon

client
New()
..()
for(var/area/A in world) // loop through all areas in the world
if(A.coverimage) // if the area is covered
src << A.coverimage // show the coverimage to this client

// find the mob's area
var/area/A = mob.loc
while(A && !istype(A))
A = A.loc

if(A)
A.Entered(mob) // remove the coverimage
In response to Lureman
Lureman wrote:
another way to do it:

var/COVER_LAYER = 10
> area
> var
> icon/covericon // icon file to use for this area's cover
> covericon_state = "" // iconstate for the cover
> image/coverimage /* image of the cover, stored with the area so it can be be added or
> subtracted from from a client's view at will without creating
> new images. */

>
> Del()
> if(coverimage) del(coverimage) // delete lingering images
> ..()
>
> Entered(O) // O just entered this area
> ..()
> // if this area is covered and O is a mob with a client
> if(coverimage && ismob(O) && O:client)
> O:client.images -= coverimage // remove the coverimage from the client's view
>
> Exited(O) // O just exited this area
> ..()
> // if this area is covered and O is a mob with a client
> if(coverimage && ismob(O) && O:client)
> O:client << coverimage // show the coverimage to the client
>
> New()
> ..()
> if(covericon) // if this area has a covericon
> coverimage = image(covericon,src,covericon_state,COVER_LAYER) // make a coverimage of the icon
>
> client
> New()
> ..()
> for(var/area/A in world) // loop through all areas in the world
> if(A.coverimage) // if the area is covered
> src << A.coverimage // show the coverimage to this client
>
> // find the mob's area
> var/area/A = mob.loc
> while(A && !istype(A))
> A = A.loc
>
> if(A)
> A.Entered(mob) // remove the coverimage


Thank Shadowdarke for this way, because Lureman did not code it :)

http://www.byond.com/developer/Shadowdarke/RoofLib
In response to Popisfizzy
Popisfizzy wrote:
Well, one way to do it would be to have a special state for when someone enters the area (we would be changing this to an /area insted of a /turf).

Wouldn't this make the roof disappear for everyone when someone enters inside the roof? Shouldn't you use images to add and remove the roof, so it only effects the individual player?
In response to Soldierman
This was simply the simplest solution, and he hasn't replied or indicated he wants to do something differently. It could be done to make it only dissapear for a given player, but that would get a decent amount more complex.