ID:2140608
 
(See the best response by Kaiochao.)
Code:
mob
player
var/trapped = 0
area
trap_zone
Entered(mob/player/pl)
pl.trapped = 1


Problem description: I am trying to make an area where, as a mob/player enters it, then its var/trapped is set to 1. The above works good but as soon as a moveable object enters it, then it gives error because that doesn't have a var/trapped. I thought Entered(mob/player/pl) will only proc upon mob/player entering it... How can I fix this?

You're not accounting for objects within the Entered() parameters. It's best to just use /atom/movable in these cases as a catch-all then filter accordingly.

mob
player
var/trapped = 0
area
trap_zone
Entered(atom/movable/A)
var/mob/player/P = A
P.trapped = 1
In response to Azurift
Best response
DM doesn't filter like that. The problem here is that anything that enters the area becomes the first argument to Entered(), regardless of the type.

Just check for the type of object that entered:
area
trap_zone
Entered(atom/movable/M)
if(istype(M, /mob/player))
var mob/player/player = M
player.trapped = 1
Kaiochao hit it on the head. The first argument to Entered() will always be an /atom/movable type, because they're the only atoms that move, but it's never guaranteed to be a specific type you want like /mob/player; objs will trigger it too. If you want type-specific behavior you have to check the type.