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
<creature>— the perceiving creature. A null value or a non-creature yields false.<target>— a creature or an object that might be seen. A null target yields false.
Returns
A bool — true 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).