ID:264647
 
Code:
obj
icon='Items.dmi'
Health
icon_state="1"
mouse_opacity=2
Entered()
world<<"1"
if(usr.Hp>=usr.MaxHp)
del src
else
if(usr.Hp<=usr.MaxHp)
usr.Hp+=20
world<<"2"
if(usr.Hp>=usr.MaxHp)
usr.Hp=usr.MaxHp
world<<"3"
usr.HP()
del src


Problem description: I cant seem to get it to call Entered() when I enter the object. You can see I have tried debugging the code, but i still get nothing.

Thanks

Two problems:

1) usr doesn't belong here. Entered() takes two arguments, the first of which is the atom entering. You need to use that argument, not usr.

2) The mob isn't actually entering the obj; it's entering the turf that the obj happens to be sitting on. You need to be overriding turf/Entered() and have it look for items that can be picked up.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
2) The mob isn't actually entering the obj; it's entering the turf that the obj happens to be sitting on. You need to be overriding turf/Entered() and have it look for items that can be picked up.

Note that this should be done in an object-oriented way, by defining a generic proc for objs and mobs for when they get stepped on (in the same way that Entered() is a generic proc for atoms for when they get stepped into). Like so:

// Parent of obj and mob
atom/movable
proc
Stepped_On(atom/movable/Obj, atom/OldLoc)
// Do nothing

atom
proc
Entered(atom/movable/Obj, atom/OldLoc)
..()
// Call Stepped_On() for everything in our contents
for(var/atom/movable/M in src)
M.Stepped_On(Obj, OldLoc)


Now, you can override Stepped_On() for specific objects (ideally, items in general) to do what you want.
In response to Garthor
Note that you forgot to prevent movables from calling Stepped_On() for themselves.
In response to Kaioken
Don't judge them! They're just clumsy, is all.