ID:272085
Mar 24 2008, 1:12 pm
|
|
How do you make an obj's proc check to see if there is anything on top of it? (in the same tile)
|
In response to Fint
|
|
You confused me, let me clarify, i want an obj to check for any mobs, objs, or turfs in the same location as it and effect them.
|
In response to Lt. Pain
|
|
Well, the location of an obj is generally going to BE a mob or turf. I assume that, for this obj, it's always going to be a turf, though.
How do you want this to work? Something that periodically pings its location for other objects? You don't want to do that if you have a lot of these... but it's how you'd make, say, spikes that go up and down. On the other hand, if you want a trap that only triggers when a player steps onto the same turf that it's on, then you wouldn't want to repeatedly check for players, just have the players check for traps as they move. Which do you want? |
In response to Garthor
|
|
People need to pay attention to what others are saying, seriously lol.
Okay basically how to do this is just check for anything within the objs loc if its on the map... Heres an example... obj Untested but u believe thats what u want, atleast i hope so. Peace. |
In response to Bladeshifter
|
|
Your code is to situational.
The location of a obj or mob doesnt have to be a turf, don't forget this! It could be located inside a other mob or obj, or even have no location. |
In response to Lt. Pain
|
|
You could do something like this, i added some checks to make clear what I'm doing
if(src.loc) //if this object has a location, if it doesnt we dont want to continue And to effect the turf itself you could just set up a var after the istype() check. var/turf/t = src.loc Does this make things more clear? |
if(src.loc.contents.len > 1)
Were the src would be a movable atom (obj/mob)
You might want to check for a loc first, but if the movable atom has a loc it has to be a turf, and the location is the turf it's contents.
Any other obj on that turf will be in that contents
which would result in a contents list length of more than 1.
Just so you know, a turfs location is a area, which has a contents list of all turfs and objects inside it.
Not sure what you meen with "on top of it" but you could just check for layers i guess.
Hope that info helped
- Fint
PS: From the help:
"contents list var (atom)
default value: list of contained objects.
Except in the case of areas, this list is always restricted to objs and mobs (ie movable objects). Only direct contents are listed. Items inside of a bag object, for example, would not show up in the mob's contents list.
The contents of areas are a little different. The turfs contained in the area are in the list along with any objs or mobs directly contained by those turfs."