ID:155506
 
How would i make it so when a player comes direcly infront of an object he will get an overlay over his head to tell him to press a button to do a action
obj
button_overlay
object

Entered(atom/a)
..()

if(ismob(a))
var/obj/button_overlay/b = new
a.overlays += b

Exited(atom/a)
..()

for(var/obj/button_overlay/b in a.overlays)
del(b)


Basic usage of Entered() and Exited().
In response to Cyberlord84
The OP said infront of the object, not when he steps on it.
In response to Cyberlord84
last time i tested the entered() and exited() events aren't calling on the /obj type & only on /turf & /area types

anyways, if its something like that you can detect on New() when it's created & tell it to create a turf or area 1 tile in that direction & used entered/exit procs that are built in to make it show the overlay & remove it.

Also you could put it on the map but if you just want to handle moving 1 object & such(if you plan on moving them at all) or just don't want to miss 1 accidentally & want it to do it for you probly best to use the built in New() proc.

However, please be aware that it could mess with the turfs/areas already in place when using New() so you want to be sure that everything/everywhere its placed has the right icons/code references, etc.... so that they can do everything it needs to if you had been using area/turf there already.

Turf can still be easy to do using this though if they are generic because you can put a special type in & make the new turf mimic the icon & name(for sake of mouse-over showing the right thing) so thats an easy way as well if area is used for something if you want to use turf as well & still use New() & such.

---Hope this makes sense.
In response to Cyberlord84
This doesn't work, you can't enter an object in the same way you enter a turf. When you step on a turf you enter its contents list simply by being there, OBJ's don't behave the same way, same for mobs.