A
/ \ _ Play Now Nemesis on
| | | | _______ _ _ _______ _______ _ _______
| |\ | | | ____| | \ / | | ____| / ____| | | / ____|
/-------/-------------------------------------------------------------------,
O= Home <=XX| About News Pics Adventurers Wizards Download Connect >
\-------\-------------------------------------------------------------------'
| | \ | | |____ | | | | | |____ ___ \ \ | | ___ \ \
| | \_| |_______| |_| |_| |_______| |_______/ |_| |_______/
\ /
V
Documentation Area
Document Path: /doc/concepts/store_items
In Nemesis2 the inventory of all players is saved over a logout or crash.
This means that the filenames and variable data of the objects in the inven-
tory of a player are stored in the player.o-file at saves or logout. When the
players logs in again those items that are stored are cloned according to the
saved filenames and the variable data is set according to what has been saved.
Now, you as a wizard have the responsibility to make sure that your objects
work correctly after they are re-cloned. Different kinds of objects require
different actions. There are 3 classes of objects in this matter:
1) Simple objects and objects with no variable data
2) Objects that inherit standard objects but differ from the standard data
3) Objects that have own variable data
Simple objects are here objects that are cloned from standard objects (file-
names beginning with /obj/) and that are configured using set_class. See also
'man tables'. Variable data is data that changes during the existance of an
object, like the fuel in a lantern.
Objects of type 1) require no changes to become saveable. They are just cloned
and in the case of standard objects the class provides all the information
necessary to recreate the object. If an object hast no variable data at all,
(like a magazine for example) it is just necessary to clone it.
Example:
weapon=clone_object("obj/weapon");
weapon->set_class("longsword");
The set_class call sets all the necessary data in the sword. Standard objects
care about their generic data themselves.
Objects of type 2) differ from the default values set with set_class, there-
fore those objects have to be put into a separate file and inherit must be
used instead of clone_object.
Example:
inherit "obj/weapon";
reset(arg) {
::reset(arg);
if (arg) return;
set_class("longsword");
set_short("a fine longsword");
set_value(500);
}
Again the standard object cares about the variable data on save and restore.
Objects of type 3) are special objects created by wizards. The wizard hast to
care for the saving of all variable data in that object. If the object in-
herits a standard object the wizard mustn't forget the variable data from the
standard object.
Example:
inherit "obj/item";
int charges;
reset(arg) {
::reset(arg);
set_id( ({ "a wand" }) );
set_short("a magic wand");
charges=5;
}
save_data() { return charges; }
load_data(arg) { charges=arg; }
This a magic wand with a limited number of charges. It is necessary to save the
charges left. The convenience functions load_data and save_data allow the
wizard to save and restore variable data. The example above shows how a single
variable can be saved, the next example shows how this can be done with
several variables using an array:
save_data() { return ({ charges, hits }); }
load_data(arg) { charges=arg[0]; hits=arg[1]; }
In the example above the object inherits a standard object with no variable
data itself (obj/item). If the inherited object has extra variable data, this
has to be respected:
save_data() { return ({ charges, ::save_data() }); }
load_data(arg) { charges=arg[0]; ::load_data(arg[1]); }
It's not that hard, is it? Well, now the whole thing in short:
1) If you have a simple object you don't have to change anything
2) If you have an object that inherits a standard object but differs in
one or more of the standard values, you have to put it into a separate
file.
3) If you have an object that has own variable data, you have to make sure
that the data is saved and restored using save_data and load_data.
This page was generated in LPC
Imprint / Impressum