ID:2392823
 
(See the best response by Nadrew.)
Code:
for(var/mob/M in world)
if(M in oview(5))
del(M)
else if(!(M in oview(5)))
world << "They aren't there?"


Problem description:
So, I've been looking for a solution to a major feature I'd like to use for my game. I'm looking for a code that allows me to search for something on the players screen or in their oview(), but if the desired object isn't there. I want it to perform another action.

Above, I put what I've been testing.
Best response
var/type/to/something/variable = locate() in oview(5)
if(variable)
// Found
else
// Not found.


As for the code you posted, you should avoid 'in world' anywhere you can when looping.
for(var/mob/M in oview(src,5))
In response to Nadrew
Thanks for the help!