ID:272695
 
How do I make a roofing icon disappear when a mob walks under it? I've tried using Entered() and Exited() with the see_invisible variable, but no luck.
Make the roof an area, and use area/Entered() with the invisibility var. Not see_invisible.
In response to Andre-g1
Not working :(

area
Roofing
invisibility = 0
layer = MOB_LAYER+1
Main
icon = 'Turfs.dmi'
icon_state = "Roof"
Entered(mob/M)
src.invisibility = 1
Exited(mob/M)
src.invisibility = 0
In response to Mizukouken Ketsu
mob
see_invisible = 2

area
Roofing
invisibility = 1
layer = MOB_LAYER+1
Main
icon = 'Turfs.dmi'
icon_state = "Roof"
Entered(mob/M)
M.see_invisible=0
Exited(mob/M)
M.see_invisible=2


Try that.
In response to Andre-g1
Ah thanks.

Now...

Is there a way to get a turf to merely overlap another turf, not delete the underlaying turf? Like I want the roofing in the previous posts to be put over the walls, but I still want the wall to be there for when the player walks into it.
In response to Andre-g1
You can also use images, which are probably the best solution in this case; the invisibility related vars are very useful for other sight related things.
In response to Andre-g1
Do not forget that movement related procedures, like Entered(), Exit(), Bump(), etc. do not check if the argument is the type you entered.

For example, if a projectile (an /obj for this example) entered "area/Roofing/Main", then Entered() will be called even though you have "Entered(mob/M)"... and it'll cause a runtime error since see_invisible is a mob only variable.

So, to avoid runtime errors in movement procedures, always check if the object in the argument is what you want:
            Entered(mob/M)
if(ismob(M))
M.see_invisible=0
Exited(mob/M)
if(!ismob(M)) return
M.see_invisible=2
In response to Mizukouken Ketsu
Is there a way to get a turf to merely overlap another turf, not delete the underlaying turf?

No, you need to use another type of object.
In response to Jeff8500
Like that?

image
icon = 'Turfs.dmi'
icon_state = "Roof"
In response to Jeff8500
What do you mean by "another type of obj"? It's an area I'm using, not turf|obj.
In response to Mizukouken Ketsu
No, I meant object.
In response to Mizukouken Ketsu
You would want to give it its own type, too.
In response to Jeff8500
Objects don't delete the underlaying turf? I'll look up the obj.type thing in the Guide.
In response to Mizukouken Ketsu
Objects is a general term in object-oriented program that can mean any form of thing that holds data.
In response to Jeff8500
So I'd have to create something like...?

Roof
icon = 'Turfs.dmi'
icon_state = "Roof"
In response to Mizukouken Ketsu
...datums don't have an icon variable. When I say another type of object, I mean another form of atom that can do what you want. An obj would work be kind of be the equivalent of two turfs on the same location (minus the Enter() etc. proc being called).

I think we might be on two different subjects, though. Here's an example of how to use /image objects to do what you want

var/list/roof_images = new //make a list of roof images

image/roof //make a new /image/roof type
icon = 'roof.dmi'
New()
..()
roof_images += src //add it to the roof_images list

area/building //make an area for buildings
Exited(atom/A) //when something exits it
..()
if(ismob(A)) //if its a mob
var/mob/M = A
if(M.client) M.client << roof_images //and it has a client
//display the roof images to it
Entered(atom/A) //when something enters it
..()
if(ismob(A)) if its a mob
var/mob/M = A
if(M.client) M.images -= roof_images // and it has a client,
// take away the roof images
Take a look at Shadowdarke's RoofLib (it's free now, despite what the hub says). I've never tried it, but Shadowdarke's libraries tend to work well and are fairly easy to use.
In response to Jeff8500
It would be better to have an individual <code>roof_images</code> list for each <code>area/building</code>, unless he plans on having only one building with a roof.