Ability: movable

Description:

Inherits ability containable.

This ability is used for objects which can move from one environment to another.

A movable object may be temporarily declared unmovable. If you are planning to have an object that cannot be moved at all, then there is no point in it having this ability.

Usage:

#include <ability.h>

inherit MOVABLE;

Functions:

All functions in ability containable.

int query_moveable()
Return 1 if the object is movable, 0 otherwise.

int set_movable(int f)
If f is 0 then the object is not movable (temporarily), otherwise it is movable. Initially, the object is movable.

int movep(object dest)
If this object may move to destination dest, return 1, and 0 otherwise. Note that this function should perform tests that are specific to this object. It need not bother checking if there is enough room in dest, for example, since dest->move_to_p(this_object()) does that. (See functions move_to_p and move_from_p in ability container.)

int move_allowed(object dest)
This function combines the three functions (movep, move_from_p, move_to_p) check if a move is allowed. Whenever you want to check if a move is allowed, call this function. Do not try to call the other three by hand, because this one does what is supposed to be done.

Return 1 if the move is allowed, 0 otherwise.

vararg int move(object dest, mixed ob_msg, mixed env_msg, mixed dest_msg)
Move this object to object dest. Before actually moving the object, the function checks if the move is allowed (see move_allowed).

The optional arguments ob_msg, env_msg and dest_msg are messages which are transmitted to the object, its environment and the destination. Note that the environment receives the message after the object has been moved from it, and the destination before the object is moved into it. The messages are in standard message format (see "Messages").

Source code:

/ability/movable.c.

See also:

Ability: container
Class: thing