ID:267336
 
Does Entered() work with objs? My friend told me it did, but when i tried it it didn't. If it doesn't, or if i jsut don't know how to use it, is there an alternate way of checking to see if a person walks over an obj?
It doesn't. What you can do is this:

turf
Entered(mob/M)
if(ismob(M))
if(locate(/obj/blah) in src) //if there's an object on the turf (in the turf's contents)
//stuff
return..()
In response to Nadrew
So then, lets say i have a door code like this
obj/door
density = 1
Click()
density = 0

it order to close it, would this work?
turf
Entered(mob/M)
if(ismob(M))
var/obj/door/O
if(locate(O) in src)
O.density = 1

would that work?
thanks
-Magnus
In response to Magnus VI
You could try it before asking, the best way to learn is through trial and error.
In response to Nadrew
ok, sorry, its just that im at school right now.
Magnus VI wrote:
Does Entered() work with objs? My friend told me it did, but when i tried it it didn't. If it doesn't, or if i jsut don't know how to use it, is there an alternate way of checking to see if a person walks over an obj?

Entered() does work with objs, but not in the way you thought it would. It does not check to see if a person walked over it, because what the person's mob entered was the turf it's on, not the obj itself.

The way Entered() works for all atoms--turfs, objs, mobs, and areas--is to be called whenever something uses Move() to enter its contents list. When you walk onto a turf with another obj, obj.Entered() is not called because you didn't get into the obj; you stepped onto the turf. However if the obj was some kind of treasure chest and you could climb in, then Entered() would be called for it.
obj/treasurechest
verb/Get_In()
set src in oview(1)
usr.Move(src)

Enter(atom/movable/A)
.=..()
if(!.)
A << "There's no room in [src]."
return 0

Entered(atom/movable/A)
if(ismob(A))
A << "It's cramped in here."
I hope that clears things up.

Lummox JR
In response to Lummox JR
Ah, I forgot about that method, thanks for the reminder.
In response to Lummox JR
  Enter(atom/movable/A)
.=..()
if(!.)
A << "There's no room in [src]."
return 0

Isn't that <code>return 0</code> redundant?
Probably the best way to handle this is to create two new procs, walkOver() and walkOff(), like this:
atom/movable/proc/walkOn(atom/movable/A)
atom/movable/proc/walkOff(atom/movable/A)

turf
Entered(atom/movable/A)
for(var/atom/movable/M in (src.contents - A))
M.walkOn(A)
..()
Exited(atom/movable/A)
for(var/atom/movable/M in (src.contents))
M.walkOff(A)
..()
obj
Door
walkOff(atom/movable/A)
if(loc.contents.len == 1) //If it's the only thing there
src.Close()

Landmine
WalkOn(atom/movable/A)
view() << "KABLOOIE!"
del(A)
In response to Garthor
Garthor wrote:
   Enter(atom/movable/A)
.=..()
if(!.)
A << "There's no room in [src]."
return 0
Isn't that <code>return 0</code> redundant?

Good point. Oh well; can't hurt.

Lummox JR
In response to Lummox JR
Actually, it could destroy an entire galactic civilization! Haven't you hever read Hitchhiker's Guide to the Galaxy?!
In response to Garthor
obj
stairs_A
icon = 'stairsup.dmi'
Entered(mob/M as mob)
if(!M.client)
return
else
M.movable = 0
M.Fade_Out()
M<<sound("stairs.wav")
M.loc = locate(M.x,M.y,M.z+1)
sleep(10)
M.Fade_In()
M.movable = 1

so using that, how can i change the stairs to an object?
because for some reason i couldnt call the mobs variables.

I tried this
obj
stairs_A
icon = 'stairsup.dmi'
WalkOn(atom/movable/A)
if(ismob(A))
if(!A.client)
else
A.movable = 0
A.Fade_Out()
A<<sound("stairs.wav")
A.loc = locate(A.x,A.y,A.z+1)
sleep(10)
A.Fade_In()
A.movable = 1

but that didnt work. Please help.

ETG
In response to Erdrickthegreat2
Did you include the Entered() and Exited() changes I wrote for your turfs?
In response to Garthor
atom/movable/proc/walkOn(atom/movable/A)
atom/movable/proc/walkOff(atom/movable/A)

turf
Entered(atom/movable/A)
for(var/atom/movable/M in (src.contents - A))
M.walkOn(A)
..()
Exited(atom/movable/A)
for(var/atom/movable/M in (src.contents))
M.walkOff(A)
..()

obj
stairs_A
icon = 'stairsup.dmi'
WalkOn(atom/movable/A)

if(!A.client)
else
A.movable = 0
A.Fade_Out()
A<<sound("stairs.wav")
A.loc = locate(16,17,1)
sleep(10)
A.Fade_In()
A.movable = 1

obj junk.dm:19:error:A.client:undefined var
obj junk.dm:21:error:A.movable:undefined var
obj junk.dm:22:error:A.Fade_Out:undefined proc
obj junk.dm:26:error:A.Fade_In:undefined proc
obj junk.dm:27:error:A.movable:undefined var
obj junk.dm:17:error:WalkOn :undefined proc

this is what i have.
In response to Nadrew
What i have now, should work, yet it doesn't.
obj/door
icon = 'turfs.dmi'
var/orig
jaildoor
icon_state = "jaildoor"
orig = "jaildoor"
density = 1
verb/action()
set src in oview(1)
set hidden = 1
if(src in get_step(usr,usr.dir))
src.density = 0
src.icon_state = "blank"
turf/Entered(mob/M)
if(ismob(M))
var/obj/door/O
if(locate(O) in src)
O.density = 1
O.icon_state = O.orig


can someone help?
thanks
In response to Erdrickthegreat2
Okay, first of all, it's walkOn, not WalkOn. Second, after you do an ismob() check, use var/mob/M = A, and then use M.

if(ismob(A))
var/mob/M = A
if(M.client)
...
In response to Lummox JR
Lummox JR wrote:
Garthor wrote:
   Enter(atom/movable/A)
> .=..()
> if(!.)
> A << "There's no room in [src]."
> return 0
Isn't that <code>return 0</code> redundant?

Good point. Oh well; can't hurt.

It's not a bad habit, especially if you work in other languages that don't default to a return value of zero. The Vignette TCL interpreter I must suffer at work comes to mind.
In response to Garthor
thanx that helped