cansee

cansee <creature> <target>

Whether a creature can perceive a target.

cansee applies the game's normal visibility rules — darkness, invisibility, hide, and the perceiver's own senses — to decide whether the first creature can see the second entity. The target may be another creature or an object.

Arguments

Returns

A booltrue if the creature can perceive the target, false otherwise.

Examples

after command (say) {
  do "say I can see you: [cansee $self $actor]."
}

When the actor is plainly visible in the room, [cansee $self $actor] is true.

after command (say) {
  oload 1
  let item [first [inventory $self]]
  do "say can see item=[cansee $self $item]."
}

After oload places an object in the owner's hands, [cansee $self $item] is true for that visible object.

before command (steal) {
  if [not [cansee $actor $self]] {
    do "say You cannot steal what you cannot see."
  }
}

The body runs only when the actor cannot perceive the owner — for instance while the owner is hidden or the room is dark (see Control flow).

See also