ID:149441
 
Ok, for my MUD I'm making all sorts of mobs. How would I make it so say if a goblin were in a room ever say 10 seconds it would say "There is a Goblin amidst, keep your guard up."?
turf/Grass//or whatever turf name
icon='grass.dmi'//or what ever the turf is in
Enter()
if(istype(,/mob/goblin))
oview(10)<<"There is a Goblin Amist keep your gards up"
In response to Strange Kidd
turf
Entered()
for(var/mob/M in src.contents)
usr << M
..()
In response to Sariat
Would this work the same way for an area? And will this say the same message every 10 seconds or so?
In response to Daemon5532
It will if you tell it to.
In response to Daemon5532
Daemon5532 wrote:
Would this work the same way for an area? And will this say the same message every 10 seconds or so?

For areas you'll have to loop through every turf in the area, then loop through the contents of each turf.

Lummox JR
In response to Lummox JR
And I'm curious on how you do that, it's what I asked for in the first post.
In response to Daemon5532
Daemon5532 wrote:
And I'm curious on how you do that, it's what I asked for in the first post.

Loop through every turf in the area, then through each turf's contents, as I said: Pretty straightforward.
for(var/turf/T in thearea)
for(mob/M in T)
...

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Daemon5532 wrote:
And I'm curious on how you do that, it's what I asked for in the first post.

Loop through every turf in the area, then through each turf's contents, as I said: Pretty straightforward.

Areas are an exception to the normal contents behaviour. Areas contain not only the turfs that are directly in them, but also the contents of anything in the area. I ran into this little known fact when I put tanks into a random atom in the spawn area contents and found tanks popping up in another player's inventory. Anyway, you can simply filter all the mobs in the area instead of going through the turfs to find the mobs.

for(var/mob/M in thearea)
...
In response to Shadowdarke
Shadowdarke wrote:
Areas are an exception to the normal contents behaviour. Areas contain not only the turfs that are directly in them, but also the contents of anything in the area. I ran into this little known fact when I put tanks into a random atom in the spawn area contents and found tanks popping up in another player's inventory. Anyway, you can simply filter all the mobs in the area instead of going through the turfs to find the mobs.

Huh. I didn't realize that. That's pretty useful after all, then.

Lummox JR