ID:170051
 
obj/Doortube
icon = 'turf.dmi'
icon_state = "Doortube"
density=1
Bump(mob/M)
if(istype(M,/mob/))
if(M.health<30)
if(src.icon_state=="Doortube")
M<<"*SNAP"
src.icon_state="Doortube2"


When i bump this, nothing happens. Any suggestions on why not?

~>Jiskuha
Jiskuha wrote:
> obj/Doortube
> icon = 'turf.dmi'
> icon_state = "Doortube"
> density=1
> Bump(mob/M)
> if(istype(M,/mob/))
> if(M.health<30)
> if(src.icon_state=="Doortube")
> M<<"*SNAP"
> src.icon_state="Doortube2"
>

When i bump this, nothing happens. Any suggestions on why not?

~>Jiskuha

For one, you're doing it all wrong. The door doesn't bump into the user, thus you do:

mob/Bump(atom/a)
if(istype(a,/obj/Doortube))
if(src.health<30)
if(a.icon_state=="Doortube")
src<<"*SNAP"
a.icon_state="Doortube2"
In response to Asohtra
Hey, don't bump() the posts. :) Your suggestion works fine, but to make the logic more tied to the system in operation, I recommend using a GotBumpedBy() proc for atoms. It'll be defined like this:
atom/proc/Bumped(atom/movable/A)

Then you use Bump() to send src to the Bumped object, and in there, you make all the calculations. It'll look like this:

atom/movable/Bump(atom/Obstacle)
Obstacle.GotBumpedBy(src)

atom/proc/GotBumpedBy(atom/movable/A)
// Nothing happens here by default.

obj/Doortube/GotBumpedBy(atom/movable/A)
if(istype(A, /mob)) // I assume all mobs have health
var/mob/M = A // Create a mob variable to avoid using the dangerous colon operator.
if(M.health < 30 && src.icon_state == "Doortube")
M << "*SNAP"
src.icon_state = "Doortube2"


See how all the doortube logic is now encapsulated within that object? That's how it should be.


/Gazoot