ID:164162
 
When you have entered a tile with broken glass in it, I want the player to have damage taken, but what I have doesn't seem to work. Nothing for the player is called, and the blood object isn't created. The error I've made is probably some silly mistake, but I've tried everything I can think of, but nothing prevails.

obj
Glass
icon_state="glass"

Entered(atom/O)
if(istype(O, /mob/player))
O.TakeDamage(damage=2, damagetype="piercing")
new /obj/Blood(O)


I know that it isn't because the procedure called isn't working, and if you enter the glass, you should be a /mob/player, but just to be sure, if I take it out, it still doesn't work.

Any suggestions?
What you've got there is very well set up - use of Entered() is correct, use of the argument to Entered() is correct, it's all very properly set up.

One problem, though - you're not entering the glass. You're entering a turf that contains the glass. You'll have to do something like this:

obj/Glass
proc/SteppedOn(mob/m)
m.TakeDamage(damage=2,damagetype="piercing")
new /obj/Blood(loc) //Makes blood on the tile the glass is on - you had it being made 'inside' the entering object. Not sure if that's what you want

turf
Entered(atom/o)
var/obj/Glass/g=locate(/obj/Glass) in src //Gets a glass object inside the turf if one exists. Null otherwise
if(g&&ismob(o)) g.SteppedOn(o)


If you override Entered() for any other turfs, you'll want to call the parent procedure (..()) for this to apply.
obj/proc/Trigger()//Give all objs teh trigger proc!

turf/Entered(atom/movable/a)//when a movable atom has entered
for(var/obj/O in src.contents)O.Trigger(a)//look and see if there is an obj that we can trigger
..()

obj/Glass
icon_state="glass"
Trigger(atom/movable/a)
if(istype(a,/mob/player))
a.TakeDamage(damage=2, damagetype="piercing")
new/obj/Blood(a.loc)


That should work :/.