ID:999787
 
(See the best response by Kaiochao.)

obj
dirtwall
icon='turfs3.dmi'
icon_state="dirtwall"
New(client/C)
screen_loc = "2,2"
C.screen+=src
invisibility=0
MouseDrop(var/turf/a)
var/mob/M
for(M in view(3,usr)))
if(text2num(M)<=1)
new/turf/dirtwall3(a)
world<< usr.client
world<< a


I was thinking I could count the amount of mobs in range and if the amount was more, including or not including the usr. I could have it make new turf.

Best response
If you're checking for no surrounding mobs, try this:
!length(ohearers(3, usr))
Yes, I was checking for no surrounding mobs that works just the way I want it to, thank you for your help.
if(text2num(M)<=1)

This line does not do what you think it is doing. M is not text, M is a mob. text2num() converts a text string into a number value. You are attempting to convert a mob into a number, which does not make sense.

Also, the way you currently have your for() loop set, it will attempt to create a wall for EVERY mob in view(3,usr). So if there are 10 mobs, it will attempt to create 10 walls.