autoload

concepts
CONCEPT
	autoload

LAST UPDATE
	Pepel, Tue Sep 22 15:40:48 MET DST 1992

DESCRIPTION
	This file describes how autoloading works.

	Any object can be made autoloading. Autoloading means, that an
	object is automatically cloned and moved to the inventory of a
	player when the player logs into the world.

	When the player logs out, all objects in the inventory are checked
	if they define the propery P_AUTOOBJECT. If P_AUTOOBJECT returns
	a non-zero value, the objectfilename and the property value are
	stored in the P_AUTOLOAD property in the player object. The
	AUTOLOAD property is saved together with the other important
	player variables into the player save file. When the player
	object is restored on the next login, all autoload objects are
	loaded and the P_AUTOOBJECT property is set to the value stored
	in the player object.

	Making an object autoload is therefore very simple:

	card->SetProp(P_AUTOOBJECT,({"gold",2000}))

	marks the object <card> as autoloading and at the same time makes
	it a 'gold card' with an additional information value of 2000.
	What "gold" and 2000 mean is up to the card object. If you want to
	chance the information later, you can simply call
	SetProp(P_AUTOOBJECT,...) again with the new value later.

	When the object is auto-loaded during the restoration of the
	player object, ``call_other(ob, "init_arg", ...);''
	and ``ob->SetProp(P_AUTOOBJECT,...)'' are called by the
	player object. Thus, the object is explicilty told the values
	it wanted to have saved, and those values are automagically
	set again.

	There is one problem if the object needs to immediately set
	some things when it has been loaded depending on the value.
	create() cannot be used for this because P_AUTOOBJECT will be
	overwritten immediately. But create() is a good place to set
	up initial autoload information which is overwritten by the
	call from the player object if the object is loaded as part of
	the player restoration.

	If you want to immediately react when P_AUTOOBJECT is set up,
	you can make it a `builtin' property by defining the functions
	SetAutoObject() and QueryAutoObject() (see the #define in
	<properties.h>).

SEE ALSO
	properties(C)