ID:270334
 
I've already got monsters in my game,but I was wondering is there anyway to prevent monsters from going on specific tiles,but still allow people to move around on that tile.I tried some of the monster demos but none of them had anything like that on it.Could anyone help me out?
Hey, I am a little rusty... Haven't been on for a few weeks, but I think what you are looking for here is Enter().

A little something like this

turf
grass
Enter(var/mob/M)
if(ismob(M)&&M.client)//Checks if it's a mob and is a player(client)
..()//Let's em pass
return
In response to Exophus
Somewhat right, except you need to return 0 under an else statement.
In response to Artemio
Still wrong. In every case it'd return false.
turf
grass
Enter(var/mob/M)
if(ismob(M)&&M.client)//Checks if it's a mob and is a player(client)
return ..()//Let's em pass
return FALSE


..() will return the default action for this situation, and that's what you want to return when the enteree is a player. Then you'll want to return false if it's anything else.
In response to Crashed
Thanks for your help guys,code works great.

All I need now is another code like this but does the opposite,so players cannot pass but the monsters can.
In response to Pvt.Sampson
turf    
badgrass
Enter(var/mob/M)
if(ismob(M) && !M.client)//Checks if it's a mob and isn't a player(client)
return ..()//Let's em pass
else
return FALSE

In response to SJRDOZER
I mean a code exaclty the same as that BUT it allows mobs to pass and not the client.
In response to Pvt.Sampson
Pvt.Sampson wrote:
I mean a code exaclty the same as that BUT it allows mobs to pass and not the client.


thats what it does, the !M.client, means no client

the ! is the not operator
In response to Albire
Ah sorry,I was kinda tired and missed the alteration to the code.